:root {
  --bg: #14161c; --card: #1c1f27; --card2: #252935; --line: #2f3442;
  --text: #eef0f5; --muted: #9aa1b2; --accent: #ff7a59;
  --study: #ff7a59; --short: #3ecf8e; --long: #4ea8ff;
  --p0: #ff7eb6; --p1: #5cc8ff;
  --r: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
h1, h2 { margin: 0; }
h2 { font-size: 1rem; color: var(--muted); font-weight: 600; letter-spacing: .3px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: #ff8a80; min-height: 1.4em; }

input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #4a5164; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1b1410; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.big { padding: 12px 26px; font-size: 1.1rem; min-width: 140px; }
.btn.on { border-color: var(--short); color: var(--short); }
.btn.warn { border-color: #e5a50a; color: #ffcc4d; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 28px 24px; text-align: center; }
.logo { font-size: 48px; }
.login-card h1 { margin: 6px 0 18px; }
.login-card form { display: flex; gap: 8px; }
.login-card input { flex: 1; text-align: center; font-size: 1.3rem; letter-spacing: 6px; }

/* header */
.top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top h1 { font-size: 1.15rem; display: flex; align-items: center; gap: 6px; }
.yt-logo { display: none; width: 30px; height: 21px; }
.tabs { display: flex; gap: 8px; margin-right: auto; }
.tab { height: 32px; padding: 0 12px; border-radius: 8px; border: 0; background: rgba(255,255,255,.1); color: var(--text); font-weight: 500; font-size: .9rem; cursor: pointer; }
.tab:hover { background: rgba(255,255,255,.2); }
.tab[aria-selected="true"] { background: #f1f1f1; color: #0f0f0f; }
.presence { display: flex; gap: 8px; flex-wrap: wrap; }
.who { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); transition: box-shadow .12s; }
.who b { color: var(--c); font-weight: 600; }
.who small { color: var(--muted); }
.who .dot { width: 8px; height: 8px; border-radius: 50%; background: #555c6e; }
.who[data-status="active"] .dot { background: #3ecf8e; }
.who[data-status="idle"] .dot { background: #e5a50a; }
.who.speaking { box-shadow: 0 0 0 2px var(--c), 0 0 14px var(--c); }
.banner { background: #3a2f12; border-bottom: 1px solid #e5a50a; padding: 9px 16px; text-align: center; }

/* layout */
.grid { display: grid; gap: 14px; padding: 16px; max-width: 1150px; margin: 0 auto;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-areas: "timer tasks" "timer stats" "voice chat"; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.timer-card { grid-area: timer; text-align: center; --ph: var(--study); }
.voice-card { grid-area: voice; }
.tasks-card { grid-area: tasks; }
.stats-card { grid-area: stats; }
.chat-card { grid-area: chat; display: flex; flex-direction: column; }

/* timer */
.timer-card[data-phase="short"] { --ph: var(--short); }
.timer-card[data-phase="long"] { --ph: var(--long); }
.phase-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.phase-label { color: var(--ph); font-weight: 700; font-size: 1.1rem; }
.dots { display: flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ph); opacity: .5; }
.dots i.done { background: var(--ph); opacity: 1; }
.dots i.cur { opacity: 1; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { background: var(--ph); } }
.ring-wrap { position: relative; width: min(320px, 78vw); aspect-ratio: 1; margin: 14px auto 10px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--card2); }
.ring-fg { stroke: var(--ph); stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .3s; }
.paused .ring-fg { opacity: .55; }
.time-box { position: absolute; inset: 0; display: grid; place-content: center; }
.time { font-size: clamp(3rem, 13vw, 4.6rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.paused .time { opacity: .7; }
.next-up { color: var(--muted); font-size: .9rem; }
.controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.controls .btn.primary { background: var(--ph); border-color: var(--ph); }
.last-change { color: var(--muted); font-size: .85rem; min-height: 1.3em; margin-top: 10px; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--ph); } 30% { box-shadow: 0 0 0 8px var(--ph); } 100% { box-shadow: 0 0 0 0 transparent; } }

.settings { text-align: left; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.settings summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.presets { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.chip { background: var(--card2); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; cursor: pointer; }
.chip:hover { border-color: var(--ph); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.fields label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }
.fields input { width: 4.4em; text-align: center; color: var(--text); }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--muted); font-size: .9rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: .8rem; margin: 8px 0 0; }

/* tasks */
.tasks { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.tasks li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; }
.tasks li:hover { background: var(--card2); }
.tasks label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.tasks input { width: 18px; height: 18px; accent-color: var(--short); flex: none; }
.tasks .txt { overflow-wrap: anywhere; }
.tasks li.done .txt { text-decoration: line-through; color: var(--muted); }
.tasks small { font-size: .75rem; flex: none; }
.tasks .x { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 0 6px; }
.tasks .x:hover { color: #ff8a80; }
.tasks .empty { color: var(--muted); font-size: .9rem; }

/* stats */
.stats-today { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card2); border-radius: 12px; padding: 10px 12px; border-left: 3px solid var(--c); }
.stat b { color: var(--c); display: block; font-size: .9rem; }
.stat .big { font-size: 1.5rem; font-weight: 700; display: block; }
.stat small { color: var(--muted); font-size: .78rem; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; height: 110px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bars i { width: 40%; max-width: 14px; min-height: 2px; border-radius: 4px 4px 0 0; }
.day small { color: var(--muted); font-size: .7rem; }

/* chat */
.chat-log { flex: 1; min-height: 160px; max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.msg b { color: var(--c); font-size: .85rem; }
.msg time { color: var(--muted); font-size: .72rem; margin-left: 6px; }
.msg p { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000d; color: #fff; padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); z-index: 10; text-align: center; }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; grid-template-areas: "timer" "voice" "tasks" "chat" "stats"; padding: 12px 16px; }
  .fields { grid-template-columns: 1fr; }
  .top h1 { margin-right: auto; }
  .tabs { margin-right: 0; order: 3; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .dots i.cur, .flash { animation: none; } .ring-fg { transition: none; } }
