/* Study Hub 0.1 – calm, card-based, one accent per semester (Q1 blue, Q2 green). */
:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #1f2430; --muted: #6b7280; --line: #e5e7eb; --line2: #d1d5db;
  --accent: #2563eb; --accent-soft: #e0e9ff; --ok: #16a34a; --ok-soft: #dcfce7; --warn: #d97706; --warn-soft: #fef3c7;
  --crit: #dc2626; --crit-soft: #fee2e2; --info: #0891b2; --info-soft: #cffafe; --shadow: 0 1px 2px rgba(0,0,0,.05);
  --radius: 12px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
html[data-term="Q2"] { --accent: #059669; --accent-soft: #d1fae5; }
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] { --bg: #111318; --card: #1a1d24; --text: #e6e8ee; --muted: #9aa3b2; --line: #2a2f3a; --line2: #3a4150;
    --accent-soft: #1e2a4a; --ok-soft: #123522; --warn-soft: #3a2a0a; --crit-soft: #3d1414; --info-soft: #0f3540; --shadow: none; }
  html[data-theme="system"][data-term="Q2"] { --accent-soft: #10362a; }
}
html[data-theme="dark"] { --bg: #111318; --card: #1a1d24; --text: #e6e8ee; --muted: #9aa3b2; --line: #2a2f3a; --line2: #3a4150;
  --accent-soft: #1e2a4a; --ok-soft: #123522; --warn-soft: #3a2a0a; --crit-soft: #3d1414; --info-soft: #0f3540; --shadow: none; }
html[data-theme="dark"][data-term="Q2"] { --accent-soft: #10362a; }

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; font-weight: 650; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; font-weight: 650; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; font-weight: 650; }
p { margin: .4rem 0; }
small, .muted { color: var(--muted); }
.small { font-size: .85rem; }
code { background: var(--accent-soft); padding: .05rem .3rem; border-radius: 4px; font-size: .9em; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.tablewrap { overflow-x: auto; }

/* layout */
.topbar { display: flex; align-items: center; gap: 1.2rem; padding: .6rem 1.2rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand.big { font-size: 1.6rem; text-align: center; display: block; margin-bottom: 1.2rem; }
.mainnav { display: flex; gap: .2rem; flex: 1; }
.mainnav a, .topright a { padding: .35rem .7rem; border-radius: 8px; color: var(--text); }
.mainnav a.active, .topright a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mainnav a:hover, .topright a:hover { text-decoration: none; background: var(--accent-soft); }
.topright { display: flex; align-items: center; gap: .4rem; }
.semlabel { font-size: .85rem; color: var(--muted); margin-right: .4rem; }
.themetoggle { background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--text); padding: .2rem .5rem; }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: .35rem .5rem; }
.linkbtn:hover { color: var(--text); }
.inline { display: inline; }
.page { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1.2rem 5rem; }
.tabbar { display: none; }
.authpage { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.authwrap { width: 100%; max-width: 520px; }
.authwrap.wide { max-width: 860px; }

/* cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.cardlabel { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: .4rem; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.hero { font-size: 1.35rem; font-weight: 600; margin: 0 0 .2rem; }
.big { font-size: 1.8rem; font-weight: 700; }
.huge { font-size: 3.4rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; }

/* buttons & forms */
.btn { display: inline-block; padding: .5rem .95rem; border-radius: 9px; border: 1px solid var(--line2); background: var(--card); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { display: block; width: 100%; text-align: center; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line2); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; }
textarea { min-height: 6rem; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .5rem 0 .2rem; }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: .95rem; margin: .3rem 0; cursor: pointer; }
label.check input { width: auto; }
.field { margin-bottom: .6rem; }
.formrow { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.actions { display: flex; gap: .6rem; margin-top: .8rem; flex-wrap: wrap; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem; margin: .6rem 0; }
legend { color: var(--muted); font-size: .85rem; padding: 0 .3rem; }

/* flash */
.flash { padding: .6rem .9rem; border-radius: 9px; margin-bottom: .8rem; border: 1px solid var(--line); background: var(--card); }
.flash-ok { border-color: var(--ok); background: var(--ok-soft); }
.flash-error { border-color: var(--crit); background: var(--crit-soft); }
.flash-info { border-color: var(--info); background: var(--info-soft); }

/* badges & status */
.badge { display: inline-block; font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.badge.neutral { background: var(--line); color: var(--muted); }
.badge.ok, .st-ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .st-warn { background: var(--warn-soft); color: var(--warn); }
.badge.crit { background: var(--crit-soft); color: var(--crit); }
.badge.info, .st-info { background: var(--info-soft); color: var(--info); }
.st-muted { background: var(--line); color: var(--muted); }
.modtag { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .35rem; vertical-align: middle; background: var(--accent); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--line2); margin-right: .15rem; }
.dot.on { background: var(--accent); }
.light { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .4rem; }
.light.critical { background: var(--crit); }
.light.soon { background: var(--warn); }
.light.later { background: var(--ok); }
.light.pattern { background: var(--line2); }

/* progress */
.bar { height: .55rem; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.bar.thin { height: .35rem; }
.blocks { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; color: var(--accent); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; align-items: flex-start; }
.list li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: .82rem; color: var(--muted); }
.list li.done .grow { opacity: .55; text-decoration: line-through; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .4rem 0 .8rem; }
.chip { padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--line2); font-size: .85rem; color: var(--text); background: var(--card); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip:hover { text-decoration: none; background: var(--accent-soft); }
.chip.active:hover { background: var(--accent); }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.knob { display: inline-flex; gap: .15rem; }
.knob button { width: 1.05rem; height: 1.05rem; border-radius: 50%; border: 1px solid var(--line2); background: var(--card); cursor: pointer; padding: 0; }
.knob button.on { background: var(--accent); border-color: var(--accent); }
.flagbtn { border: 1px solid var(--line); background: var(--card); border-radius: 6px; cursor: pointer; padding: .1rem .4rem; font-size: .85rem; color: var(--muted); }
.flagbtn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.path { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; word-break: break-all; color: var(--muted); }
.copybtn { font-size: .75rem; }

/* week grid */
.weekgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.weekcell { border: 1px solid var(--line); border-radius: 9px; padding: .4rem .5rem; min-height: 4.5rem; background: var(--card); font-size: .8rem; }
.weekcell.now { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.weekcell.vacation { background: var(--line); opacity: .7; }
.weekcell .wk { font-weight: 700; color: var(--muted); font-size: .75rem; }
.weekcell .ev { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weekcell .ev.pattern { color: var(--muted); }

/* session */
.session { text-align: center; padding: 2rem 1rem; }
.session .timer { font-variant-numeric: tabular-nums; }
.session ol { text-align: left; max-width: 520px; margin: 1rem auto; padding-left: 1.4rem; }
.session .actions { justify-content: center; }

/* onboarding */
.steps { display: flex; gap: .3rem; margin-bottom: 1rem; }
.steps span { flex: 1; height: .35rem; border-radius: 999px; background: var(--line); }
.steps span.on { background: var(--accent); }
.variant { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; margin-bottom: .6rem; }
.variant.over { border-style: dashed; }
.variant h4 { margin: 0 0 .2rem; font-size: .95rem; }

/* misc */
.markdown ul, .markdown ol { padding-left: 1.3rem; margin: .3rem 0; }
.markdown p { margin: .3rem 0; }
.markdown table { font-size: .88rem; }
.empty { color: var(--muted); padding: 1rem; text-align: center; border: 1px dashed var(--line2); border-radius: 10px; }
.pill-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details summary { cursor: pointer; color: var(--accent); }
.tokenbox { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--accent-soft); padding: .6rem; border-radius: 8px; word-break: break-all; }
.admin-nav { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.admin-nav a { padding: .3rem .7rem; border-radius: 8px; border: 1px solid var(--line); color: var(--text); font-size: .9rem; }
.admin-nav a.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .8rem; }
.tile .n { font-size: 1.6rem; font-weight: 700; }
.tile .l { font-size: .8rem; color: var(--muted); }

@media (max-width: 800px) {
  .grid2, .grid3, .formrow { grid-template-columns: 1fr; }
  .mainnav { display: none; }
  .topbar { gap: .6rem; padding: .5rem .8rem; }
  .topright .semlabel { display: none; }
  .page { padding: .9rem .8rem 5rem; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); z-index: 10; }
  .tabbar a { flex: 1; text-align: center; padding: .7rem .2rem; font-size: .8rem; color: var(--muted); }
  .tabbar a.active { color: var(--accent); font-weight: 600; }
  .huge { font-size: 2.6rem; }
}
@media print { .topbar, .tabbar, .btn, .actions { display: none !important; } }
