/* timetrack — mobile-first, dark by default, light when the phone asks for it. */

:root {
  --bg: #0e1015;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e7eaf0;
  --muted: #99a1b3;
  --accent: #5b8def;
  --accent-text: #ffffff;
  --danger: #e5484d;
  --good: #3dd68c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --border: #dde2ea;
    --text: #161a22;
    --muted: #5f6980;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  }
}

* { box-sizing: border-box; }

/* The UA rule for [hidden] is display:none, but any author `display:` below
   (.login, .row, .dot, .pill, .btn) outranks it and the element stays visible. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior-y: none;
}

h1 { font-size: 1.3rem; margin: 0 0 1rem; }
h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .75rem; }

.boot { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ---------- login ---------- */
.login { display: flex; min-height: 100svh; align-items: center; justify-content: center; padding: 1.25rem; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.75rem 1.5rem; box-shadow: var(--shadow); text-align: center;
}
.login-mark {
  width: 48px; height: 48px; margin: 0 auto 1rem; border-radius: 50%;
  border: 3px solid var(--accent); position: relative;
}
.login-mark::before, .login-mark::after {
  content: ""; position: absolute; left: 50%; bottom: 50%; background: var(--accent);
  border-radius: 2px; transform-origin: bottom center;
}
.login-mark::before { width: 3px; height: 14px; margin-left: -1.5px; transform: rotate(20deg); }
.login-mark::after  { width: 3px; height: 10px; margin-left: -1.5px; transform: rotate(-105deg); }
.login-card .field { text-align: left; }

/* ---------- chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1rem .6rem; max-width: 720px; margin: 0 auto;
}
.topbar-totals { display: flex; gap: 1.5rem; }
.topbar-totals div { display: flex; flex-direction: column; line-height: 1.15; }
.topbar-totals b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.topbar-totals span { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.tabs {
  display: flex; gap: .25rem; padding: 0 1rem .75rem; max-width: 720px; margin: 0 auto;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.tab {
  flex: 1; padding: .55rem .5rem; border: 1px solid transparent; border-radius: 10px;
  background: var(--surface-2); color: var(--muted); font: inherit; font-size: .9rem;
  font-weight: 600; cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--text); border-color: var(--border); }

.view { max-width: 720px; margin: 0 auto; padding: 0 1rem 5rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; margin-bottom: .85rem; box-shadow: var(--shadow);
}

/* ---------- timer ---------- */
.timer-card { text-align: center; padding: 1.6rem 1.1rem; }
.timer-project { display: flex; align-items: center; justify-content: center; gap: .5rem; color: var(--muted); font-weight: 600; }
.clock {
  font-size: clamp(2.8rem, 14vw, 4rem); font-weight: 300; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; margin: .35rem 0 .1rem;
}
.clock.is-running { color: var(--good); }
.timer-note { color: var(--muted); font-size: .92rem; min-height: 1.2rem; word-break: break-word; }
.pill {
  display: inline-block; margin-top: .5rem; padding: .15rem .6rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 600;
}
.timer-card .row { margin-top: 1.1rem; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: .85rem; }
.field > span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; font-weight: 600; }
.field-inline { display: flex; align-items: center; gap: .5rem; margin: 0; }
.field-inline > span { margin: 0; }

input[type="text"], input[type="password"], input[type="datetime-local"], select {
  width: 100%; padding: .65rem .7rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
}
input[type="color"] {
  width: 46px; height: 44px; padding: 2px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); flex: 0 0 auto;
}
select { appearance: none; background-image: none; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  padding: .7rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-block { display: flex; width: 100%; }
.btn-small { padding: .45rem .7rem; font-size: .85rem; }

.row { display: flex; gap: .5rem; align-items: center; }
.row > .btn { flex: 1; }
.row-between { justify-content: space-between; }
.row-between > .btn { flex: 0 0 auto; }

.hint { color: var(--muted); font-size: .78rem; margin: .6rem 0 0; text-align: center; }
.error { color: var(--danger); font-size: .85rem; margin: 0 0 .75rem; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-top: 1px solid var(--border);
  background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.list .item:first-child { border-top: 0; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-variant-numeric: tabular-nums; font-weight: 600; flex: 0 0 auto; }
.item-time.is-running { color: var(--good); }
.empty { color: var(--muted); font-size: .9rem; padding: .4rem 0; }

.day-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.day-head h2 { margin: 0; }
.day-total { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Three buttons plus a name do not fit on one phone line, so the actions wrap
   onto their own row rather than crushing the project name to an ellipsis. */
.proj-item { flex-wrap: wrap; cursor: default; }
.proj-actions { display: flex; gap: .35rem; flex: 1 0 100%; justify-content: flex-end; }
.is-archived .item-title { color: var(--muted); text-decoration: line-through; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 1.1rem; width: min(460px, calc(100vw - 2rem)); box-shadow: var(--shadow);
  margin: auto; /* keeps it centred on iOS Safari, which ignores the UA default */
}
dialog::backdrop { background: rgba(0,0,0,.55); }
/* Stacked by default: two datetime-local inputs do not fit side by side on a
   375px phone, and the second one gets clipped off the dialog. */
.seg-row { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .9rem; }
.seg-row .field { flex: 1; min-width: 0; margin: 0; }
.seg-row input[type="datetime-local"] { font-size: 16px; padding: .55rem; min-width: 0; }
.seg-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
@media (min-width: 480px) {
  .seg-row { flex-direction: row; align-items: flex-end; }
}
.editor-actions { margin-top: 1rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1.25rem + env(safe-area-inset-bottom));
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: .6rem 1rem; border-radius: 999px; box-shadow: var(--shadow); font-size: .88rem;
  z-index: 20; max-width: calc(100vw - 2rem); text-align: center;
}
.toast.is-error { border-color: var(--danger); color: var(--danger); }
