:root {
  color-scheme: light;
  --canvas: #f5f4ef;
  --paper: #ffffff;
  --ink: #18211f;
  --muted: #68716e;
  --line: #d9ddd8;
  --soft: #edf0ea;
  --pine: #14635c;
  --pine-dark: #0e4a45;
  --coral: #d86048;
  --coral-dark: #b94a34;
  --gold: #e6b84e;
  --danger: #b33a32;
  --shadow: 0 14px 32px rgba(24, 33, 31, 0.09);
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select, input { font: inherit; }

button, a, select { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, select:focus-visible, .drop-zone:focus-within {
  outline: 3px solid rgba(230, 184, 78, 0.8);
  outline-offset: 3px;
}

h1, h2, h3, p { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  width: min(1180px, calc(100% - 36px));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
}

.brand img { width: 28px; height: 28px; }

.language-control select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 30px 0 10px;
  color: var(--ink);
  background: var(--paper);
  cursor: pointer;
}

.hero {
  min-height: 408px;
  display: flex;
  align-items: end;
  background-color: #111514;
  background-image: url("/static/hero-studio.png");
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 9999px rgba(10, 14, 13, 0.34);
}

.hero-inner {
  width: min(1180px, calc(100% - 36px));
  padding: 54px 0 58px;
  margin: 0 auto;
  color: #ffffff;
}

.hero-kicker, .section-kicker {
  margin-bottom: 10px;
  color: var(--coral);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-kicker { color: #f5cc71; }

h1 {
  width: min(670px, 100%);
  font-size: clamp(2.5rem, 5vw, 4.65rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-copy {
  width: min(570px, 100%);
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.05rem;
  line-height: 1.6;
}

.page-grid {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 30px;
  align-items: start;
}

.tool-area, .results { display: grid; gap: 18px; }

.notice {
  display: flex;
  align-items: start;
  gap: 10px;
  padding: 13px 14px;
  border-left: 4px solid var(--gold);
  background: #fff7df;
  color: #5d4a16;
  font-size: 0.92rem;
  line-height: 1.45;
}

.notice > span:first-child {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
}

.upload-panel, .status-panel, .error-box, .result-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.upload-panel { padding: 16px; box-shadow: var(--shadow); }

.drop-zone {
  min-height: 248px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px;
  border: 2px dashed #b8c4bd;
  border-radius: 6px;
  background: #fafbf8;
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--pine);
  background: #f0f7f4;
}

.drop-zone img { width: 48px; height: 48px; opacity: 0.88; }

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title { font-size: 1.22rem; font-weight: 800; }
.drop-meta, .limit { color: var(--muted); font-size: 0.92rem; }
.file-types { color: var(--pine); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; }

.upload-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 14px;
}

button, .download-actions a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--pine);
  border-radius: 6px;
  padding: 0 16px;
  background: var(--pine);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

button:hover, .download-actions a:hover { background: var(--pine-dark); border-color: var(--pine-dark); }
button:disabled { cursor: wait; opacity: 0.66; }

.status-panel, .error-box { padding: 14px; }
.status-row, .result-header, .block-title-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

.progress-track { height: 8px; margin-top: 12px; overflow: hidden; border-radius: 6px; background: #dce3dd; }
.progress-bar { width: 0; height: 100%; background: var(--coral); transition: width 260ms ease; }

.error-box { border-color: rgba(179, 58, 50, 0.32); background: #fff2ef; color: var(--danger); }

.result-header { align-items: flex-end; }
h2 { font-size: 1.55rem; line-height: 1.1; }
h3 { font-size: 1rem; }

.result-tools, .chord-tools, .download-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chord-tools button, .download-actions a { min-width: 44px; min-height: 36px; padding: 0 11px; }
.chord-tools button { background: var(--paper); border-color: var(--line); color: var(--ink); }
.chord-tools button:hover { background: var(--soft); border-color: #bfc7c1; }
.chord-tools button.is-active { border-color: var(--coral); background: var(--coral); color: #fff; }
.chord-tools button.is-active:hover { border-color: var(--coral-dark); background: var(--coral-dark); }
.download-actions a { background: #ffffff; border-color: var(--pine); color: var(--pine); }
.download-actions a:hover { background: var(--pine); color: #fff; }
.share-button { min-height: 36px; padding: 0 11px; background: var(--coral); border-color: var(--coral); }
.share-button:hover { background: var(--coral-dark); border-color: var(--coral-dark); }

.result-block { display: grid; gap: 12px; padding: 16px; }
.transpose-status { color: var(--muted); font-size: 0.88rem; text-align: right; }

.result-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 16px; }

pre {
  min-height: 168px;
  max-height: 440px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid #283431;
  border-radius: 6px;
  background: #19231f;
  color: #f4f7f3;
  font-family: "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
}

.score-block pre { min-height: 300px; font-size: 1rem; line-height: 1.68; }
.markdown-block pre { min-height: 240px; }

.side-rail { display: grid; gap: 28px; }

.ad-slot {
  min-height: 250px;
  display: grid;
  place-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: #9aa29c;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-note { border-top: 3px solid var(--coral); padding-top: 14px; }
.rail-note p:last-child { color: var(--muted); font-size: 0.94rem; line-height: 1.6; }

.site-footer {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 20px 0 28px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer span:first-child { color: var(--ink); font-weight: 800; }
.footer-meta { display: flex; align-items: center; gap: 16px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 12px; }
.footer-links a, .back-link { color: var(--pine); text-underline-offset: 3px; }
.footer-links a:hover, .back-link:hover { color: var(--coral-dark); }

.legal-main { width: min(760px, calc(100% - 36px)); margin: 0 auto; padding: 56px 0 72px; }
.back-link { display: inline-block; margin-bottom: 34px; font-weight: 800; }
.legal-content { border-top: 3px solid var(--coral); padding-top: 16px; }
.legal-content h1 { color: var(--ink); font-size: 2.65rem; }
.legal-content h2 { margin-top: 30px; color: var(--pine); font-size: 1.15rem; }
.legal-content p { max-width: 68ch; color: var(--muted); line-height: 1.7; }
.legal-content .legal-intro { margin-top: 18px; color: var(--ink); font-size: 1.08rem; }

.admin-main { width: min(1120px, calc(100% - 36px)); margin: 0 auto; padding: 56px 0 72px; }
.admin-login { max-width: 540px; border-top: 3px solid var(--coral); padding-top: 16px; }
.admin-login h1, .admin-heading h1 { margin: 0; color: var(--ink); font-size: 2.3rem; }
.admin-login > p:not(.section-kicker), .admin-heading p { color: var(--muted); line-height: 1.6; }
.admin-login-form { display: grid; gap: 9px; margin-top: 24px; }
.admin-login-form label, .admin-controls label { color: var(--ink); font-size: 0.88rem; font-weight: 800; }
.admin-login-form input, .admin-controls select, .language-control select { min-height: 42px; border: 1px solid var(--line); border-radius: 6px; background: #ffffff; color: var(--ink); padding: 0 11px; font: inherit; }
.admin-login-form button { justify-self: start; margin-top: 5px; }
.admin-error { margin-top: 14px; color: var(--danger); font-weight: 700; }
.admin-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; }
.admin-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-controls select { min-width: 112px; }
button.admin-secondary { background: var(--paper); border-color: var(--line); color: var(--ink); }
button.admin-secondary:hover { background: var(--soft); border-color: #bfc7c1; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 30px; }
.metric-card { min-height: 122px; display: grid; align-content: space-between; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: #ffffff; }
.metric-card span { color: var(--muted); font-size: 0.84rem; font-weight: 800; }
.metric-card strong { color: var(--pine); font-size: 2rem; line-height: 1; }
.analytics-table-section { margin-top: 34px; border-top: 1px solid var(--line); padding-top: 18px; }
.table-heading { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.table-heading h2 { margin: 0; }
.table-heading p { color: var(--muted); font-size: 0.84rem; }
.analytics-table-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; background: #ffffff; font-size: 0.9rem; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--soft); color: var(--ink); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:last-child td { border-bottom: 0; }
.empty-statistics { color: var(--muted); }
.hidden { display: none !important; }

.consent-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  width: min(430px, calc(100% - 36px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.consent-banner p { font-size: 0.9rem; line-height: 1.45; }
.consent-banner > div { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.consent-banner button { min-height: 36px; padding: 0 12px; }
.consent-banner .consent-secondary { background: var(--paper); border-color: var(--line); color: var(--ink); }
.consent-banner .consent-secondary:hover { background: var(--soft); border-color: #bfc7c1; }

@media (max-width: 860px) {
  .page-grid { grid-template-columns: 1fr; }
  .side-rail { grid-template-columns: 1fr 1fr; align-items: start; }
  .ad-slot { min-height: 110px; }
}

@media (max-width: 640px) {
  .site-header, .hero-inner, .page-grid, .site-footer { width: min(100% - 24px, 1180px); }
  .site-header { min-height: 60px; }
  .hero { min-height: 390px; background-position: 62% center; }
  .hero-inner { padding: 46px 0 44px; }
  h1 { font-size: 2.42rem; }
  .hero-copy { font-size: 1rem; }
  .page-grid { padding: 24px 0 40px; }
  .upload-footer, .result-header, .site-footer, .footer-meta { align-items: stretch; flex-direction: column; }
  .upload-footer button { width: 100%; }
  .result-tools { justify-content: space-between; }
  .result-grid, .side-rail { grid-template-columns: 1fr; }
  .side-rail { gap: 22px; }
  .ad-slot { min-height: 84px; }
  .block-title-row { align-items: flex-start; flex-direction: column; }
  .transpose-status { text-align: left; }
  .legal-main { width: min(100% - 24px, 760px); padding: 32px 0 48px; }
  .legal-content h1 { font-size: 2.2rem; }
  .admin-main { width: min(100% - 24px, 1120px); padding: 32px 0 48px; }
  .admin-heading { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card:last-child { grid-column: span 2; }
}
