:root {
  --bg: #FBFAF7;
  --card: #FFFFFF;
  --ink: #17161A;
  --ink-2: #5E5B66;
  --line: #E9E6E0;
  --accent: #C2410C;
  --accent-soft: #FCEEE6;
  --ok: #15803D;
  --ok-soft: #E8F5EC;
  --err: #B91C1C;
  --err-soft: #FDECEC;
  --radius: 16px;
  --font: 'Figtree', 'Hind Siliguri', system-ui, sans-serif;
  --bn: 'Hind Siliguri', 'Figtree', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
::selection { background: var(--accent); color: #fff; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h3 { font-size: 1.05rem; margin-bottom: 14px; }
.bn, .bn-big { font-family: var(--bn); font-weight: 500; }
.en + .bn { color: var(--ink-2); font-size: .88em; }
.bn-big { color: var(--accent); }
.muted { color: var(--ink-2); }
.small { font-size: .86rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); font-size: .92em; white-space: nowrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .74rem; color: var(--ink-2); margin: 0 0 8px; font-weight: 600; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(16px, 4vw, 48px); background: rgba(251,250,247,.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--ink); font-weight: 700; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); align-self: center; box-shadow: 0 0 0 4px var(--accent-soft); }
.brand-bn { font-family: var(--bn); color: var(--accent); font-weight: 600; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--ink); padding: 8px 14px; border-radius: 999px; font-weight: 500; font-size: .95rem; transition: background-color .2s; }
.nav a:hover { background: #F1EEE8; text-decoration: none; }
.nav a.active { background: var(--ink); color: #fff; }
.nav a.active .bn { color: #D9D6DE; }
.nav-user { color: var(--ink-2); font-size: .9rem; padding: 0 10px; border-left: 1px solid var(--line); margin-left: 6px; }
.nav-logout { color: var(--ink-2) !important; }
.menu-btn { display: none; background: none; border: 0; padding: 10px; cursor: pointer; }
.menu-btn span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 4px 0; border-radius: 2px; transition: transform .25s, opacity .25s; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: clamp(20px, 4vw, 48px) clamp(16px, 4vw, 48px) 64px; flex: 1; }
.foot { text-align: center; color: var(--ink-2); font-size: .82rem; padding: 24px 16px 32px; }

/* Elements */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 3vw, 28px); }
.block { margin-top: 36px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: .9rem; font-weight: 500; }
.field > span { color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%; min-height: 46px; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23,22,26,.08); }
select:disabled { background: #F5F3EF; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row .field { margin-bottom: 0; }
.grow { flex: 1 1 200px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 999px; padding: 11px 22px; min-height: 46px; cursor: pointer; transition: background-color .2s, transform .15s, border-color .2s; color: var(--ink); background: transparent; }
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn .bn { color: inherit; opacity: .8; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-stop { background: var(--accent); color: #fff; }
.btn-stop:hover { background: #9A3412; }
.btn-ghost { border-color: var(--line); background: #fff; }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 7px 14px; min-height: 38px; font-size: .88rem; }
.btn-lg { padding: 14px 40px; font-size: 1.05rem; min-width: 180px; }
.btn-block { width: 100%; margin-top: 6px; }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: .92rem; animation: rise .35s ease both; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-err { background: var(--err-soft); color: var(--err); }
.badge { display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: 3px 9px; border-radius: 999px; font-weight: 600; vertical-align: middle; }
.badge-pending { background: #FEF3C7; color: #92400E; }
.badge-active { background: var(--ok-soft); color: var(--ok); }
.badge-inactive { background: #EEECEA; color: var(--ink-2); }

/* Auth */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(24px, 6vw, 80px); align-items: center; min-height: 70vh; }
.auth-intro h1 { font-size: clamp(2.4rem, 7vw, 4.4rem); margin-bottom: 18px; }
.auth-intro p.muted { max-width: 420px; font-size: 1.05rem; }
.auth-card { max-width: 440px; width: 100%; justify-self: end; animation: rise .5s ease both; }
.auth-card h2 { font-size: 1.4rem; margin-bottom: 20px; }

/* Page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 32px; animation: rise .4s ease both; }
.section-title { display: flex; align-items: baseline; gap: 12px; font-size: 1.25rem; margin-bottom: 18px; flex-wrap: wrap; }
.section-title .num { font-family: var(--mono); font-size: .8rem; color: var(--accent); }

/* Dashboard */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: clamp(24px, 4vw, 48px); align-items: start; }
.dash-timer { position: sticky; top: 88px; animation: rise .5s .1s ease both; }
.dash-stats { animation: rise .5s ease both; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; transition: transform .2s, border-color .2s; }
.stat:hover { transform: translateY(-2px); border-color: #D6D2CA; }
.stat-label { font-size: .78rem; color: var(--ink-2); line-height: 1.3; min-height: 2.1em; }
.stat-value { font-size: 1.45rem; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.stat-value small { font-size: .55em; font-weight: 500; color: var(--ink-2); }
.goal { padding: 14px 0; border-bottom: 1px solid var(--line); }
.goal:last-child { border-bottom: 0; }
.goal-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .95rem; margin-bottom: 8px; }
.goal-name { font-weight: 600; }
.goal-nums { font-family: var(--mono); font-size: .85rem; }
.goal-pct { font-size: .78rem; color: var(--ink-2); margin-top: 6px; }
.bar { height: 8px; background: #F1EEE8; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width .8s ease; }
.bar span.done { background: var(--ok); }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 190px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 14px 12px; }
.col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.col-val { font-size: .66rem; color: var(--ink-2); height: 14px; white-space: nowrap; }
.col-track { flex: 1; width: 100%; max-width: 34px; display: flex; align-items: flex-end; background: #F7F5F1; border-radius: 8px; overflow: hidden; }
.col-track span { width: 100%; background: var(--accent); border-radius: 8px; min-height: 0; transition: height .8s ease; }
.col:last-child .col-track span { background: var(--ink); }
.col-lbl { font-size: .74rem; color: var(--ink-2); font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list:empty { display: none; }
.list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: .93rem; }
.list li:last-child { border-bottom: 0; }
.live { color: var(--accent); font-style: normal; font-weight: 600; }
.row-end { display: flex; align-items: center; gap: 10px; }

/* Timer */
.timer-card { text-align: center; }
.timer-card .field { text-align: left; }
.clock-wrap { width: min(100%, 280px); margin: 8px auto 0; aspect-ratio: 1; }
.clock { width: 100%; height: 100%; display: block; }
.clock-face { fill: #fff; stroke: var(--line); stroke-width: 1.5; }
.clock-ring-bg { fill: none; stroke: #F4F1EC; stroke-width: 4; }
.clock-ring { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset .4s linear; }
.tick { stroke: #CFCAC1; stroke-width: 1.2; stroke-linecap: round; }
.tick-major { stroke: var(--ink); stroke-width: 2.4; }
.hand { stroke-linecap: round; transition: transform .2s cubic-bezier(.4, 2.3, .6, 1); }
.hand-h { stroke: var(--ink); stroke-width: 5.5; }
.hand-m { stroke: var(--ink); stroke-width: 3.5; }
.hand-s { stroke: var(--accent); stroke-width: 1.6; }
.clock-pin { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.digital { font-size: clamp(2rem, 7vw, 2.6rem); letter-spacing: .04em; margin-top: 14px; font-weight: 500; }
.timer-status { color: var(--ink-2); font-size: .9rem; margin: 2px 0 20px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.is-running .timer-card { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timer-actions { display: flex; justify-content: center; }
.timer-msg { min-height: 1.4em; margin-top: 14px; font-size: .88rem; }
.timer-msg.err { color: var(--err); }
.timer-msg.ok { color: var(--ok); }

/* Goal form */
.narrow { max-width: 760px; }
.goal-sentence { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 1.15rem; font-weight: 600; margin-bottom: 22px; }
.hours-input { width: 110px; font-size: 1.3rem; font-weight: 700; text-align: center; font-family: var(--mono); }
.seg { display: inline-flex; background: #F1EEE8; border-radius: 999px; padding: 4px; flex-wrap: wrap; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: auto; min-height: 0; }
.seg span { display: inline-block; padding: 8px 14px; border-radius: 999px; font-size: .9rem; font-weight: 500; transition: background-color .2s, color .2s; }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:checked + span .bn { color: #D9D6DE; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

/* Admin */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.tabs a { white-space: nowrap; color: var(--ink); border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 999px; font-size: .9rem; }
.tabs a:hover { text-decoration: none; border-color: var(--ink); }
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a.active .bn { color: #D9D6DE; }
.tabs b { font-family: var(--mono); font-size: .8em; margin-left: 4px; opacity: .7; }
.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; animation: rise .35s ease both; }
.user-row.is-off { opacity: .6; }
.user-info { min-width: 0; }
.user-name { font-weight: 600; margin-bottom: 2px; }
.user-info .small { overflow-wrap: anywhere; }
.user-actions { display: flex; gap: 8px; flex-shrink: 0; }
.split { display: grid; grid-template-columns: 380px 1fr; gap: 28px; align-items: start; }
.picker { margin-bottom: 24px; padding: 16px 20px; }
.picker .field { margin: 0; }
.selected-user { margin-bottom: 20px; }
.selected-user h2 { font-size: 1.5rem; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .25; } }

/* Responsive */
@media (max-width: 1024px) {
  .dash { grid-template-columns: 1fr; }
  .section-title .num { display: none; }
  .dash-timer { position: static; order: -1; max-width: 520px; width: 100%; margin: 0 auto; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .nav { position: fixed; top: 61px; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 2px; padding: 12px 16px 20px; background: var(--bg); border-bottom: 1px solid var(--line); transform: translateY(-8px); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s, transform .2s, visibility .2s; }
  .nav-open .nav { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
  .nav a { padding: 12px 14px; border-radius: 12px; }
  .nav-user { border: 0; margin: 8px 0 0; padding: 8px 14px; }
  .nav-open .menu-btn span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-open .menu-btn span:nth-child(2) { opacity: 0; }
  .nav-open .menu-btn span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .auth { grid-template-columns: 1fr; min-height: 0; gap: 28px; }
  .auth-card { justify-self: stretch; max-width: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .user-row { flex-direction: column; align-items: stretch; }
  .user-actions { justify-content: flex-start; flex-wrap: wrap; }
  .chart { gap: 4px; padding: 14px 8px 10px; height: 170px; }
  .col-val { font-size: .58rem; }
  .goal-sentence { font-size: 1rem; }
  .seg { width: 100%; justify-content: space-between; }
  .seg label { flex: 1; text-align: center; }
  .seg span { width: 100%; padding: 8px 6px; font-size: .82rem; }
  .seg .bn { display: block; }
  .row .btn { width: 100%; }
  .btn-lg { width: 100%; }
  .list li { padding: 12px 14px; }
}
[hidden] { display: none !important; }
.dash > *, .split > *, .two > * { min-width: 0; }

/* Celebrations */
.celebrate { position: relative; overflow: hidden; margin-bottom: 16px; padding: 18px 20px; border-radius: var(--radius); background: #FFF7ED; border: 1px solid #FCD9B8; animation: rise .5s ease both; }
.celebrate-head { font-weight: 700; font-size: 1.05rem; margin-bottom: 12px; color: #9A3412; }
.celebrate-head .bn { color: #B45309; }
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge-card { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 10px 16px 10px 10px; font-size: .9rem; line-height: 1.3; }
.medal { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: #fff; background: var(--accent); box-shadow: 0 0 0 4px #FFEAD5; }
.medal svg { width: 22px; height: 22px; }
.badge-week .medal { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.badge-flame .medal { background: #E11D48; box-shadow: 0 0 0 4px #FFE4E6; }
.burst .medal { animation: pop .7s cubic-bezier(.3, 1.8, .5, 1) both; }
.confetti { position: absolute; top: -10px; width: 7px; height: 12px; border-radius: 2px; opacity: 0; animation: fall 1.8s ease-in forwards; pointer-events: none; }
@keyframes pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes fall { 0% { opacity: 1; translate: 0 0; } 100% { opacity: 0; translate: 0 180px; } }

/* Session notes */
.note-panel { text-align: left; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; animation: rise .35s ease both; }
.note-title { font-weight: 600; margin-bottom: 10px; }
.moods { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mood-btn { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; transition: background-color .2s, border-color .2s, color .2s; }
.mood-btn:hover { border-color: var(--ink); }
.mood-btn[aria-checked="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.mood-btn[aria-checked="true"] .bn { color: #D9D6DE; }
.note-panel textarea { resize: vertical; }
.note-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.sess-note { display: block; margin-top: 6px; font-size: .86rem; color: var(--ink); background: #F7F5F1; border-radius: 10px; padding: 8px 10px; overflow-wrap: anywhere; }
.mood-chip { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-right: 6px; background: #EEECEA; }
.mood-chip .bn { color: inherit; }
.mood-chip.mood-great { background: #FFEDD5; color: #9A3412; }
.mood-chip.mood-good { background: var(--ok-soft); color: var(--ok); }
.mood-chip.mood-tough { background: #FFE4E6; color: #BE123C; }
@media (max-width: 560px) { .badge-card { width: 100%; } .note-actions .btn { flex: 1; } .note-actions .bn { display: none; } }
