/* Personal projects design system — base stylesheet.
   Extracted from gymtracker (gymtracker/web/styles.css). Read design-system/DESIGN.md first.
   Copy this file into a new app as-is, then add app-specific styles in a separate file. */

:root {
  --bg: #08090a;
  --surface: #0e0f11;
  --surface-2: #16171a;
  --border: #1c1d20;
  --border-strong: #2b2c30;
  --text: #f7f8f8;
  --muted: #8a8f98;
  --faint: #5d6169;
  --invert: #f7f8f8;
  --invert-ink: #08090a;
  --up: #4cb782;
  --down: #eb5757;
  --warn: #d6a847;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, "Roboto Mono", monospace;
  --r: 4px;
  --tabbar: 58px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1px solid var(--muted); outline-offset: 1px; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); letter-spacing: 0; }
.k {
  font: 500 10.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 44px; padding: 0 16px; padding-top: env(safe-area-inset-top);
  background: rgba(8, 9, 10, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font: 500 13px var(--mono); letter-spacing: -0.02em; display: flex; gap: 8px; align-items: center; }
.brand-mark { width: 26px; height: 16px; color: var(--text); }
.status { font: 11px var(--mono); color: var(--faint); padding: 8px 0 8px 8px; }
.status:hover { color: var(--muted); }
.status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--up); vertical-align: 1px; }
.status[data-tone="busy"]::before { background: var(--warn); }
.status[data-tone="warn"]::before { background: var(--down); }

.login { max-width: 360px; margin: 8vh auto 0; display: grid; gap: 14px; text-align: center; }
.login img { margin: 0 auto; border-radius: 12px; }
.login h1 { font-size: 24px; }
.login p { margin: 0; font-size: 13px; }
.login-form { display: grid; gap: 10px; text-align: left; margin-top: 8px; }
.form-error { margin: 0; color: var(--down); font-size: 12.5px; }
.kv { display: grid; gap: 10px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.kv .btn { justify-self: start; margin-top: 4px; }
.kv p { margin: 0; font-size: 12.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { cursor: pointer; }
.nudge .btn { white-space: nowrap; }
.nudge { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px;
  padding: 10px 12px; border: 1px solid #4a4230; border-radius: var(--r); background: rgba(214, 168, 71, 0.06); font-size: 13px; }

main {
  max-width: 720px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar) + 40px + env(safe-area-inset-bottom));
  outline: none;
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(8, 9, 10, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: var(--faint);
}
.tab-ico { font-size: 15px; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--text); }

@media (min-width: 900px) {
  .tabs {
    top: 44px; right: auto; bottom: 0; width: 208px; height: auto;
    flex-direction: column; padding: 12px 8px; gap: 1px;
    border-top: 0; border-right: 1px solid var(--border); background: var(--bg);
  }
  .tabs a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 6px 10px; border-radius: var(--r); font-size: 13px; color: var(--muted); }
  .tabs a:hover { background: var(--surface-2); color: var(--text); }
  .tabs a[aria-current="page"] { background: var(--surface-2); }
  .tab-ico { font-size: 12px; width: 14px; text-align: center; color: var(--faint); }
  main { padding: 32px 40px 72px; margin-left: max(208px, calc(50vw - 360px)); }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r);
  font-size: 13px; font-weight: 500;
}
.btn:hover { border-color: #3a3b40; }
.btn.primary { background: var(--invert); border-color: var(--invert); color: var(--invert-ink); }
.btn.primary:hover { background: #fff; }
.btn.done { background: transparent; border-color: var(--border-strong); color: var(--up); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { min-height: 30px; padding: 0 8px; font-size: 12.5px; }
.btn.big { min-height: 44px; font-size: 14px; }
.btn.danger:hover { color: var(--down); }
.icon {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  background: none; border: 0; border-radius: var(--r); color: var(--faint); font-size: 14px;
}
.icon:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.icon:disabled { opacity: 0.3; cursor: default; }

input, select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--r);
  font-size: 16px; /* no zoom on focus */
}
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--muted); }
input:disabled { opacity: 0.4; }
select { appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="date"] { font-family: var(--mono); font-size: 13px; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.6); }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: calc(var(--r) + 1px); }
.seg button { min-height: 32px; padding: 0 12px; border: 0; border-radius: var(--r); background: none; color: var(--muted); font-size: 13px; font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.seg.small button { min-height: 26px; padding: 0 8px; font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 30px; padding: 0 10px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: none; color: var(--muted); font-size: 12.5px;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--surface-2); border-color: #45474d; color: var(--text); }
.chip-input { width: 130px; min-height: 30px; font-size: 12.5px; padding: 0 10px; }

.stepper { display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; height: 44px;
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--bg); overflow: hidden; }
.stepper:focus-within { border-color: var(--muted); }
.stepper button { border: 0; background: transparent; color: var(--faint); font-size: 17px; line-height: 1; padding: 0; }
.stepper button:hover { color: var(--text); }
.stepper button:active { background: var(--surface-2); color: var(--text); }
.stepper input { min-height: 0; height: 100%; border: 0; border-radius: 0; padding: 0 2px; text-align: center;
  font: 500 16px var(--mono); background: transparent; }

