/* Hassan — "Mono" design: black & white, Geist, hairline list. */

:root {
  color-scheme: light;

  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #fff;
  --surface: #fff;
  --surface-2: #f4f4f5;
  --text: #0a0a0a;
  --muted: #737373;
  --line: #ececec;
  --accent: #0a0a0a;
  --red: #ff3b30;
  --mark: #e5e5e5;
  --ring: rgba(0, 0, 0, 0.08);

  --radius: 14px;
  --radius-sm: 12px;
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 4px 16px calc(env(safe-area-inset-bottom) + 110px);
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: #c4c4c4;
  text-underline-offset: 2px;
  word-break: break-all;
}

/* ---------- Header ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(env(safe-area-inset-top) + 12px) 20px 14px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.top-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 608px;
  margin: 0 auto;
}

#title {
  flex: 1;
  margin: 0 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.045em;
}

/* Logo: heavy "H" with a small red dot at its top-right. Tapping it goes home. */
.logo {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0 4px 1px 0; /* nudged left so H + dot sit centred together */
  font-size: 21px;
  line-height: 1;
  letter-spacing: -0.06em;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.logo .h {
  font-weight: 800;
}

.logo::after {
  content: "";
  position: absolute;
  top: 11px;
  right: 7px;
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
}

/* When there's a count, the badge replaces the dot */
.logo:has(sup:not(:empty))::after {
  display: none;
}

.logo sup {
  position: absolute;
  top: -7px;
  right: -9px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: 0;
  text-align: center;
  color: #fff;
  background: var(--red);
  border: 2px solid var(--bg);
  border-radius: 10px;
}

.logo sup:empty {
  display: none;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--text);
  background: var(--surface-2);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn[aria-pressed="true"] {
  color: #fff;
  background: var(--accent);
}

#reload:active svg {
  transform: rotate(-60deg);
  transition: transform 0.2s;
}

/* ---------- Tabs ---------- */

section {
  display: none;
  animation: fade-in 0.2s ease;
}

section.on {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
}

/* ---------- Filters ---------- */

.filters {
  padding-top: 12px;
}

.field {
  position: relative;
  display: block;
}

