/* ============ RESONA — Apple-inspired theme ============ */
:root {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-2: #FAFAFC;
  --ink: #1D1D1F;
  --ink-2: #6E6E73;
  --hairline: rgba(0, 0, 0, 0.08);
  --accent: #5E5CE6;            /* Apple indigo */
  --accent-soft: rgba(94, 92, 230, 0.10);
  --good: #30A46C;
  --warn: #E5484D;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0E10;
    --surface: #1A1A1E;
    --surface-2: #232327;
    --ink: #F5F5F7;
    --ink-2: #98989F;
    --hairline: rgba(255, 255, 255, 0.10);
    --accent: #7D7AFF;
    --accent-soft: rgba(125, 122, 255, 0.14);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { -webkit-font-smoothing: antialiased; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: -0.011em;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--hairline);
  height: 56px; display: flex; align-items: center;
}
.brand { font-weight: 700; font-size: 19px; letter-spacing: 0.02em; color: var(--ink); text-decoration: none; }
.brand-dot { color: var(--accent); }
.mainnav { gap: 4px; margin-left: 12px; }
.mainnav a {
  color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 6px 12px; border-radius: 999px; transition: background .15s, color .15s;
}
.mainnav a:hover { color: var(--ink); background: var(--accent-soft); }
.mainnav a.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.iconbtn {
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  width: 34px; height: 34px; border-radius: 999px; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; cursor: pointer; transition: transform .12s, background .15s;
}
.iconbtn:hover { background: var(--accent-soft); transform: translateY(-1px); }
.pill { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; font-weight: 600; }
.pill-quiet { background: var(--surface); border: 1px solid var(--hairline); color: var(--ink-2); }

/* ---------- Layout ---------- */
.studio { padding: 28px 12px 60px; }
.card-soft {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.output-pane { min-height: 560px; position: relative; }

/* ---------- Segmented control ---------- */
.segmented {
  display: flex; background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 3px; gap: 2px;
}
.seg {
  flex: 1; border: 0; background: transparent; color: var(--ink-2);
  font-size: 13.5px; font-weight: 600; padding: 7px 6px; border-radius: 9px;
  cursor: pointer; transition: all .15s;
}
.seg.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.10); }

/* ---------- Inputs ---------- */
.field-label { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; display: block; }
.hint { font-size: 12px; color: var(--ink-2); }
.bigtext {
  width: 100%; border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); padding: 13px 15px;
  font-size: 14.5px; line-height: 1.55; resize: vertical; transition: border-color .15s, box-shadow .15s;
}
.bigtext:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select-soft {
  width: 100%; border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--surface-2); color: var(--ink); padding: 8px 11px; font-size: 13.5px;
}
.select-soft:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Modifier chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--hairline); background: var(--surface-2); color: var(--ink);
  border-radius: 999px; padding: 6px 13px 6px 9px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .13s; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-ic { font-size: 13px; }

/* ---------- 16-type grid ---------- */
.typegrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.typebtn {
  border: 1px solid var(--hairline); background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px 6px 8px; cursor: pointer; text-align: center; transition: all .13s;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.typebtn:hover { border-color: var(--accent); transform: translateY(-1px); }
.typebtn.on { background: var(--accent); border-color: var(--accent); }
.typebtn.on .t-code, .typebtn.on .t-label, .typebtn.on .t-pop { color: #fff; }
.t-code { font-weight: 700; font-size: 13.5px; letter-spacing: 0.04em; color: var(--ink); }
.t-label { font-size: 10.5px; color: var(--ink-2); line-height: 1.2; }
.t-pop { font-size: 9.5px; color: var(--ink-2); opacity: .75; }

/* ---------- Primary button ---------- */
.btn-primary-soft {
  width: 100%; border: 0; background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600; padding: 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: transform .12s, filter .15s, opacity .15s;
}
.btn-primary-soft:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn-primary-soft:disabled { opacity: .55; cursor: default; transform: none; }
.btn-ghost {
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  transition: all .13s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Empty / loading ---------- */
.hidden-block { display: none !important; }
.empty-state { text-align: center; padding: 90px 40px; }
.empty-mark { font-size: 40px; color: var(--accent); margin-bottom: 16px; }
.empty-state h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 10px; }
.empty-state p { color: var(--ink-2); font-size: 14px; max-width: 460px; margin: 0 auto; line-height: 1.6; }
.loading-state { text-align: center; padding: 110px 40px; }
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; margin: 0 auto 18px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--ink-2); font-size: 14px; font-weight: 500; }

.error-note {
  margin-top: 12px; background: rgba(229, 72, 77, .08); border: 1px solid rgba(229, 72, 77, .25);
  color: var(--warn); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px;
}

