/* ============================================================
   Follow-up — pure black & white, iOS feel
   ============================================================ */
:root {
  --bg: #f2f2f7;          /* iOS grouped background */
  --surface: #ffffff;
  --surface-2: #ffffff;
  --ink: #000000;
  --ink-2: #6b6b70;       /* secondary label */
  --ink-3: #a1a1a6;       /* tertiary */
  --hair: rgba(0, 0, 0, 0.08);
  --hair-strong: rgba(0, 0, 0, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --sheet-shadow: 0 -1px 40px rgba(0, 0, 0, 0.18);
  --radius: 20px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --ink: #ffffff;
    --ink-2: #98989f;
    --ink-3: #6c6c70;
    --hair: rgba(255, 255, 255, 0.1);
    --hair-strong: rgba(255, 255, 255, 0.16);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --shadow: none;
    --sheet-shadow: 0 -1px 40px rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
.hidden {
  display: none !important;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-t);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--hair);
}
.topbar-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 8px 20px 6px;
}
.large-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--fill);
  transition: transform 0.15s var(--ease), background 0.15s;
}
.icon-btn:active {
  transform: scale(0.9);
  background: var(--fill-2);
}
.icon-btn.on {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- Segmented control ---------- */
.segmented {
  position: relative;
  display: flex;
  margin: 6px 20px 12px;
  padding: 2px;
  background: var(--fill);
  border-radius: 10px;
  height: 34px;
}
.seg {
  position: relative;
  z-index: 2;
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  border-radius: 8px;
  transition: color 0.2s;
}
.seg:not(.active) {
  color: var(--ink-2);
}
.seg-thumb {
  position: absolute;
  z-index: 1;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.08);
  transition: transform 0.28s var(--ease);
}
.seg-thumb.right {
  transform: translateX(100%);
}

/* ---------- Tag filter bar ---------- */
.tagbar {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tagbar::-webkit-scrollbar {
  display: none;
}
.chip {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--c, var(--ink-2));
  white-space: nowrap;
  transition: transform 0.15s var(--ease), background 0.15s, color 0.15s;
}
.chip:active {
  transform: scale(0.94);
}
/* "All" chip (no colour) selected -> black/white */
.chip.on {
  background: var(--ink);
  color: var(--bg);
}
/* a coloured tag chip selected -> its own colour */
.chip.on[class*="t-"] {
  background: var(--c);
  color: #fff;
}

/* ---------- Board ---------- */
.board {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px calc(120px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border: 0.5px solid var(--hair);
  transition: transform 0.18s var(--ease), opacity 0.3s;
  animation: rise 0.4s var(--ease) both;
}
.card:active {
  transform: scale(0.985);
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.card-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.card-note {
  margin-top: 4px;
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--ink-3);
}
.card-meta .m {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card-meta svg {
  width: 15px;
  height: 15px;
}
.meta-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.tag-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--c, var(--ink-2));
  background: color-mix(in srgb, var(--c, var(--ink-3)) 16%, transparent);
}

/* ---------- Tag colours (the one place we use colour) ---------- */
.t-demirbas {
  --c: #248a3d;
}
.t-service {
  --c: #0a6cff;
}
.t-kitchen {
  --c: #c25e00;
}
.t-bar {
  --c: #8944ab;
}
.t-others {
  --c: #6b6b70;
}
@media (prefers-color-scheme: dark) {
  .t-demirbas {
    --c: #30d158;
  }
  .t-service {
    --c: #409cff;
  }
  .t-kitchen {
    --c: #ff9f0a;
  }
  .t-bar {
    --c: #bf5af2;
  }
  .t-others {
    --c: #98989f;
  }
}

/* thumbnails strip on a card */
.thumbs {
  margin-top: 12px;
  display: flex;
  gap: 6px;
}
.thumbs img {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  object-fit: cover;
  border: 0.5px solid var(--hair);
}
.thumbs .more {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  background: var(--fill);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

/* routine due badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  color: var(--ink);
}
.badge.soft {
  border-color: var(--hair-strong);
  color: var(--ink-2);
}
.badge.overdue {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* empty state */
.empty {
  text-align: center;
  padding: 80px 30px;
  color: var(--ink-3);
}
.empty .big {
  font-size: 19px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.empty .sub {
  font-size: 15px;
  line-height: 1.4;
}

/* ---------- Routines: side-by-side countdown tiles ---------- */
.rt-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 2px 16px 12px;
}
.rt-rail::-webkit-scrollbar {
  display: none;
}
.followup-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rt-tile {
  flex: 0 0 auto;
  width: 98px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 0.5px solid var(--hair);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px 10px 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: rise 0.4s var(--ease) both;
  transition: transform 0.18s var(--ease);
}
.rt-tile:active {
  transform: scale(0.97);
}
.rt-tile.rt-overdue {
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--c) 38%, transparent);
}
.rt-ring {
  position: relative;
  width: 54px;
  height: 54px;
  margin-bottom: 4px;
}
.rt-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: var(--fill);
  stroke-width: 6;
}
.ring-prog {
  fill: none;
  stroke: var(--c);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s var(--ease);
}
.rt-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.rt-num {
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.rt-unit {
  font-size: 8.5px;
  font-weight: 600;
  color: var(--ink-3);
  margin-top: 1px;
}
.rt-overdue .rt-num,
.rt-overdue .rt-unit {
  color: var(--c);
}
.rt-status {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 7px;
}
.rt-overdue .rt-status {
  color: var(--c);
}
.rt-title {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  line-height: 1.25;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rt-tile .tag-pill {
  margin-top: auto;
  font-size: 9px;
  padding: 2px 7px;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 22px;
  bottom: calc(26px + var(--safe-b));
  z-index: 30;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s var(--ease);
  animation: pop 0.35s var(--ease) both;
}
.fab:active {
  transform: scale(0.9);
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

/* ---------- Sheet ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}
.scrim.show {
  opacity: 1;
}
.sheet {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 640px;
  margin: 0 auto;
  max-height: 92vh;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--sheet-shadow);
  transform: translateY(100%);
  transition: transform 0.42s var(--ease);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-b);
}
.sheet.show {
  transform: translateY(0);
}
.grabber {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--fill-2);
  margin: 8px auto 2px;
  flex: none;
}
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px 24px;
}

/* sheet content bits */
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 14px;
}
.sheet-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}
.text-btn {
  font-size: 16px;
  font-weight: 400;
  color: var(--ink);
  padding: 4px 2px;
}
.text-btn.strong {
  font-weight: 600;
}
.text-btn:active {
  opacity: 0.5;
}

.detail-note {
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  margin-bottom: 8px;
}
.detail-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 18px;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin: 22px 0 10px;
}

