/* ========================================================
   libオススメ - Modern Design System
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-dark: #1e40af;
  
  --accent: #0284c7;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #f8fafc;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;
  
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-glow: 0 0 20px -3px rgba(37, 99, 235, 0.25);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-sans: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 2.5rem 1.5rem 3rem;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 60%;
  height: 200%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

.header-container {
  max-width: 1000px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(37, 99, 235, 0.25);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #93c5fd;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-subtitle {
  font-size: 1.05rem;
  color: #cbd5e1;
  max-width: 700px;
  margin-bottom: 1.25rem;
}

.header-purpose {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: #94a3b8;
}

.header-purpose-title {
  font-weight: 600;
  color: #e2e8f0;
}

.header-purpose ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.header-purpose li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.header-purpose li::before {
  content: '✓';
  color: #38bdf8;
  font-weight: bold;
}

/* Main Layout */
.main-container {
  max-width: 1000px;
  width: 100%;
  margin: -1.5rem auto 2.5rem;
  padding: 0 1rem;
  position: relative;
  z-index: 2;
  flex: 1;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.75rem;
  margin-bottom: 1.75rem;
  transition: var(--transition);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.card-title svg {
  color: var(--primary);
  flex-shrink: 0;
}

/* Controls Grid */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

/* Input Area */
.input-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.input-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: var(--bg-card-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.char-counter.warning {
  color: var(--accent-amber);
  background: #fef3c7;
  font-weight: bold;
}

.char-counter.limit {
  color: var(--accent-rose);
  background: #ffe4e6;
  font-weight: bold;
}

.textarea-wrapper {
  position: relative;
}

.isbn-textarea {
  width: 100%;
  min-height: 110px;
  padding: 0.85rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-main);
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  resize: vertical;
  transition: var(--transition);
  line-height: 1.5;
}

.isbn-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Action Buttons Row */
.action-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-subtle);
  border-color: #cbd5e1;
}

.btn-subtle {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
}

.btn-subtle:hover {
  color: var(--text-main);
  background: var(--bg-card-subtle);
}

/* Current ISBN processing banner */
.processing-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  margin-top: 1rem;
}

.processing-banner.active {
  background: #ecfeff;
  border-color: #a5f3fc;
}

.processing-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #0e7490;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.processing-isbn {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: #155e75;
}

/* Thresholds & Options */
.thresholds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

.threshold-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.threshold-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.select-input, .text-input {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.select-input:focus, .text-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Settings Toggle Area */
.settings-details {
  margin-top: 1rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.75rem;
}

.settings-summary {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.settings-summary:hover {
  text-decoration: underline;
}

.settings-body {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
}

.help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Sample ISBN Chips */
.sample-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sample-title {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sample-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sample-chip {
  font-family: var(--font-mono);
  font-size: 0.785rem;
  padding: 0.25rem 0.6rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.sample-chip:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #93c5fd;
}

/* Results Section */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Status / Alert banners */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* Loading Spinner */
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: 1rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

.loading-subtext {
  font-size: 0.825rem;
  color: var(--text-muted);
}

/* Book Metadata Card */
.book-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
}

.book-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.book-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.book-meta-item {
  display: flex;
  gap: 0.5rem;
}

.book-meta-label {
  font-weight: 600;
  color: var(--text-main);
  flex-shrink: 0;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.stat-card-cinii {
  border-left: 4px solid var(--primary);
}

.stat-card-ndl {
  border-left: 4px solid var(--accent-cyan);
}

.stat-card-ratio {
  border-left: 4px solid var(--accent-emerald);
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
  line-height: 1.1;
}

.stat-link {
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.stat-link:hover {
  text-decoration: underline;
}

/* 2x2 Evaluation Matrix */
.matrix-container {
  margin: 1.5rem 0;
}

.matrix-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: #ffffff;
}

.matrix-table th, .matrix-table td {
  padding: 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 0.9rem;
}

.matrix-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
}

.matrix-table td:last-child, .matrix-table th:last-child {
  border-right: none;
}

.matrix-table tr:last-child td {
  border-bottom: none;
}

.matrix-header-cell {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-main);
  text-align: left;
  width: 180px;
}

.matrix-cell {
  position: relative;
  transition: var(--transition);
  font-weight: 500;
  color: var(--text-muted);
}

.matrix-cell.highlight {
  background: #fef08a !important;
  color: #854d0e !important;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: inset 0 0 0 2px #eab308;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: inset 0 0 0 2px #eab308; }
  50% { box-shadow: inset 0 0 0 3px #ca8a04; }
  100% { box-shadow: inset 0 0 0 2px #eab308; }
}

.evaluation-badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.95rem;
}

/* Libraries Accordion */
.libraries-section {
  margin-top: 1.5rem;
}

.libraries-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #ffffff;
}

.libraries-summary {
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  background: var(--bg-card-subtle);
  cursor: pointer;
  user-select: none;
}

.libraries-list {
  padding: 1rem 1.5rem 1rem 2.5rem;
  columns: 2;
  column-gap: 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.libraries-list li {
  margin-bottom: 0.35rem;
}

@media (max-width: 600px) {
  .libraries-list {
    columns: 1;
  }
}

/* Footer */
.app-footer {
  margin-top: auto;
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.825rem;
}

.footer-container {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-credits {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
}

.footer-credits a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.footer-credits a:hover {
  text-decoration: underline;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