/* ---------- Analysis view ---------- */
.an-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.an-topic { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; text-transform: capitalize; }
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
.tag { background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.tag.quiet { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--hairline); }
.fitlist { display: flex; flex-direction: column; gap: 10px; }
.fitcard {
  border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 14px 16px;
  background: var(--surface-2); display: flex; gap: 14px; align-items: center; transition: border-color .15s;
}
.fitcard:hover { border-color: var(--accent); }
.fit-score {
  min-width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--accent); background: var(--accent-soft);
}
.fit-main { flex: 1; }
.fit-code { font-weight: 700; font-size: 15px; }
.fit-label { color: var(--ink-2); font-size: 12.5px; margin-left: 6px; }
.fit-why { font-size: 13px; color: var(--ink-2); margin-top: 3px; line-height: 1.45; }

/* ---------- Result view: beat timeline (signature element) ---------- */
.res-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.res-target { font-size: 17px; font-weight: 700; }
.qc-badge { font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 999px; }
.qc-pass { background: rgba(48,164,108,.12); color: var(--good); }
.qc-warn { background: rgba(229,72,77,.10); color: var(--warn); }

.timeline { position: relative; padding-left: 26px; margin-top: 6px; }
.timeline::before {
  content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px;
  background: linear-gradient(var(--accent), var(--accent-soft));
  border-radius: 2px;
}
.beat { position: relative; padding: 0 0 22px 8px; }
.beat::before {
  content: ""; position: absolute; left: -23px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.beat-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 5px; flex-wrap: wrap; }
.beat-t { font-family: var(--mono); font-size: 11.5px; color: var(--accent); font-weight: 700; }
.beat-role { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 6px; padding: 2px 7px; }
.beat-line { font-size: 15px; line-height: 1.55; }
.beat-line .pausemark { color: var(--accent); font-family: var(--mono); font-size: 12px; font-weight: 600; }
.beat-delivery { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.beat-delivery b { color: var(--ink); font-weight: 600; }

.subcard { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 10px; }
.subcard h5 { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.subcard p, .subcard li { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.hookcard { border-left: 3px solid var(--accent); }
.hook-text { font-size: 14.5px; font-weight: 600; color: var(--ink); line-height: 1.5; }
.hook-why { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.copybar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* rating */
.stars { display: inline-flex; gap: 4px; }
.star { font-size: 20px; color: var(--hairline); cursor: pointer; background: none; border: 0; transition: color .1s, transform .1s; }
.star:hover { transform: scale(1.15); }
.star.on { color: #F5A623; }

/* result inner tabs */
.res-tabs { margin: 4px 0 16px; }

/* ---------- Advisory view ---------- */
.adv-summary { font-size: 15px; line-height: 1.6; background: var(--accent-soft); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 16px; }
.lever { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 700; }

/* ---------- Settings sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.30); z-index: 90;
  backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 94vw); z-index: 100;
  background: var(--surface); border-left: 1px solid var(--hairline);
  box-shadow: -12px 0 40px rgba(0,0,0,.14);
  transform: translateX(105%); transition: transform .28s cubic-bezier(.32,.72,0,1);
  display: flex; flex-direction: column;
}
.sheet.open { transform: translateX(0); }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--hairline);
}
.sheet-head h3 { font-size: 17px; font-weight: 700; margin: 0; }
.sheet-body { padding: 20px 22px 40px; overflow-y: auto; }
.radio-cards { display: flex; flex-direction: column; gap: 8px; }
.radio-card {
  border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 12px 14px;
  cursor: pointer; display: flex; flex-direction: column; gap: 2px; transition: all .13s;
  background: var(--surface-2);
}
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { position: absolute; opacity: 0; }
.rc-title { font-size: 14px; font-weight: 600; }
.rc-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.divider { height: 1px; background: var(--hairline); margin: 22px 0; }

/* ---------- Guide & History pages ---------- */
.guide-layout { display: grid; grid-template-columns: 230px 1fr; gap: 24px; }
.guide-side { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 4px; }
.gside-btn {
  text-align: left; border: 0; background: transparent; color: var(--ink-2);
  padding: 8px 13px; border-radius: 10px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: all .13s;
}
.gside-btn:hover { background: var(--accent-soft); color: var(--ink); }
.gside-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.g-section { margin-bottom: 16px; }
.g-section h6 { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-2); margin-bottom: 7px; }
.g-hero { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.g-code { font-size: 32px; font-weight: 800; letter-spacing: 0.02em; }
.g-label { font-size: 16px; color: var(--ink-2); font-weight: 600; }
.facetbars { display: flex; flex-direction: column; gap: 7px; }
.facetbar { display: grid; grid-template-columns: 190px 1fr 38px; gap: 10px; align-items: center; }
.fb-name { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.fb-track { height: 6px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 999px; overflow: hidden; }
.fb-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.fb-val { font-family: var(--mono); font-size: 11px; color: var(--ink); text-align: right; }

.table-soft { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-soft th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); font-weight: 700; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--hairline); }
.table-soft td { padding: 11px 12px; border-bottom: 1px solid var(--hairline); }
.table-soft tr:hover td { background: var(--accent-soft); cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card .brand { font-size: 26px; }

@media (max-width: 991px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-side { position: static; flex-direction: row; flex-wrap: wrap; }
  .typegrid { grid-template-columns: repeat(4, 1fr); }
  .facetbar { grid-template-columns: 130px 1fr 34px; }
}