.field svg {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 18px;
  height: 18px;
  translate: 0 -50%;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.field input {
  height: 44px;
  padding-left: 42px;
  background: var(--surface-2);
  border-color: transparent;
}

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

.search-row .field {
  flex: 1;
}

/* Filter toggle: dark when open, red dot when a date/type filter is active */
.filter-btn {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--text);
  background: var(--surface-2);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.filter-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.filter-btn[aria-expanded="true"] {
  color: #fff;
  background: var(--accent);
}

.filter-btn.active::after {
  content: "";
  position: absolute;
  top: 9px;
  right: 9px;
  width: 7px;
  height: 7px;
  background: var(--red);
  border: 1.5px solid var(--surface-2);
  border-radius: 50%;
}

.filter-btn.active[aria-expanded="true"]::after {
  border-color: var(--accent);
}

.filter-panel {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: fade-in 0.15s ease;
}

.filter-label {
  margin: 0 2px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.filter-label:not(:first-child) {
  margin-top: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
}

.chip {
  flex: none;
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface-2);
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chip .n {
  margin-left: 5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chip.on {
  color: #fff;
  background: var(--accent);
}

.chip.on .n {
  color: #a3a3a3;
}

/* Date range as a segmented control */
.chips.seg {
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 10px;
}

.chips.seg .chip {
  flex: 1;
  height: 28px;
  padding: 0 6px;
  background: none;
  border-radius: 8px;
}

.chips.seg .chip.on {
  color: var(--text);
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 4px 0;
  font-size: 13px;
  color: var(--muted);
}

.link-btn {
  padding: 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- Notification list ---------- */

.day {
  margin: 18px 4px 2px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Swipe row: the item slides over a coloured action layer (red = trash, dark = restore) */
.swipe {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 22px;
  color: #fff;
  background: var(--red);
  opacity: 0;
}

.trash-view .swipe-bg {
  background: var(--accent);
}

.swipe-bg.left {
  justify-content: flex-end;
}

.swipe-bg svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s;
}

.swipe.armed .swipe-bg svg {
  transform: scale(1.25);
}

.swipe.gone {
  transition: height 0.2s ease;
}

.item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 4px;
  background: var(--bg);
  cursor: pointer;
  touch-action: pan-y; /* vertical scroll stays native, horizontal moves are ours */
  user-select: none;
}

.item.snap {
  transition: transform 0.2s ease;
}


.item:active {
  background: #fafafa;
}

/* Letter avatar, shade picked from the title (--h set inline) */
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-size: 14.5px;
  font-weight: 700;
  color: hsl(var(--h) 0% 15%);
  background: hsl(var(--h) 0% 95%);
  border-radius: 50%;
}

.body {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* Full title always visible: wraps instead of truncating (prices sit at the end) */
.ttl {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.item.unread .ttl {
  font-weight: 700;
}

.when {
  flex: none;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  padding-top: 1px;
  color: var(--muted);
}

.dot {
  flex: none;
  margin-top: 5px;
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 50%;
}

.msg {
  display: -webkit-box;
  margin: 1px 0 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Tap to expand the full message */
.item.open .msg {
  display: block;
}

mark {
  padding: 0 2px;
  color: inherit;
  background: var(--mark);
  border-radius: 4px;
}

.empty {
  padding: 72px 24px;
  text-align: center;
  color: var(--muted);
}

.empty svg {
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  opacity: 0.6;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty b {
  display: block;
  margin-bottom: 2px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

/* ---------- Forms ---------- */

input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  font: 16px var(--font); /* 16px stops iOS zooming on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder {
  color: var(--muted);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  margin-top: 10px;
  font-size: 15.5px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn.ghost {
  color: var(--text);
  background: var(--surface-2);
}

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

/* ---------- Settings ---------- */

.group-title {
  margin: 26px 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.card p {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--muted);
}

pre {
  margin: 8px 0 0;
  padding: 12px 14px;
  overflow-x: auto;
  font: 12px/1.6 ui-monospace, Menlo, Consolas, monospace;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--surface-2);
  border-radius: 10px;
}

/* ---------- Bottom tab bar ---------- */

.tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  padding: 6px 12px calc(env(safe-area-inset-bottom) + 6px);
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.tabs-inner {
  display: flex;
  max-width: 440px;
  margin: 0 auto;
}

.tabs button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}

.tabs .ico {
  display: grid;
  place-items: center;
  width: 54px;
  height: 32px;
  border-radius: 16px;
  transition: background 0.2s;
}

.tabs button.on {
  color: var(--accent);
}

.tabs button.on .ico {
  background: #f0f0f0;
}

.tabs svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Images: bento grid ---------- */

/* Square cells sized from the content width; tiles span cells by aspect ratio */
.bento {
  --cols: 3;
  --gap: 4px;
  --cell: calc((min(100vw, 640px) - 32px - (var(--cols) - 1) * var(--gap)) / var(--cols));
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-auto-rows: var(--cell);
  grid-auto-flow: dense;
  gap: var(--gap);
  padding-top: 12px;
}

@media (min-width: 560px) {
  .bento {
    --cols: 4;
    --gap: 6px;
  }
}

.tile {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: var(--surface-2);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.tile.wide { grid-column: span 2; }
.tile.tall { grid-row: span 2; }
.tile.big  { grid-column: span 2; grid-row: span 2; }
.tile.pano { grid-column: 1 / -1; }

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s, transform 0.2s;
}

.tile img.loaded {
  opacity: 1;
}

.tile:active img {
  transform: scale(0.97);
}

/* Upload in progress: local preview, dimmed, with a progress bar */
.tile.pending {
  cursor: default;
}

.tile.pending img {
  opacity: 0.5;
}

.tile .bar {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 2px;
}

.tile .bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}

.bento .empty {
  grid-column: 1 / -1;
  grid-row: span 3;
}

/* ---------- Image viewer ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: #000;
  animation: fade-in 0.15s ease;
}

.viewer-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
}

.v-info {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  color: #a3a3a3;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.v-btn,
.v-nav {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.v-btn svg,
.v-nav svg,
.v-act svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.v-stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  touch-action: pinch-zoom; /* pinch still zooms; swipes are ours: sideways = next/prev, down = close */
}

.v-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s, opacity 0.2s;
  user-select: none;
  -webkit-user-drag: none;
}

.v-nav {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
}

.v-nav.prev { left: 12px; }
.v-nav.next { right: 12px; }

/* Touch screens swipe instead */
@media (hover: none) {
  .v-nav { display: none; }
}

.viewer-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px);
}

