/* ──────────── Reset & Variables ──────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --clr-bg: #fafafa;
  --clr-surface: #ffffff;
  --clr-text: #1a1a1a;
  --clr-muted: #6b7280;
  --clr-accent: #2563eb;
  --clr-accent-hover: #1d4ed8;
  --clr-border: #e5e7eb;
  --clr-error: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  min-height: 100dvh;
}

/* ──────────── Layout ──────────── */

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--clr-muted);
  font-size: 1.05rem;
  margin-top: 0.25rem;
}

/* ──────────── Form ──────────── */

form {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

input[type="text"] {
  flex: 1;
  padding: 0.65rem 0.9rem;
  font-size: 1rem;
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font);
}

input[type="text"]:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}

button {
  padding: 0.65rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--clr-accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font);
  white-space: nowrap;
}

button:hover {
  background: var(--clr-accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hint {
  color: var(--clr-muted);
  font-size: 0.85rem;
  margin-top: 0.6rem;
}

.hint code {
  background: var(--clr-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ──────────── Error ──────────── */

.error {
  background: #fef2f2;
  color: var(--clr-error);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ──────────── Diagram grid ──────────── */

.diagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

.diagram-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}

.diagram-card:hover {
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
}

.diagram-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.diagram-card svg {
  width: 100%;
  height: auto;
}

/* ──────────── Section divider ──────────── */

.section-divider {
  border: none;
  border-top: 1px solid var(--clr-border);
  margin: 2.5rem 0;
}

/* ──────────── Upload section ──────────── */

.upload-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.upload-description {
  color: var(--clr-muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.drop-zone {
  border: 2px dashed var(--clr-border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover,
.drop-zone--over {
  border-color: var(--clr-accent);
  background: rgb(37 99 235 / 0.04);
}

.drop-zone-content {
  pointer-events: none;
}

.drop-zone-content p {
  pointer-events: auto;
}

.drop-zone-icon {
  width: 40px;
  height: 40px;
  color: var(--clr-muted);
  margin-bottom: 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--clr-accent);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-family: var(--font);
  text-decoration: underline;
  pointer-events: auto;
}

.link-btn:hover {
  color: var(--clr-accent-hover);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--clr-bg);
  border-radius: 6px;
  font-size: 0.9rem;
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.clear-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--clr-muted);
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.clear-btn:hover {
  color: var(--clr-error);
}

.upload-btn {
  margin-top: 1rem;
  width: 100%;
}

/* ──────────── Upload results ──────────── */

.upload-results {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow);
}

.upload-results h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.doc-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.doc-meta dt {
  font-weight: 600;
  color: var(--clr-muted);
}

.page-text {
  margin-bottom: 1rem;
}

.page-text h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--clr-muted);
  margin-bottom: 0.35rem;
}

.page-text pre {
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 400px;
  overflow-y: auto;
}

/* ──────────── Chord extraction info ──────────── */

.chord-extraction-info {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--clr-border);
}

.chord-extraction-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.extracted-chord-list {
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  word-break: break-word;
  margin-bottom: 0.75rem;
}

.use-chords-btn {
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
}

.chord-extraction-warning {
  color: var(--clr-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* ──────────── Unrecognized chords ──────────── */

.unrecognized-chords {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--clr-border);
}

.unrecognized-chords h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #b45309;
  margin-bottom: 0.35rem;
}

.unrecognized-chord-list {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  color: #92400e;
  word-break: break-word;
}

/* ──────────── Loading spinner ──────────── */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

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

/* ──────────── Responsive ──────────── */

@media (max-width: 480px) {
  .container { padding: 1.5rem 1rem 2rem; }
  header h1 { font-size: 1.5rem; }
  .input-row { flex-direction: column; }
  button { width: 100%; }
}