/* photo grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.photo-grid .cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--fill);
  border: 0.5px solid var(--hair);
}
.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-grid .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
}
.add-photo {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1.5px dashed var(--hair-strong);
  display: grid;
  place-items: center;
  color: var(--ink-3);
}
.add-photo svg {
  width: 26px;
  height: 26px;
}

/* comments */
.comment {
  padding: 12px 0;
  border-bottom: 0.5px solid var(--hair);
}
.comment:last-child {
  border-bottom: none;
}
.comment .who {
  font-size: 14px;
  font-weight: 600;
}
.comment .when {
  font-size: 12px;
  color: var(--ink-3);
  margin-left: 6px;
  font-weight: 400;
}
.comment .body {
  font-size: 15px;
  line-height: 1.45;
  margin-top: 2px;
  color: var(--ink);
}
.comment .del {
  float: right;
  color: var(--ink-3);
  font-size: 13px;
}

/* inputs */
.field {
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 0.5px solid var(--hair-strong);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  resize: none;
}
.field:focus {
  border-color: var(--ink);
}
.field::placeholder {
  color: var(--ink-3);
}
textarea.field {
  min-height: 96px;
  line-height: 1.45;
}
input[type="date"].field {
  min-height: 50px;
}
@media (prefers-color-scheme: dark) {
  input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.6;
  }
}

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 12px;
}
.composer .field {
  margin: 0;
  min-height: 44px;
}
.btn {
  font-size: 16px;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  transition: transform 0.15s var(--ease), opacity 0.15s;
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.96);
}
.btn:disabled {
  opacity: 0.35;
  transform: none;
}
.btn.block {
  width: 100%;
  padding: 15px;
}
.btn.ghost {
  background: var(--fill);
  color: var(--ink);
}
.btn.danger {
  background: none;
  color: #ff3b30;
  font-weight: 500;
}
@media (prefers-color-scheme: dark) {
  .btn.danger {
    color: #ff453a;
  }
}
.send-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
}
.send-btn:disabled {
  opacity: 0.3;
}
.send-btn svg {
  width: 20px;
  height: 20px;
}

/* type chooser (add) */
.type-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.type-choice button {
  padding: 16px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--hair-strong);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.type-choice button.on {
  border-color: var(--ink);
  background: var(--fill);
}
.type-choice .t {
  font-size: 15px;
  font-weight: 600;
}
.type-choice .d {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 3px;
  line-height: 1.3;
}

/* tag chooser (add/edit) */
.tag-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.tag-choice button {
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--c) 45%, transparent);
  background: color-mix(in srgb, var(--c) 10%, transparent);
  color: var(--c);
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s var(--ease);
}
.tag-choice button:active {
  transform: scale(0.95);
}
.tag-choice button.on {
  border-color: var(--c);
  background: var(--c);
  color: #fff;
}

.interval-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 16px;
  color: var(--ink);
}
.interval-row input {
  width: 74px;
  text-align: center;
}
.interval-row select {
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 0.5px solid var(--hair-strong);
  border-radius: 12px;
  padding: 13px 12px;
  outline: none;
}

/* lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.94);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.25s;
}
.lightbox.show {
  opacity: 1;
}
.lightbox img {
  max-width: 94vw;
  max-height: 88vh;
  border-radius: 8px;
}

/* name modal */
.name-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.name-modal.show {
  opacity: 1;
}
.name-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 0.5px solid var(--hair);
  border-radius: 20px;
  padding: 24px 22px 22px;
  transform: scale(0.94);
  transition: transform 0.28s var(--ease);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.name-modal.show .name-card {
  transform: scale(1);
}
.name-card h2 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.name-card p {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.4;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(40px + var(--safe-b));
  transform: translate(-50%, 20px);
  z-index: 90;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