.v-act {
  flex: 1;
  max-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.v-act:active {
  background: rgba(255, 255, 255, 0.1);
}

.v-act.danger.confirm {
  color: var(--red);
}

/* Drag-and-drop overlay (desktop) */
.drop {
  position: fixed;
  inset: 12px;
  z-index: 40;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.92);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  pointer-events: none;
}

/* ---------- Reminders: list ---------- */

.day.alert {
  color: var(--red);
}

.rem {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}

.rem:active {
  background: #fafafa;
}

.rem:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 8px;
}

/* Severity shows in the icon too: low = outline, normal = grey, high = red */
.rem-ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 50%;
}

.rem-ico svg,
.ring-ico svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rem.sev-low .rem-ico {
  color: var(--muted);
  background: none;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.rem.sev-high .rem-ico {
  color: var(--red);
  background: #fff0ef;
}

.rem .ttl {
  font-size: 15.5px;
}

.rem .when {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.rem.late .when {
  color: var(--red);
}

.rem-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.rem-sub > span:last-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sev-tag {
  flex: none;
  height: 19px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 19px;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 10px;
}

.sev-tag.low {
  color: var(--muted);
  background: none;
  box-shadow: inset 0 0 0 1px var(--line);
}

.sev-tag.high {
  color: var(--red);
  background: #ffeceb;
}

/* Done: greyed out with a check */
.rem.done .rem-ico {
  color: var(--muted);
  background: var(--surface-2);
  box-shadow: none;
}

.rem.done .ttl {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: #c4c4c4;
}

.rem.done .when,
.rem.done .sev-tag {
  color: var(--muted);
}

.rem.done .sev-tag.high {
  background: var(--surface-2);
}

/* Ringing high-severity reminder: red card with a wobbling bell */
.ring-card {
  margin: 8px 0 12px;
  padding: 14px;
  background: #fff6f5;
  border: 1px solid #ffd4d1;
  border-radius: var(--radius);
  cursor: pointer;
}

.ring-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ring-ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: var(--red);
  border-radius: 50%;
  animation: ring-pulse 1.6s ease-out infinite;
}

.ring-ico svg {
  width: 20px;
  height: 20px;
  animation: ring-wobble 1.6s ease-in-out infinite;
}

@keyframes ring-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); }
  70%, 100% { box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); }
}

@keyframes ring-wobble {
  0%, 50%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(14deg); }
  20%, 40% { transform: rotate(-14deg); }
}

.ring-text {
  min-width: 0;
}

.ring-text b {
  display: block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.ring-text span {
  font-size: 13px;
  color: #b4362e;
}

.btn.alarm {
  margin-top: 12px;
  background: var(--red);
}

.empty .btn {
  max-width: 220px;
  margin: 18px auto 0;
}

/* ---------- Reminders: add / edit sheet ---------- */

.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  animation: backdrop-in 0.2s ease;
}

@keyframes backdrop-in {
  from { opacity: 0; }
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 20px);
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.12);
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
}

.grabber {
  width: 36px;
  height: 5px;
  margin: 0 auto 10px;
  background: #d9d9d9;
  border-radius: 3px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.sheet-head .icon-btn {
  width: 34px;
  height: 34px;
}

.sheet-head .icon-btn svg {
  width: 17px;
  height: 17px;
}

.sheet .ring-card {
  margin: 0 0 14px;
  cursor: default;
}

.sheet .filter-label {
  margin: 18px 2px 8px;
}

#r-title {
  font-weight: 500;
}

.r-when {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

/* Native date / time pickers, styled like the other fields */
.r-when input {
  min-width: 0;
  text-align: left;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border-color: transparent;
}

.r-when input::-webkit-date-and-time-value {
  text-align: left;
}

.r-when input:focus {
  background: var(--surface);
  border-color: var(--accent);
}

/* Severity segmented control; each option has a dot, High turns red */
.chips.seg.sev .chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
}

.chips.seg.sev .chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--muted);
}

.chips.seg.sev [data-sev="normal"] i {
  background: var(--text);
  box-shadow: none;
}

.chips.seg.sev [data-sev="high"] i {
  background: var(--red);
  box-shadow: none;
}

.chips.seg.sev[data-sev="high"] .chip.on {
  color: #fff;
  background: var(--red);
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.35);
}

