/* Apostrophe· web app. Same palette as the site and the apps. */
:root {
  --ink: #1a1209; --paper: #f5f0e8; --paper2: #ede7d9; --paper3: #e3dccf;
  --accent: #c8360a; --amber: #b8680a; --muted: #7a6a55; --success: #2a7a4b;
  --card: #fff; --serif: Georgia, 'PT Serif', serif;
  --bg: #f3eee5; --line: rgba(26, 18, 9, .07);
  --accent-soft: #f8e4d9; --success-soft: #e2efe6; --amber-soft: #f6ead6;
  --shadow: 0 1px 2px rgba(26, 18, 9, .04), 0 10px 30px rgba(26, 18, 9, .05);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--paper); color: var(--ink); line-height: 1.6; min-height: 100vh;
}
a { color: var(--amber); }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }

.top { display: flex; align-items: center; justify-content: space-between; max-width: 760px; margin: 0 auto; padding: 22px 20px 6px; }
.brand { font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand b { color: var(--accent); }
.nav { display: flex; gap: 16px; font-size: 14px; }
.nav button { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 4px 0; }

.wrap { max-width: 760px; margin: 0 auto; padding: 18px 20px 64px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
h1 { font-family: var(--serif); font-size: 30px; line-height: 1.25; margin-bottom: 10px; }
h2 { font-family: var(--serif); font-size: 21px; margin: 26px 0 10px; }
p + p { margin-top: 10px; }

.panel { background: var(--card); border-radius: 18px; padding: 26px; margin-top: 18px; }
.panel.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }

.btn { display: inline-block; border: none; border-radius: 12px; padding: 14px 24px; font-weight: 700; font-size: 16px; text-decoration: none; text-align: center; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--paper2); color: var(--ink); }
.btn.ghost { background: none; color: var(--muted); text-decoration: underline; font-weight: 500; padding: 8px 4px; }
.btn.block { display: block; width: 100%; }
.btn.apple { background: #000; color: #fff; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--paper3); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .btn { flex: 1; min-width: 180px; }

label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input[type=email], input[type=password], select {
  width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--paper3); background: #fff; color: var(--ink);
}
.msg { min-height: 22px; font-size: 14px; margin-top: 10px; }
.msg.error { color: var(--accent); }
.msg.ok { color: var(--success); }

/* Home */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0; }
.stat { background: var(--card); border-radius: 14px; padding: 14px 10px; text-align: center; }
.stat strong { display: block; font-family: var(--serif); font-size: 26px; color: var(--accent); }
.stat span { font-size: 13px; color: var(--muted); }
.level-line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; color: var(--muted); }
.cta { margin-top: 22px; }
.cta .sub { margin-top: 8px; font-size: 14px; color: var(--muted); text-align: center; }

