:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f2f0eb;
  --text: #1c1b19;
  --muted: #6d685f;
  --border: #e7e3db;
  --accent: #5b55d6;
  --accent-soft: #ecebfd;
  --accent-text: #ffffff;
  --xp: #e8930c;
  --xp-soft: #fdf1dc;
  --good: #1f9d55;
  --good-soft: #e3f5ea;
  --warn: #c76a00;
  --warn-soft: #fff1de;
  --bad: #d23f3f;
  --bad-soft: #fde8e8;
  --shadow: 0 1px 2px rgba(28, 27, 25, .05), 0 4px 16px rgba(28, 27, 25, .05);
  --radius: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111113;
  --surface: #1a1a1e;
  --surface-2: #232328;
  --text: #ededf2;
  --muted: #9b9aa6;
  --border: #2d2d34;
  --accent: #8f8cff;
  --accent-soft: #26244a;
  --accent-text: #111113;
  --xp: #f5ac3c;
  --xp-soft: #3a2a10;
  --good: #46c47c;
  --good-soft: #15301f;
  --warn: #f0a24a;
  --warn-soft: #3a2810;
  --bad: #f07070;
  --bad-soft: #3a1717;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 620; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px 0; }
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 750; font-size: 16px; white-space: nowrap; }
.brand span { color: var(--accent); }
.level { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.level-pill {
  white-space: nowrap; font-size: 12px; font-weight: 650;
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 9px; border-radius: 999px;
}
.xpbar { flex: 1; min-width: 50px; max-width: 260px; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.xpbar > div { height: 100%; width: 100%; transform-origin: left; background: linear-gradient(90deg, var(--xp), #f7c55c); border-radius: 99px; transition: transform .6s cubic-bezier(.16, 1, .3, 1); }
.xp-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.streak { font-size: 13px; font-weight: 650; white-space: nowrap; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--text); width: 32px; height: 32px; border-radius: 10px; cursor: pointer; font-size: 15px; flex: none; }
.icon-btn:hover { background: var(--surface-2); }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-top: 8px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 8px 12px 10px; font: inherit; font-weight: 560; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .badge-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 700; }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 80px; }

/* Layout */
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.cols { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; } }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { flex: 1; }

