/* Personal OKRs — one stylesheet, mobile first.
   Layout rules: single column on a phone, comfortable multi-column grids from
   760px up, and a fixed bottom tab bar on small screens that becomes a normal
   tab strip on desktop. */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f7;
  --text: #14161f;
  --muted: #6b7280;
  --line: #e2e4ee;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --good: #0e9f6e;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px -16px rgba(16, 24, 40, 0.25);
  --header-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #141a2e;
    --surface-2: #1c2440;
    --text: #eef1fb;
    --muted: #98a2c0;
    --line: #26304f;
    --accent: #8b8cf9;
    --accent-soft: #1e2450;
    --good: #34d399;
    --warn: #fbbf24;
    --bad: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

@media (min-width: 760px) {
  body {
    padding-bottom: 32px;
  }
}

h1,
h2,
h3 {
  margin: 0 0 4px;
  line-height: 1.25;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 15px;
}

p {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 12px;
}

.boot {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 64px 0;
  color: var(--muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  margin: 0 -12px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}

.topbar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__title {
  font-size: 15px;
}

.logo {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
}

@media (max-width: 520px) {
  .topbar__title {
    display: none;
  }
  #sign-out {
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ------------------------------------------------------------------ tabs */

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs__btn {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}

.tabs__btn.is-active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.tabs__count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.tabs__short {
  display: none;
}

/* Phone: fixed bottom bar with short labels. */
@media (max-width: 759px) {
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    overflow: visible;
  }

  .tabs__btn {
    flex-direction: column;
    gap: 2px;
    padding: 6px 2px;
    font-size: 11px;
    border-radius: 8px;
  }

  .tabs__btn.is-active {
    background: var(--accent-soft);
    border-color: transparent;
    box-shadow: none;
    color: var(--accent);
  }

  .tabs__full {
    display: none;
  }

  .tabs__short {
    display: block;
  }
}

/* ------------------------------------------------------------------ cards */

.page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card__title {
  font-size: 17px;
  margin-bottom: 6px;
}

.card--warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
}

.card--empty {
  text-align: center;
  padding: 40px 20px;
}

.row-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.row-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.footer {
  padding: 8px 0 24px;
  text-align: center;
}

/* ------------------------------------------------------------------ hero */

.hero__head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero__title {
  font-size: 22px;
}

.hero__score {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.hero__bars {
  flex: 1 1 240px;
  min-width: 200px;
}

.donut {
  --value: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), var(--surface-2) 0);
  flex: 0 0 auto;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--surface);
}

.donut__value,
.donut__label {
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
}

.donut__value {
  font-size: 21px;
  font-weight: 700;
  transform: translateY(-7px);
}

.donut__label {
  font-size: 11px;
  color: var(--muted);
  transform: translateY(12px);
}

.legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 4px;
}

/* ------------------------------------------------------------------ bars */