/* Session */
.session-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; }
.close { background: none; border: none; font-size: 26px; line-height: 1; color: var(--muted); padding: 2px 6px; }
.player { display: flex; align-items: center; gap: 18px; margin: 20px 0 14px; flex-wrap: wrap; }
.play { width: 64px; height: 64px; border-radius: 50%; border: none; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.play svg { width: 26px; height: 26px; }
.speeds { display: flex; gap: 6px; }
.speeds button { border: 1px solid var(--paper3); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--ink); }
.speeds button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
details.hint { background: var(--paper2); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; }
details.hint summary { font-weight: 700; cursor: pointer; }
details.hint p { margin-top: 6px; color: var(--ink); }
textarea.answer {
  width: 100%; min-height: 120px; font-family: var(--serif); font-size: 21px; line-height: 1.6;
  padding: 16px 18px; border-radius: 14px; border: 1px solid var(--paper3); background: #fff; color: var(--ink); resize: vertical;
}
textarea.answer:focus, input:focus, select:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.accents { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.accents button { min-width: 38px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--paper3); background: #fff; font-family: var(--serif); font-size: 18px; color: var(--ink); }
.keyhint { font-size: 13px; color: var(--muted); margin: 6px 0 16px; }

/* Correction */
.result-head { display: flex; align-items: center; gap: 20px; }
.ring { width: 92px; height: 92px; flex-shrink: 0; position: relative; }
.ring svg { width: 92px; height: 92px; transform: rotate(-90deg); }
.ring span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 24px; font-weight: 700; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; }
.expected { font-family: var(--serif); font-size: 21px; line-height: 1.7; }
.expected .wrong { color: var(--accent); text-decoration: line-through; }
.expected .right { color: var(--success); font-weight: 700; }
.why { background: var(--paper2); border-radius: 12px; padding: 14px 16px; margin-top: 10px; }
.why .pair { font-family: var(--serif); font-size: 18px; margin-bottom: 4px; }
.why .pair .wrong { color: var(--accent); text-decoration: line-through; }
.why .pair .right { color: var(--success); font-weight: 700; }
.encourage { margin-top: 18px; color: var(--muted); }
.rate { display: flex; gap: 12px; margin-top: 24px; }
.rate button { flex: 1; border: none; border-radius: 14px; padding: 14px 10px; font-weight: 700; font-size: 16px; }
.rate button small { display: block; font-weight: 500; font-size: 13px; opacity: .8; margin-top: 2px; }
.rate .rework { background: var(--paper2); color: var(--ink); }
.rate .master { background: var(--success); color: #fff; }

/* Progress */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bar { width: 100%; max-width: 46px; background: var(--ink); border-radius: 5px 5px 0 0; }
.bar.empty { background: var(--paper3); }
.bar-value { font-size: 13px; font-weight: 700; min-height: 18px; }
.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Per rule */
.family { margin-top: 20px; }
.family-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.rule-tile { background: var(--paper2); border-radius: 12px; padding: 10px 12px; min-height: 104px; display: flex; flex-direction: column; }
.rule-top { display: flex; justify-content: space-between; align-items: flex-start; }
.rule-num { font-size: 13px; font-weight: 700; color: var(--muted); }
.mini-ring { width: 30px; height: 30px; position: relative; }
.mini-ring svg { width: 30px; height: 30px; }
.mini-ring span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; }
.rule-name { font-size: 13px; font-weight: 600; line-height: 1.3; margin-top: auto; }
.rule-count { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Setup and account */
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choices button { border: 1px solid var(--paper3); background: #fff; border-radius: 12px; padding: 12px 8px; color: var(--ink); }
.choices button.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 700; }
.choices.four { grid-template-columns: repeat(4, 1fr); }
.note { background: var(--paper2); border-radius: 12px; padding: 14px 16px; font-size: 15px; }

@media (max-width: 640px) {
  .top { padding: 16px 16px 4px; }
  .wrap { padding: 12px 16px 48px; }
  h1 { font-size: 25px; }
  .panel { padding: 20px 16px; }
  .choices, .choices.four { grid-template-columns: repeat(2, 1fr); }
  .rate { flex-direction: column; }
  textarea.answer { font-size: 19px; }
  .bars { gap: 4px; }
  .bar-label { font-size: 10px; }
}

/* ---------- Dashboard (side bar, cards) ---------- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; }
body.dash { background: var(--bg); }
body.dash .wrap { max-width: 1180px; padding: 32px 32px 64px; }

.side { position: sticky; top: 0; height: 100vh; width: 92px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; padding: 22px 0; }
.side[hidden], .top[hidden] { display: none; }
.side-logo img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.side-nav { margin-top: 34px; display: flex; flex-direction: column; gap: 10px; background: var(--card); border-radius: 999px; padding: 10px 8px; box-shadow: var(--shadow); }
.side-item { width: 52px; height: 52px; border-radius: 50%; border: none; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; position: relative; }
.side-item span { position: absolute; left: 62px; background: var(--ink); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; }
.side-item:hover span, .side-item:focus-visible span { opacity: 1; }
.side-item:hover { color: var(--ink); background: var(--paper2); }
.side-item.on { background: var(--ink); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.avatar { width: 84px; height: 84px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--serif); font-weight: 700; font-size: 34px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.avatar.small { width: 40px; height: 40px; font-size: 17px; margin: 0; }

.dash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 26px; }
body.dash h1 { font-family: inherit; font-size: 30px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; }
body.dash h2 { font-family: inherit; font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; box-shadow: var(--shadow); }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.grid + .grid { margin-top: 20px; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.card { background: var(--card); border-radius: 22px; padding: 24px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.empty-card { text-align: center; padding: 40px 24px; }

.tile { background: var(--card); border: none; border-radius: 22px; padding: 20px 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; text-align: left; color: var(--ink); min-width: 0; }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; min-height: 40px; }
.tile-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--paper2); color: var(--ink); display: flex; align-items: center; justify-content: center; }
.tile-label { font-size: 14px; color: var(--muted); }
.tile-value { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.tile-sub { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.tile-cta { background: linear-gradient(135deg, #c8360a 0%, #d9622f 100%); color: #fff; cursor: pointer; justify-content: space-between; }
.tile-cta .tile-label, .tile-cta .tile-sub { color: rgba(255, 255, 255, .85); }
.tile-cta-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 6px; }
.tile-cta-main strong { font-size: 22px; line-height: 1.25; }
.tile-cta .round { width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tile-cta:hover:not(:disabled) .round { background: rgba(255, 255, 255, .32); }
.tile-cta:disabled { opacity: .9; }

.marks { display: flex; gap: 4px; align-items: center; padding-top: 6px; }
.mark { width: 9px; height: 9px; border-radius: 50%; background: var(--paper3); }
.mark.on { background: var(--accent); }
.minibars { display: flex; gap: 4px; align-items: flex-end; height: 36px; }
.minibars span { width: 6px; border-radius: 3px; background: var(--paper3); }
.minibars span.on { background: var(--ink); }

.pill { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.up { background: var(--success-soft); color: var(--success); }
.pill.flat { background: var(--amber-soft); color: var(--amber); }
.pill.down { background: var(--accent-soft); color: var(--accent); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0 8px; }
.kpi { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi strong { font-size: 24px; font-weight: 700; }
.kpi em { font-style: normal; font-size: 12.5px; font-weight: 700; }
.kpi em.up { color: var(--success); }
.kpi em.down { color: var(--accent); }

.line-chart { width: 100%; height: auto; display: block; margin: 6px 0; }
.line-chart .gridline { stroke: var(--line); stroke-width: 1; }
.line-chart .axis { font-size: 11px; fill: var(--muted); }
.line-chart .line { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; }
.line-chart .dot { fill: #fff; stroke: var(--accent); stroke-width: 3; }

.gauge-wrap { position: relative; max-width: 220px; margin: 14px auto 6px; }
.gauge { width: 100%; display: block; }
.gauge-bg, .gauge-fg { fill: none; stroke-width: 18; stroke-linecap: round; }
.gauge-bg { stroke: var(--paper2); }
.gauge-wrap strong { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 30px; font-weight: 700; }

.profile { text-align: center; display: flex; flex-direction: column; }
.profile > p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 18px 0; }
.profile-stats span { display: block; font-size: 12px; color: var(--muted); }
.profile-stats strong { font-size: 16px; }
.profile .btn { margin-top: auto; }

.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 12px 14px; border-left: 3px solid var(--accent); margin-top: 12px; }
.list-item strong { display: block; font-size: 15px; }

.rules-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.big-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.rules-card .btn { margin-top: 10px; }

.bar.now { background: var(--accent); }
.card .bars { gap: 6px; }
.card .bar-col { min-width: 0; }
.card .bar-label { font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: clip; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-4 { grid-column: span 2; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; width: auto; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: center; background: var(--card); box-shadow: 0 -4px 20px rgba(26, 18, 9, .08); z-index: 20; }
  .side-logo, .side-foot .avatar { display: none; }
  .side-nav { margin: 0; flex-direction: row; box-shadow: none; padding: 0; background: none; }
  .side-foot { margin: 0 0 0 10px; flex-direction: row; }
  .side-item span { display: none; }
  body.dash .wrap { padding: 20px 16px 110px; }
  .dash-head { flex-direction: column; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .span-2, .span-4 { grid-column: span 1; }
  body.dash h1 { font-size: 25px; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