.panel { border-top: 1px solid var(--border); padding: 16px 0; }
.page-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 4px 0 14px; }
.page-h h1 { font-size: 22px; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.section-h h2 { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.section-h a, .section-h .mono { font-size: 12px; color: var(--muted); }
.empty { color: var(--faint); font-size: 13px; padding: 16px 0; }
.hint { color: var(--faint); font-size: 12px; margin: 8px 0 0; }
.back { display: inline-block; color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.back:hover { color: var(--text); }
.warn-text { color: var(--warn); }


/* ---------- hero ---------- */
.hero { padding: 8px 0 20px; }
.hero h1 { font-size: 36px; margin: 8px 0 2px; letter-spacing: -0.035em; font-weight: 600; }
.hero p { margin: 0; }

/* ---------- lists ---------- */
.row-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-bottom: 1px solid var(--border); }
.row {
  display: grid; grid-template-columns: 58px 40px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 6px; font-size: 13.5px; border-radius: var(--r);
}
.row:hover { background: var(--surface); }
.row .date { color: var(--muted); font: 12.5px var(--mono); }
.row .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.row-del { opacity: 0.55; }
.row-wrap:hover .row-del { opacity: 1; }
.month { margin: 22px 0 6px; }
.search { margin-bottom: 8px; }

/* ---------- stats + charts (pair with design-system/chart.js) ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 4px 0 16px; }
.stat { font: 500 20px/1.2 var(--mono); margin: 8px 0 2px; letter-spacing: -0.02em; }
.stat small { font-size: 12px; color: var(--muted); }
.stats .muted { font-size: 12px; font-family: var(--mono); overflow-wrap: anywhere; }
.chart-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.chart-wrap { touch-action: pan-y; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--faint); font: 11px var(--mono); }
.chart .line { fill: none; stroke: var(--text); stroke-width: 1.5; stroke-linejoin: round; }
.chart .dot { fill: var(--text); stroke: var(--bg); stroke-width: 2; }
.chart .dot.hollow { fill: var(--bg); stroke: var(--muted); stroke-width: 1.5; }
.chart .dot.active { r: 6; stroke: var(--text); fill: var(--bg); stroke-width: 2; }
.chart.compact { width: 100%; height: 48px; }
.chart.compact .line { stroke: var(--muted); stroke-width: 1.5; }
.readout { min-height: 20px; margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- cards + collapsible blocks ---------- */
.block { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); padding: 12px; margin: 8px 0; display: grid; gap: 8px; }
details.block { display: block; }
details.block > :not(summary) { margin-top: 8px; }
summary { list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: baseline; min-height: 22px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸"; color: var(--faint); font-size: 10px; transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(90deg); }
summary .muted { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards { display: grid; gap: 8px; }
.card { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); padding: 10px 10px 6px; }
.card-h { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.card-h h3 { font-size: 14.5px; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-h h3 a:hover { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.card-tools { margin-left: auto; display: flex; flex: none; }

/* ---------- feedback ---------- */
.nudge { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px;
  padding: 10px 12px; border: 1px solid #4a4230; border-radius: var(--r); background: rgba(214, 168, 71, 0.06); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 11.5px; color: var(--faint); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.up-text { color: var(--up); }
.same-text { color: var(--muted); }
.down-text { color: var(--down); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 8px 8px 8px 14px; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface-2);
  font-size: 13px; z-index: 20; max-width: calc(100vw - 32px); white-space: nowrap;
}
.toast[hidden] { display: none; }
.toast span { overflow: hidden; text-overflow: ellipsis; }
.toast:not(:has(button)) { padding-right: 14px; }
.toast-undo { border: 0; background: var(--invert); color: var(--invert-ink); border-radius: 3px; padding: 4px 10px; font-size: 12.5px; font-weight: 500; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; }
}
