/* styles.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2c3e50;
  --secondary: #34495e;
  --accent: #3498db;
  --success: #27ae60;
  --background: #ecf0f1;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #bdc3c7;
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  font-family: "Yu Gothic", "游ゴシック", YuGothic, "游ゴシック体",
    "Hiragino Kaku Gothic Pro", "Meiryo", sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: 2rem;
  overflow-x: hidden;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
}

/* ==================== ランディングページ用スタイル ==================== */
.landing-page {
  display: none;
  padding-bottom: 0;
}

.landing-page.active {
  display: block;
}

.landing-header {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--secondary) 100%
  );
  color: white;
  padding: 4rem 1rem;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
}

.landing-header h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: 2px;
}

.landing-tagline {
  font-size: 1.25rem;
  opacity: 0.95;
}

.landing-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
}

.feature-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  text-align: center;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px var(--shadow);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--accent);
  display: block;
}

.feature-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--primary);
}

.feature-card p {
  color: var(--text-light);
  font-size: 0.875rem;
  line-height: 1.6;
}

.books-section {
  margin: 4rem 0;
}

.landing-section-title {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 2rem;
  text-align: center;
  color: var(--primary);
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.book-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px var(--shadow);
}

.book-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

.book-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.book-description {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.book-isbn {
  font-size: 0.75rem;
  color: var(--text-light);
  font-family: monospace;
}

.cta-section {
  background: linear-gradient(135deg, var(--accent) 0%, #5dade2 100%);
  color: white;
  padding: 3rem 2rem;
  border-radius: 12px;
  text-align: center;
  margin: 4rem 0 2rem;
  box-shadow: 0 4px 16px var(--shadow);
}

.cta-section h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.cta-section p {
  font-size: 1.125rem;
  opacity: 0.95;
}

.landing-footer {
  background: var(--primary);
  color: white;
  padding: 2rem 1rem;
  text-align: center;
}

.landing-footer p {
  opacity: 0.8;
  font-size: 0.875rem;
  margin: 0.25rem 0;
}

/* ==================== 検索セクション ==================== */
.search-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.search-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.search-tab {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-light);
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-tab:hover {
  color: var(--accent);
}

.search-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.search-tab .material-symbols-outlined {
  font-size: 1.25rem;
}

.search-panel {
  display: none;
}

.search-panel.active {
  display: block;
}

.search-input-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-button {
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, var(--accent) 0%, #5dade2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.search-button:disabled {
  background: var(--border);
  cursor: not-allowed;
  transform: none;
}

#scanner-container {
  max-width: 500px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
}

#reader {
  border-radius: 8px;
}

.scanner-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  justify-content: center;
}

.loading-spinner {
  display: none;
  text-align: center;
  padding: 2rem;
}

.loading-spinner.show {
  display: block;
}