/* Hero */
.hero { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.hero h1 { font-size: 24px; font-weight: 720; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; min-width: 88px; }
.stat b { display: block; font-size: 18px; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 560;
  padding: 6px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  transition: transform .08s, background .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: default; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.xp { background: var(--xp-soft); color: var(--xp); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

/* Apply today */
.pick { position: relative; overflow: hidden; }
.pick-company { font-size: 20px; font-weight: 720; }
.why { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; margin: 10px 0; }

/* Quests */
.quest { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.quest:first-of-type { border-top: none; padding-top: 2px; }
.check {
  flex: none; width: 24px; height: 24px; border-radius: 50%; margin-top: 1px;
  border: 2px solid var(--border); display: grid; place-items: center;
  font-size: 13px; color: transparent; transition: all .25s;
}
.quest.done .check { background: var(--good); border-color: var(--good); color: #fff; transform: scale(1.05); }
.quest.done .quest-title { color: var(--muted); }
.quest-body { flex: 1; min-width: 0; }
.quest-title { font-weight: 620; }
.quest-sub { font-size: 13px; color: var(--muted); }
.quest-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.quest-meta { display: flex; gap: 6px; align-items: center; flex: none; }

.dayprog { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.dayprog > div { height: 100%; width: 100%; transform-origin: left; background: var(--good); transition: transform .5s cubic-bezier(.16, 1, .3, 1); }

/* Lists */
.list-item { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: none; }
.list-item .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.quicklog { display: flex; flex-wrap: wrap; gap: 6px; }

/* Progress bars */
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 100%; transform-origin: left; background: var(--accent); transition: transform .5s cubic-bezier(.16, 1, .3, 1); }
.bar.good > div { background: var(--good); }
.bar.xp > div { background: var(--xp); }
.prog-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.prog-row:first-child { border-top: none; }
.prog-row .bar { grid-column: 1 / -1; }

/* Kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
.column { scroll-snap-align: start; background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.column.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.column-head { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: 13.5px; padding: 2px 4px 8px; }
.jobcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); }
.jobcard:hover { border-color: var(--accent); }
.jobcard .company { font-weight: 680; }
.jobcard .role { font-size: 13px; color: var(--muted); }
.jobcard .next { font-size: 12.5px; margin-top: 6px; display: flex; gap: 6px; align-items: baseline; }
.jobcard .moves { display: flex; gap: 4px; justify-content: flex-end; margin-top: 6px; }
@media (max-width: 560px) { .board { grid-auto-columns: 86%; } }

/* Rings */
.rings { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.ring { text-align: center; background: var(--surface-2); border-radius: 12px; padding: 12px 6px 10px; }
.ring svg { width: 72px; height: 72px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--border); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.ring.met .fill { stroke: var(--good); }
.ring-num { margin-top: -50px; height: 32px; font-weight: 720; font-size: 15px; }
.ring-label { margin-top: 14px; font-size: 12.5px; color: var(--muted); }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { text-align: center; padding: 8px 2px; border-radius: 10px; background: var(--surface-2); font-size: 12px; }
.day b { display: block; font-size: 16px; }
.day.active { background: var(--good-soft); color: var(--good); }
.day.rest { background: var(--accent-soft); color: var(--accent); }
.day.today { outline: 2px solid var(--accent); }

/* Badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.badge .emoji { font-size: 22px; }
.badge.locked { opacity: .45; }
.badge.locked .emoji { filter: grayscale(1); }
.badge b { display: block; font-size: 13px; }
.badge span { font-size: 11.5px; color: var(--muted); line-height: 1.3; display: block; }

/* Sub tabs */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg button { border: none; background: none; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 580; padding: 5px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tilecard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.tilecard p { margin: 0; font-size: 13.5px; color: var(--muted); }
.tilecard > .row:last-child { margin-top: auto; padding-top: 6px; }

.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; cursor: pointer; }
.check-row input { margin-top: 4px; accent-color: var(--good); width: 16px; height: 16px; }
.check-row.done span { color: var(--muted); text-decoration: line-through; }

/* People */
.warmth { color: var(--xp); letter-spacing: 1px; font-size: 12px; }
input[type="search"], .input, select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; width: 100%;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* Modal */
dialog {
  border: 1px solid var(--border); border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 10, 14, .45); backdrop-filter: blur(2px); }
.modal-body { padding: 18px; max-height: calc(100vh - 80px); overflow: auto; }
.modal-body h2 { margin-bottom: 12px; }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (max-width: 480px) { .fields-2 { grid-template-columns: 1fr; } }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.timer { font-size: 56px; font-weight: 720; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer.inwindow { color: var(--good); }
.timer.over { color: var(--warn); }

/* Toasts and confetti */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25); animation: toast-in .35s cubic-bezier(.16, 1, .3, 1);
  display: flex; gap: 10px; align-items: center; max-width: calc(100vw - 32px);
}
.toast .chip.xp { background: var(--xp); color: #1c1b19; }
.toast.big { font-size: 16px; padding: 14px 20px; background: linear-gradient(90deg, var(--accent), #b26cf0); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.95); } }
.confetti { position: fixed; top: -12px; width: 8px; height: 12px; border-radius: 2px; z-index: 99; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--rot)); opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } .toast { animation: none; } }

.banner { padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 560; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.hint { font-size: 12.5px; color: var(--muted); }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }

@media (max-width: 560px) {
  .xp-label { display: none; }
  .brand-row { gap: 8px; }
  main { padding: 14px 12px 60px; }
  .card { padding: 14px; }
  .hero h1 { font-size: 21px; }
}
@media (max-width: 380px) { .brand { display: none; } }