.bar {
  height: 7px;
  border-radius: 6px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar--tall {
  height: 11px;
}

.bar__fill {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.bar__fill--complete {
  background: var(--good);
}

.bar__fill--ontrack {
  background: var(--accent);
}

.bar__fill--atrisk {
  background: var(--warn);
}

.bar__fill--offtrack {
  background: var(--bad);
}

.bar__fill--empty,
.bar__fill--unscored,
.bar__fill--pending {
  background: transparent;
}

/* ------------------------------------------------------------------ tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.tiles--tight {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin: 10px 0;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tile__label {
  font-size: 12px;
  color: var(--muted);
}

.tile__value {
  font-size: 22px;
  font-weight: 700;
}

.tile__value--accent {
  color: var(--accent);
}

.tile__hint {
  font-size: 11px;
  color: var(--muted);
}

.tile--good {
  border-color: color-mix(in srgb, var(--good) 45%, var(--line));
}

.tile--bad {
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
}

/* ------------------------------------------------------------------ table */

.table {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.table__head {
  display: none;
  font-size: 12px;
  color: var(--muted);
  padding: 0 8px 6px;
}

.table__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
}

.table__row > span[data-label]::before {
  content: attr(data-label) ": ";
  color: var(--muted);
  font-size: 12px;
}

.table__score {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.table__score .bar {
  flex: 1;
}

@media (min-width: 760px) {
  .table__head,
  .table__row {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) 90px minmax(180px, 1.4fr) 120px;
    align-items: center;
  }

  .table__head {
    display: grid;
  }

  .table__row > span[data-label]::before {
    content: none;
  }

  .table__name {
    font-weight: 600;
  }
}

/* ------------------------------------------------------------------ rows (planner + archive) */

.rows {
  display: flex;
  flex-direction: column;
}

.rows__head {
  display: none;
}

.rows__group {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 12px 0 4px;
}

.rows__row {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.kr__title {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.kr__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.kr__done {
  margin-top: 4px;
}

.kr__note {
  margin-top: 4px;
  padding: 6px 8px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cell[data-label]::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 12px;
  min-width: 66px;
}

.cell__line {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.score-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 40px;
}

.target {
  font-variant-numeric: tabular-nums;
}

@media (min-width: 760px) {
  .rows__head {
    display: grid;
    grid-template-columns: minmax(240px, 2.2fr) 90px 130px minmax(150px, 1fr);
    gap: 12px;
    padding: 0 0 6px;
    font-size: 12px;
    color: var(--muted);
  }

  .rows__row {
    grid-template-columns: minmax(240px, 2.2fr) 90px 130px minmax(150px, 1fr);
    gap: 12px;
    align-items: start;
  }

  .cell[data-label]::before {
    content: none;
  }

  .rows--readonly .rows__row {
    grid-template-columns: minmax(240px, 2.6fr) 140px minmax(150px, 1fr);
  }
}

.rows--readonly .rows__row {
  padding: 10px 0;
}

/* ------------------------------------------------------------------ pills + chips */

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}

.pill--complete {
  background: color-mix(in srgb, var(--good) 18%, transparent);
  color: var(--good);
}

.pill--ontrack {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill--atrisk {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}

.pill--offtrack {
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  color: var(--bad);
}

.chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ lists */

.list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.list--plain {
  list-style: disc;
  padding-left: 18px;
  gap: 8px;
}

.list--tight {
  font-size: 13px;
  padding-left: 18px;
  list-style: disc;
}

.list__item {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.list__score {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 130px;
}

.list__score .bar {
  width: 70px;
}

/* ------------------------------------------------------------------ forms */

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field__hint {
  font-size: 12px;
  color: var(--muted);
}

.input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input:focus-visible,
.btn:focus-visible,
.tabs__btn:focus-visible,
.switch__btn:focus-visible,
.quarter__head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

textarea.input {
  resize: vertical;
}

.input--num {
  font-variant-numeric: tabular-nums;
}

.input--title {
  font-weight: 650;
}

.select {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.select--compact {
  flex-direction: row;
  align-items: center;
}

.select select {
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  max-width: 46vw;
}

.grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.grid--2 {
  grid-template-columns: 1fr;
}

.grid--3 {
  grid-template-columns: 1fr;
}

@media (min-width: 620px) {
  .grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-top: 12px;
}

.toolbar--center {
  justify-content: center;
}

.toolbar__spacer {
  flex: 1;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.btn:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.btn--small {
  padding: 6px 10px;
  font-size: 13px;
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.icon-btn--danger:hover {
  color: var(--bad);
  border-color: var(--bad);
}

/* ------------------------------------------------------------------ auth */

.auth {
  display: grid;
  place-items: center;
  min-height: 88vh;
  padding: 24px 0;
}

.auth__panel {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth__brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.auth__brand h1 {
  font-size: 20px;
}

.auth__error {
  padding: 9px 11px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
}

.switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 12px;
}

.switch__btn {
  flex: 1;
  padding: 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.switch__btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.notice {
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.notice--info {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

/* ------------------------------------------------------------------ editor */

.categories {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.category {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-2);
}

.category__head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.drag {
  color: var(--muted);
  cursor: grab;
  user-select: none;
}

.category__tools {
  display: flex;
  gap: 4px;
}

.goals {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goals__head {
  display: none;
}

.goal {
  display: grid;
  grid-template-columns: 58px 1fr 1fr 34px;
  grid-template-areas:
    "code title title remove"
    "unit from to to"
    "dir dir current current";
  gap: 6px;
  align-items: center;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.goal [data-goal-field="code"] {
  grid-area: code;
}
.goal [data-goal-field="title"] {
  grid-area: title;
}
.goal [data-goal-field="unit"] {
  grid-area: unit;
}
.goal [data-goal-field="baseline"] {
  grid-area: from;
}
.goal [data-goal-field="target"] {
  grid-area: to;
}
.goal [data-goal-field="direction"] {
  grid-area: dir;
}
.goal [data-goal-field="current"] {
  grid-area: current;
}
.goal .icon-btn {
  grid-area: remove;
}
.goal__more {
  grid-column: 1 / -1;
}

.goal__more summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 2px 0;
}

.goal__more .field,
.goal__more .grid {
  margin-top: 8px;
}

@media (min-width: 860px) {
  .goals__head,
  .goal {
    display: grid;
    grid-template-columns: 62px minmax(200px, 3fr) 90px 72px 72px 78px 92px 34px;
    gap: 6px;
  }

  .goals__head {
    font-size: 11px;
    color: var(--muted);
    padding: 0 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* Undo the stacked phone layout.  These selectors carry the same weight as
     the grid-area rules above and come later, so they win. */
  .goal {
    grid-template-areas: none;
  }

  .goal > [data-goal-field],
  .goal > .icon-btn {
    grid-area: auto;
  }

  .goal__more {
    grid-column: 1 / -1;
  }
}

/* ------------------------------------------------------------------ archive */

.archive {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.archive__trend {
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
}

.sparkline {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin-top: 8px;
  overflow-x: auto;
}

.spark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 62px;
}

.spark__bar {
  display: flex;
  align-items: flex-end;
  width: 30px;
  height: 68px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
}

.spark__bar > span {
  display: block;
  width: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.spark__label,
.spark__value {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.spark__value {
  font-weight: 700;
  color: var(--text);
}

.quarter {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.quarter.is-open {
  background: var(--surface-2);
}

.quarter__head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.quarter__title {
  display: flex;
  flex-direction: column;
}

.quarter__score {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}

.quarter__score .bar {
  width: 60px;
}

.quarter__chevron {
  color: var(--muted);
}

.quarter__body {
  padding: 0 12px 14px;
}

/* ------------------------------------------------------------------ check-ins */

.checkins {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkin {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.checkin summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.checkin__body {
  margin: 10px 0;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px 10px;
}

.checkin__body dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.checkin__body dd {
  margin: 0;
}

/* ------------------------------------------------------------------ misc */

.invite {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0 4px;
}

.invite__code {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.sub {
  margin: 14px 0 6px;
}

.quickstats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 13px;
  color: var(--muted);
}

.quickstats b {
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 60;
  transform: translate(-50%, 20px);
  max-width: min(90vw, 460px);
  padding: 10px 14px;
  border-radius: 12px;
  background: #14161f;
  color: #fff;
  font-size: 13px;
  font-weight: 550;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

@media (min-width: 760px) {
  .toast {
    bottom: 28px;
  }
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast--error {
  background: var(--bad);
}

.modal {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  max-width: min(92vw, 460px);
  background: var(--surface);
  color: var(--text);
}

.modal::backdrop {
  background: rgba(10, 12, 20, 0.5);
}

.modal__body {
  padding: 18px;
}

.modal__title {
  font-size: 17px;
  margin-bottom: 8px;
}

.modal__text {
  font-size: 14px;
  color: var(--muted);
}

.modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

@media print {
  .topbar,
  .tabs,
  .btn,
  .footer {
    display: none;
  }
}

/* ==========================================================================
   Phone layout
   --------------------------------------------------------------------------
   One app, re-laid-out.  The rules here exist because measurements at 320/390/
   430px said so (tools/mobile_audit.mjs):
     - every text field is 16px, because iOS Safari zooms the whole page when a
       focused field is smaller than that
     - every control is at least 44px tall, the size a thumb can hit
     - a planner row is two compact lines instead of a 240px block, so most of a
       quarter fits on one screen
   The markup is identical at every width; only visibility and grid placement
   change, so there is no second UI to keep in sync.
   ========================================================================== */

.only-narrow {
  display: none !important;
}

/* Hide the row detail until it is asked for; the desktop rule re-shows it. */
.kr__extra {
  display: none;
}

.rows__row.is-open .kr__extra {
  display: block;
}

.kr__toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 17px;
  cursor: pointer;
}

.rows__row.is-open .kr__toggle {
  transform: rotate(180deg);
  color: var(--accent);
}

.kr__toggle-less {
  display: none;
}

.rows__row.is-open .kr__toggle-more {
  display: none;
}

.rows__row.is-open .kr__toggle-less {
  display: inline;
}

.kr__pill {
  flex: 0 0 auto;
}

.cell__pill {
  display: none;
}

/* Thumb-sized steppers, one tap to record progress. */
.stepper__btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.stepper__btn:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.cell--current {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cell--current .input {
  width: 100%;
  min-width: 0;
}

@media (max-width: 759px) {
  .only-wide {
    display: none !important;
  }

  .only-narrow {
    display: inline !important;
  }

  /* Never let iOS zoom on focus. */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Thumb-sized controls everywhere. */
  .btn,
  .btn--small,
  .tabs__btn,
  .switch__btn,
  .quarter__head,
  .checkin summary {
    min-height: 44px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
    font-size: 17px;
  }

  /* Fields too: a 38px select is a miss, not a tap. */
  .input,
  .select select,
  .topbar .select select,
  #sign-out {
    min-height: 44px;
  }

  .app {
    padding: 0 12px;
  }

  /* --- dashboard: lead with the action and the number --------------------- */
  .donut {
    display: none; /* the Actual/Expected bars below already carry the figure */
  }

  .hero__score {
    margin-top: 10px;
  }

  .hero__head {
    gap: 8px;
  }

  .hero__actions {
    width: 100%;
  }

  .hero__actions .btn {
    flex: 1 1 auto;
    padding: 10px 10px;
  }

  /* Reachable from the bottom bar already. */
  [data-tab="weekly"].btn--small {
    display: none;
  }

  .hero__title {
    font-size: 20px;
  }

  .tile__value {
    font-size: 20px;
  }

  /* --- planner: two compact lines per key result -------------------------- */
  .rows__row {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 8px;
    padding: 10px 0;
    align-items: center;
  }

  .rows__row .kr {
    grid-column: 1 / -1;
  }

  .cell--target {
    display: none; /* the target sits next to the stepper instead */
  }

  .cell[data-label]::before {
    content: none;
  }

  /* Let a long title wrap rather than squeeze the status pill. */
  .kr__title {
    flex-wrap: wrap;
  }

  .kr__pill {
    margin-left: auto;
  }

  .cell--current {
    grid-column: 1;
  }

  .cell--current .input {
    width: 56px;
    flex: 0 0 auto;
    padding: 9px 4px;
    text-align: center;
  }

  .cell--progress {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .cell--progress .bar {
    flex: 1 1 auto;
    min-width: 32px;
  }

  .cell--progress .score-value {
    min-width: 0;
    font-size: 13px;
  }

  /* The Target column is hidden here, so show it beside the stepper. */
  .kr__target {
    display: inline;
    flex: 0 0 auto;
    font-size: 12px;
    white-space: nowrap;
  }

  .kr__meta,
  .kr__done,
  .kr__note {
    margin-top: 6px;
  }

  /* --- editor: stack the category header so the name keeps its width ------ */
  .category__head {
    flex-wrap: wrap;
  }

  .category__head .input--title {
    flex: 1 1 100%;
    order: 1;
  }

  .category__tools {
    order: 2;
    margin-left: auto;
  }

  .goal {
    grid-template-columns: 52px 1fr 1fr 44px;
    gap: 6px;
  }

  /* --- misc ---------------------------------------------------------------*/
  .card {
    padding: 14px 12px;
  }

  .list__item {
    align-items: flex-start;
  }

  .quarter__head {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title score"
      "chevron chevron";
  }

  .quarter__title {
    grid-area: title;
  }

  .quarter__score {
    grid-area: score;
    min-width: 0;
  }

  .quarter__chevron {
    grid-area: chevron;
    text-align: right;
  }
}

/* On a very narrow phone the percentage would crowd the bar. */
@media (max-width: 359px) {
  .cell--progress .score-value {
    display: none;
  }
}

/* The responsive rules above are for phones; from tablet width up the row is a
   table again and the phone-only affordances go away. */
@media (min-width: 760px) {
  .only-wide {
    display: inline !important;
  }

  .kr__extra {
    display: block;
  }

  .kr__toggle,
  .stepper__btn,
  .kr__target {
    display: none;
  }

  .kr__pill {
    display: none;
  }

  .cell__pill {
    display: inline-flex;
  }
}