.chips.seg.sev[data-sev="high"] .chip.on i {
  background: #fff;
}

.r-hint {
  margin: 8px 2px 0;
  font-size: 13px;
  color: var(--muted);
}

textarea {
  display: block;
  width: 100%;
  min-height: 72px;
  margin-top: 18px;
  padding: 13px 16px;
  font: 16px/1.4 var(--font); /* 16px stops iOS zooming on focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea::placeholder {
  color: var(--muted);
}

textarea:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

/* Lock-screen style preview of the notification */
.np {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 18px;
}

.np.high {
  box-shadow: inset 3px 0 0 var(--red);
}

.np img {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 9px;
}

.np-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.np-app {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--muted);
}

.np-body b {
  font-size: 14.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

#np-text {
  font-size: 13.5px;
  color: #404040;
}

.np-action {
  display: none;
  margin-top: 9px;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--red);
  background: var(--bg);
  border-radius: 10px;
}

.np.high .np-action {
  display: block;
}

#r-save {
  margin-top: 20px;
}

.r-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.r-actions .btn {
  margin-top: 8px;
}

.r-actions:has(#r-off[hidden]) {
  grid-template-columns: 1fr;
}

.btn.ghost.danger {
  color: var(--red);
}

.btn.ghost.danger.confirm {
  color: #fff;
  background: var(--red);
}

/* ---------- Usage ---------- */

#usage-claude {
  padding-top: 14px;
}

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

.u-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.u-logo {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #fff;
  background: var(--accent);
  border-radius: 12px;
}

.u-logo svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.u-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.u-title b {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.u-title span {
  font-size: 13px;
  color: var(--muted);
}

.u-status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.u-status:not(:empty)::before {
  content: "";
  width: 7px;
  height: 7px;
  background: #34c759;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18);
}

.u-status.stale::before {
  background: var(--muted);
  box-shadow: none;
}

/* One limit window */
.meter {
  --fill: var(--accent);
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--line);
}