.spinner {
  border: 4px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.no-results {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

/* ==================== アプリページ用スタイル ==================== */
.app-page {
  display: none;
}

.app-page.active {
  display: block;
}

header {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--secondary) 100%
  );
  color: white;
  padding: 1.5rem 1rem;
  box-shadow: 0 2px 8px var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-title {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 0.25rem;
  font-weight: 400;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.sync-status {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  opacity: 0.8;
}

.sync-status.syncing {
  color: #f39c12;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
}

.loading {
  text-align: center;
  padding: 3rem;
  font-size: 1.2rem;
  color: var(--text-light);
}

.error {
  background: #fee;
  border: 2px solid #fcc;
  border-radius: 8px;
  padding: 2rem;
  margin: 2rem auto;
  max-width: 600px;
  text-align: center;
}

.error h2 {
  color: #c00;
  margin-bottom: 1rem;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal h2 .material-symbols-outlined {
  font-size: 1.5rem;
}

.modal.success h2::before {
  content: "check_circle";
  font-family: 'Material Symbols Outlined';
  color: var(--success);
  margin-right: 0.5rem;
}

.modal.warning h2::before {
  content: "warning";
  font-family: 'Material Symbols Outlined';
  color: #f39c12;
  margin-right: 0.5rem;
}

.modal.error h2::before {
  content: "error";
  font-family: 'Material Symbols Outlined';
  color: #e74c3c;
  margin-right: 0.5rem;
}

.modal p {
  margin-bottom: 1.5rem;
  color: var(--text-light);
  line-height: 1.6;
}

.modal input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  font-family: monospace;
}

.modal input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.modal-buttons button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 100px;
  transition: all 0.2s ease;
}

.code-display {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  margin-bottom: 1rem;
  word-break: break-all;
  font-family: monospace;
  font-size: 0.875rem;
}

.progress-comparison {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.progress-comparison-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.progress-comparison-item:last-child {
  border-bottom: none;
}

.progress-comparison-item .label {
  font-weight: 600;
  color: var(--text);
}

.progress-comparison-item .value {
  color: var(--accent);
  font-weight: 600;
}

.stats-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.stats-grid {
  grid-template-columns:: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stat-card {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-bar-container {
  margin-top: 1.5rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-light);
}

.progress-bar {
  width: 100%;
  height: 24px;
  background: #e0e0e0;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #5dade2 100%);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.5rem;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
}

.chart-container {
  margin-top: 1.5rem;
  height: 200px;
  position: relative;
}

canvas {
  max-width: 100%;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 1.5rem;
  background: var(--accent);
  border-radius: 2px;
}

.chapters-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.chapter {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: all 0.3s ease;
}

.chapter:hover {
  box-shadow: 0 4px 12px var(--shadow);
}

.chapter-header {
  display: flex;
  align-items: center;
  padding: 1rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  cursor: pointer;
  user-select: none;
}

.chapter-header:active {
  background: #e9ecef;
}

.chapter-checkbox {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: 2px solid var(--border);
  border-radius: 6px;
  margin-right: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chapter-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}

.chapter-checkbox.checked::after {
  content: "check";
  font-family: 'Material Symbols Outlined';
  color: white;
  font-size: 1rem;
}

.chapter-info {
  flex: 1;
}

.chapter-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.chapter-topics {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.chapter-sections {
  padding: 0.5rem 1rem 1rem 3.5rem;
  background: #fafafa;
  display: none;
}

.chapter.expanded .chapter-sections {
  display: block;
}

.section-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.875rem;
}

.section-checkbox {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  margin-right: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.section-checkbox.checked::after {
  content: "check";
  font-family: 'Material Symbols Outlined';
  color: white;
  font-size: 0.75rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 140px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #5dade2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
  background: white;
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  background: var(--background);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #229954;
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.install-prompt {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
  display: none;
  align-items: center;
  gap: 1rem;
}

.install-prompt.show {
  display: flex;
}

.install-prompt-text {
  flex: 1;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.install-prompt-text::before {
  content: "install_mobile";
  font-family: 'Material Symbols Outlined';
  font-size: 1.5rem;
  color: var(--accent);
}

.install-prompt button {
  min-width: auto;
  flex: 0 0 auto;
}

.sync-section {
  background: #f0f9ff;
  border: 2px solid #bae6fd;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.sync-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sync-section h3::before {
  content: "favorite";
  font-family: 'Material Symbols Outlined';
  font-size: 1.25rem;
  color: #e74c3c;
}

.sync-section p {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.sync-section .donation-info {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.firework-particle {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  animation: firework-explode 0.8s ease-out forwards;
}

@keyframes firework-explode {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .landing-header h1 {
    font-size: 2rem;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
  }
  
  .books-grid {
    grid-template-columns: 1fr;
  }
  
  .search-tab {
    padding: 0.75rem;
    min-width: 48px;
    justify-content: center;
  }
  
  .search-tab .tab-text {
    display: none;
  }
  
  
  .search-input-group {
    flex-direction: column;
  }
  
  .search-button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .site-title {
    font-size: 0.75rem;
  }
  h1 {
    font-size: 1.25rem;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-value {
    font-size: 1.75rem;
  }
  .actions {
    flex-direction: column;
  }
  button {
    min-width: 100%;
  }
  .modal {
    width: 95%;
    padding: 1.5rem;
  }
  .modal-buttons {
    flex-direction: column;
  }
  .modal-buttons button {
    width: 100%;
  }
}