@font-face { font-family: Peyda; src: url(/fonts/PeydaWebFaNum-Light.woff2) format('woff2'); font-weight: 300; font-display: swap; }
@font-face { font-family: Peyda; src: url(/fonts/PeydaWebFaNum-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Peyda; src: url(/fonts/PeydaWebFaNum-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Peyda; src: url(/fonts/PeydaWebFaNum-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #000;
  --fg: #fff;
  --muted: #9a9a9a;   /* 7.4:1 on black */
  --line: #2a2a2a;
  --soft: #141414;
  --r: 14px;
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: Peyda, system-ui, sans-serif;
  background: var(--bg); color: var(--fg);
  font-size: 16px; line-height: 1.6;
  height: 100dvh; overflow: hidden; /* one screen: lists scroll inside their own panel */
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.view, .app {
  max-width: 480px; margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
}
.app { height: 100dvh; display: flex; flex-direction: column; }
.timer, .people, .chat { min-height: 0; }
/* Thin scrollbars with reserved space, so RTL bars on the left never cover bubbles or cards */
.chat-list, .people-list { scrollbar-width: thin; scrollbar-color: var(--line) transparent; scrollbar-gutter: stable; }

/* Login */
.login { display: flex; flex-direction: column; justify-content: center; height: 100dvh; overflow-y: auto; padding-bottom: 48px; }
.brand { font-size: 56px; font-weight: 700; line-height: 1.1; letter-spacing: -1px; }
.lede { color: var(--muted); margin: 8px 0 40px; }
form { display: grid; gap: 8px; }
label { font-size: 14px; color: var(--muted); }
input {
  height: 52px; padding: 0 16px; margin-bottom: 12px;
  background: var(--soft); border: 1px solid var(--line); border-radius: var(--r);
}
input:focus { border-color: var(--fg); outline: none; }
.hint { font-size: 14px; color: var(--muted); }
.error { color: var(--fg); font-weight: 500; min-height: 1.6em; font-size: 14px; }
.error:not(:empty)::before { content: '× '; }
.btn-primary {
  height: 52px; border-radius: var(--r);
  background: var(--fg); color: var(--bg); font-weight: 700;
  transition: opacity .15s;
}
.btn-primary:active { opacity: .8; }
.btn-primary:disabled { opacity: .5; }

/* Timer */
.timer { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.modes {
  display: grid; grid-template-columns: repeat(3, 1fr); width: 100%;
  border: 1px solid var(--line); border-radius: var(--r); padding: 4px;
}
.modes button {
  min-height: 44px; border-radius: 10px; color: var(--muted); font-size: 14px;
  transition: background .2s, color .2s;
}
.modes button[aria-selected="true"] { background: var(--fg); color: var(--bg); font-weight: 500; }

/* The dial takes whatever height is left, so the timer always fits one screen */
.dial-wrap { flex: 1; min-height: 120px; width: 100%; display: grid; place-items: center; container-type: size; }
.dial { position: relative; width: min(100cqw, 100cqh, 320px); aspect-ratio: 1; container-type: inline-size; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial circle { fill: none; stroke-width: 2; }
.track { stroke: var(--line); }
.bar { stroke: var(--fg); stroke-linecap: round; transition: stroke-dashoffset .3s linear; }
.dial-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.clock { font-size: 26cqi; font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.phase { color: var(--muted); margin-top: 4px; font-size: max(13px, 5cqi); }

.task { width: 100%; }
.task input { width: 100%; margin: 0; text-align: center; }

.controls { display: flex; align-items: center; gap: 32px; }
.controls svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.controls .fill { fill: currentColor; stroke: none; }
.btn-round {
  width: 72px; height: 72px; border-radius: 50%;
  border: 1.5px solid var(--fg); display: grid; place-items: center;
  transition: background .2s, color .2s, transform .1s;
}
.btn-round svg { width: 30px; height: 30px; }
.btn-round:active { transform: scale(.96); }
.btn-round.on { background: var(--fg); color: var(--bg); }
.btn-ghost { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.btn-ghost:active { color: var(--fg); }
/* play/pause icons point the same way in RTL */
.controls svg { direction: ltr; }
#skip svg { transform: scaleX(-1); }
.count { color: var(--muted); font-size: 14px; }

/* Focus length picker: each length shows the chocolate it earns */
.lengths-wrap { width: 100%; }
.lengths { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.lengths button {
  min-height: 52px; border-radius: 12px; border: 1px solid var(--line); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 14px;
  transition: border-color .15s, color .15s;
}
.lengths button[aria-checked="true"] { border-color: var(--fg); color: var(--fg); font-weight: 500; }
.lengths button:disabled { opacity: .45; cursor: default; }
.length-hint { font-size: 13px; color: var(--muted); text-align: center; margin-top: 6px; }
.choc-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.reward { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.reward:empty { display: none; }
.reward .choc-icon { width: 28px; height: 28px; }
.chocs { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.chocs:empty { display: none; }
.chocs li { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.chocs .choc-icon { width: 20px; height: 20px; }

/* Confirm popup */
.confirm {
  margin: auto; width: min(360px, calc(100vw - 32px)); padding: 24px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--fg); border-radius: 20px;
}
.confirm::backdrop { background: rgb(0 0 0 / .7); }
.confirm h2 { font-size: 19px; font-weight: 700; margin-bottom: 8px; }
.confirm p { color: var(--muted); font-size: 15px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.confirm-actions button { min-height: 48px; padding: 0 12px; }
.btn-secondary { height: 52px; border-radius: var(--r); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--fg); }

/* Panel toggles: filled = panel shown */
.toolbar { display: flex; justify-content: flex-end; gap: 8px; }
.toggle {
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.toggle:hover { border-color: var(--fg); color: var(--fg); }
.toggle[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.unread {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--fg); color: var(--bg); font-size: 12px; line-height: 20px; text-align: center;
}

/* People */
.people h2, .chat h2 { font-size: 22px; font-weight: 700; margin-bottom: 16px; }
.totals { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 16px; }
.totals div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.totals div + div { border-top: 1px solid var(--line); }
.totals dt { font-size: 14px; color: var(--muted); }
.totals dd { margin: 0; font-size: 17px; font-weight: 500; white-space: nowrap; }
.people { display: flex; flex-direction: column; }
.people-list { list-style: none; padding: 0; display: grid; align-content: start; gap: 10px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.person {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 16px; border-radius: var(--r); border: 1px solid var(--line);
}
/* Running focus = inverted card; break = outlined; idle/offline = dimmed */
.person.focus { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.person.focus .meta, .person.focus .stats { color: #555; }
.person.break { border-color: var(--fg); }
.person.idle { color: var(--muted); }
.person .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .you { font-weight: 400; font-size: 13px; }
.person .time { font-size: 24px; font-weight: 300; font-variant-numeric: tabular-nums; grid-row: span 3; }
.person .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .stats { font-size: 13px; color: var(--muted); }
.person .chocs { grid-column: 1 / -1; margin-top: 8px; }
.empty { color: var(--muted); text-align: center; margin-top: 32px; }

/* Chat */
.chat { display: flex; flex-direction: column; }
.chat-list {
  list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px;
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
}
.msg { max-width: 85%; align-self: flex-end; padding: 8px 12px; border-radius: var(--r); border: 1px solid var(--line); }
.msg.mine { align-self: flex-start; background: var(--fg); color: var(--bg); border-color: var(--fg); }
.msg .from { display: block; font-size: 12px; color: var(--muted); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg time { display: block; font-size: 11px; color: var(--muted); text-align: end; }
.msg.mine time { color: #555; }
.msg.cont { margin-top: -2px; }
.msg { position: relative; }
.reacts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.react {
  height: 28px; padding: 0 8px; border-radius: 999px; font-size: 13px; line-height: 1;
  border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 4px;
}
.react[aria-pressed="true"] { border-color: currentColor; font-weight: 500; }
.msg.mine .react { border-color: #ccc; }
.msg.mine .react[aria-pressed="true"] { border-color: var(--bg); }
.react-add { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.msg.mine .react-add { color: #555; }
.react-add:hover { color: inherit; }
.react-add svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.react-picker {
  position: absolute; z-index: 5; top: 100%; margin-top: 4px; inset-inline-start: 0;
  display: flex; gap: 2px; padding: 4px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--fg); color: var(--fg);
}
.react-picker.up { top: auto; bottom: 100%; margin: 0 0 4px; }
.msg:not(.mine) .react-picker { inset-inline-start: auto; inset-inline-end: 0; }
.react-picker button { width: 40px; height: 40px; border-radius: 50%; font-size: 20px; }
.react-picker button:hover, .react-picker button:focus-visible { background: var(--soft); }
.chat-status { font-size: 13px; color: var(--muted); min-height: 0; }
.chat-status:empty { display: none; }
.chat .empty { margin: 16px 0; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form input { flex: 1; min-width: 0; margin: 0; }
.send {
  width: 52px; height: 52px; flex-shrink: 0; border-radius: var(--r);
  background: var(--fg); color: var(--bg); display: grid; place-items: center;
}
.send:disabled { opacity: .4; cursor: default; }
.send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Phone: one section at a time, switched by the bottom tabs */
@media (max-width: 1099px) {
  .app { padding-bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); }
  .app > .timer, .app > .people, .app > .chat { flex: 1; }
  .toolbar { display: none; }
  .app:not([data-tab="timer"]) .timer,
  .app:not([data-tab="people"]) .people,
  .app:not([data-tab="chat"]) .chat { display: none; }
  .tabs {
    position: fixed; inset: auto 0 0 0; z-index: 10;
    display: grid; grid-template-columns: repeat(3, 1fr);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .tabs[hidden] { display: none; }
  .tabs a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: 12px;
  }
  .tabs a[aria-current="page"] { color: var(--fg); }
  .tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  /* Physical left/right: the badge sits on the icon's top-right corner in both directions */
  .tab-badge { position: absolute; top: 4px; left: calc(50% + 4px); box-shadow: 0 0 0 3px var(--bg); }
}
/* Desktop: chat | timer | coworkers. A hidden panel leaves its column empty, so the timer stays centered. */
@media (min-width: 1100px) {
  .app {
    max-width: 1360px; padding: 24px 32px;
    display: grid; gap: 24px 40px; align-items: stretch;
    grid-template-columns: 320px minmax(0, 1fr) 320px; grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "bar bar bar" "chat timer people";
  }
  .toolbar { grid-area: bar; }
  .timer { grid-area: timer; width: 100%; max-width: 480px; justify-self: center; }
  .people { grid-area: people; border-inline-start: 1px solid var(--line); padding-inline-start: 32px; }
  .chat { grid-area: chat; border-inline-end: 1px solid var(--line); padding-inline-end: 32px; }
  .app.hide-chat .chat, .app.hide-people .people { display: none; }
  .tabs { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Room for the overlay scrollbar (left side in RTL) */
.chat-list, .people-list { padding-inline-end: 8px; }