.meter.warn { --fill: #ff9500; }
.meter.crit { --fill: var(--red); }

.m-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.m-name {
  font-size: 15px;
  font-weight: 600;
}

.m-pct {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.m-pct b {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text);
}

.meter.warn .m-pct b,
.meter.crit .m-pct b {
  color: var(--fill);
}

.m-span {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

/* Full-width bar: fill = used, dark tick = time elapsed in the window */
.m-bar {
  position: relative;
  height: 14px;
  margin-top: 12px;
  background: var(--surface-2);
  border-radius: 7px;
}

.m-bar i {
  display: block;
  height: 100%;
  min-width: 14px;
  background: var(--fill);
  border-radius: 7px;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.m-bar i[style="width:0"] {
  min-width: 0;
}

.m-now,
.m-key {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  margin-left: -1.5px;
  background: var(--text);
  border: 1px solid var(--bg);
  border-radius: 2px;
  box-sizing: content-box;
  transition: left 1s linear;
}

.m-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 500;
  color: #a3a3a3;
  font-variant-numeric: tabular-nums;
}

.m-times {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.m-time {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 12px;
}

.m-time .k {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.m-time .v {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.m-pace {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.m-pace.crit {
  font-weight: 500;
  color: var(--red);
}

.u-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.u-legend .m-key {
  position: relative;
  top: 0;
  bottom: 0;
  height: 14px;
  margin: 0 2px;
}

.u-error {
  padding: 24px 4px 8px;
  font-size: 14px;
  text-align: center;
  color: var(--muted);
}

.u-error b {
  display: block;
  margin-bottom: 2px;
  font-size: 16px;
  color: var(--text);
}

/* Loading placeholder */
.meter.skeleton i {
  display: block;
  height: 14px;
  margin-top: 10px;
  background: linear-gradient(90deg, var(--surface-2) 30%, #fafafa 50%, var(--surface-2) 70%) 0 0 / 300% 100%;
  border-radius: 7px;
  animation: shimmer 1.2s linear infinite;
}

.meter.skeleton i:first-child { width: 45%; margin-top: 0; }
.meter.skeleton i:last-child { width: 70%; }

@keyframes shimmer {
  to { background-position: -150% 0; }
}

/* ---------- Usage: weekly planner ---------- */

.u-card.plan {
  --plan: var(--accent);
  --sess: #ff9500;
  margin-top: 12px;
  padding-bottom: 16px;
}

.p-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.p-head > b {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  background: var(--surface-2);
  border-radius: 10px;
}

.stepper b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stepper span {
  padding: 0 6px;
}

.stepper button {
  width: 28px;
  height: 26px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  background: var(--bg);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

/* Big number + verdict */
.p-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0 12px;
}

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

.p-big b {
  font-size: 56px;
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.p-big span {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--muted);
}

.p-verdict {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 12px;
}

.p-verdict i {
  font-style: normal;
  font-size: 11px;
}

.p-verdict.ok   { color: #1a7f37; background: #e9f7ee; }
.p-verdict.warn { color: #b45309; background: #fff4e5; }
.p-verdict.crit { color: #c62828; background: #fdecea; }

/* Budget cells: one cell = one window */
.cells {
  display: flex;
  gap: 4px;
  height: 30px;
}

.cell {
  position: relative;
  display: flex;
  overflow: hidden;
  background: var(--bg);
  border: 1.5px dashed #d4d4d4;
  border-radius: 7px;
}

.cell i {
  flex: none;
  height: 100%;
}

.c-used { background: #c4c4c4; }
.c-sess { background: var(--sess); }
.c-plan { background: var(--plan); }
.c-free { background: var(--bg); border: 1.5px dashed #d4d4d4; }

.c-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.c-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.c-legend i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* Stat tiles */
.p-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.p-stats div {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  background: var(--surface-2);
  border-radius: 12px;
}

.p-stats b {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.p-stats span {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

/* Section labels with inline keys */
.p-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 20px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.p-sub span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.p-sub i {
  display: inline-block;
  width: 12px;
  height: 4px;
  margin-left: 4px;
  border-radius: 2px;
}

.k-plan  { background: var(--plan); }
.k-max   { background: repeating-linear-gradient(90deg, var(--red) 0 3px, transparent 3px 5px); }
.k-sess  { background: var(--sess); }
.k-spare { background: #e5e5e5; }

/* Forecast chart */
.fc {
  display: block;
  width: 100%;
  height: 120px;
  overflow: visible;
}

.fc * {
  vector-effect: non-scaling-stroke;
  fill: none;
}

.fc-grid { stroke: var(--line); stroke-width: 1; }
.fc-cap  { stroke: var(--text); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.4; }
.fc .fc-area { fill: rgba(10, 10, 10, 0.06); }
.fc-plan { stroke: var(--plan); stroke-width: 2.5; stroke-linejoin: round; }
.fc-max  { stroke: var(--red); stroke-width: 1.5; stroke-dasharray: 4 3; stroke-linejoin: round; }
.fc-run  { stroke: var(--red); stroke-width: 1; opacity: 0.5; }

.fc-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.fc-empty {
  font-weight: 600;
  color: var(--red);
  text-align: center;
}

/* Day schedule: 24h tracks */
.d-hours,
.day-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  column-gap: 10px;
}

.d-hours {
  margin-bottom: 4px;
  font-size: 10.5px;
  color: #a3a3a3;
}

.h-scale {
  position: relative;
  height: 13px;
}

.h-scale span {
  position: absolute;
  translate: -50% 0;
}

.h-scale span:first-child { translate: 0 0; }
.h-scale span:last-child { translate: -100% 0; }

.day-row {
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.d-name {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
}

.d-name span {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.d-track {
  position: relative;
  height: 22px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 6px;
}

.d-track i {
  position: absolute;
  top: 0;
  bottom: 0;
}

.t-sleep { background: repeating-linear-gradient(135deg, transparent 0 4px, rgba(0, 0, 0, 0.05) 4px 8px); }
.t-after { background: repeating-linear-gradient(135deg, #fff 0 4px, #f0f0f0 4px 8px); }
.t-spare { background: #e5e5e5; border-left: 2px solid var(--surface-2); }
.t-plan  { background: var(--plan); border-left: 2px solid var(--surface-2); }
.t-sess  { background: var(--sess); }

.d-track b {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
}

.t-now   { background: var(--red); box-shadow: 0 0 0 1px #fff; }
.t-reset { background: var(--text); width: 3px !important; }

.d-times {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.d-times span {
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.d-times span.none {
  color: var(--muted);
  background: var(--surface-2);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  left: 50%;
  z-index: 45; /* above the image viewer and reminder sheet */
  max-width: calc(100% - 32px);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--text);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

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

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