/* Perfect Boyfriend. Look borrowed from Fitness Tracker ("match my apps"):
   same dark tokens, gold accent, bottom tab bar on a phone, sidebar on a
   laptop, no bordered cards (hairlines and spacing instead), the window never
   scrolls (only the pane inside a screen does).
   This file: tokens, shell (nav, top bar, sub-tabs) and shared pieces.
   Each screen's own styles live in css/<screen>.css. */

:root {
  --ground: #0F1214;
  --surface: #161A1C;
  --raised: #1E2427;
  --raised-hi: #282F33;
  --ink: #ECEFEE;
  --ink-soft: #C3CACE;
  --ink-faint: #A7B0B5;
  --rule: #242A2E;
  --rule-soft: #1C2225;
  --accent: #D99A3E;
  --accent-ink: #1A1206;
  --accent-dim: #2E2413;
  --danger: #D9614A;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --fs-xs: 10px;
  --fs-sm: 11.5px;
  --fs-md: 13px;
  --fs-lg: 15px;
  --fs-xl: 19px;
  --pad: 14px;
  --r: 9px;
  --bar-h: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --t: 170ms;
  --ease-out: cubic-bezier(.2, 0, 0, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-lg);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; text-align: inherit; }
a { color: inherit; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
}

/* ---------- tab bar (phone) ---------- */
.navbar {
  flex: none;
  height: calc(var(--bar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  position: relative;
  z-index: 2;
  background: var(--surface);
  border-top: 1px solid var(--rule);
}
.navbar a {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 8px;
  gap: 2px;
  text-decoration: none;
  color: var(--ink-faint);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.navbar a svg { width: 21px; height: 21px; }
.navbar a[aria-current="page"] { color: var(--accent); }
.nav-brand, .navbar .nav-extra { display: none; }

/* Plan: the center hub, a little bigger and raised into the content. */
.navbar .nav-hub { position: relative; }
.hub-ring {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-top: -16px;
  border-radius: 50%;
  background: var(--raised-hi);
  color: var(--ink);
  box-shadow: 0 0 0 4px var(--surface);
  transition: background var(--t), transform 100ms;
}
.navbar .nav-hub svg { width: 24px; height: 24px; }
.navbar .nav-hub:active .hub-ring { transform: scale(.94); }
.navbar .nav-hub[aria-current="page"] .hub-ring { background: var(--accent); color: var(--accent-ink); }

/* ---------- screen ---------- */
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.screen.enter { animation: screen-in var(--t) var(--ease-out); }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) calc(var(--pad) - 6px) 6px var(--pad);
  border-bottom: 1px solid var(--rule-soft);
  background: var(--ground);
}
.topbar h1 {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.022em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background var(--t), transform 100ms;
}
.icon-btn:active { background: var(--raised); transform: scale(.94); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 17px; height: 17px; }
.topbar .icon-btn[data-back] { margin-left: -8px; }
.avatar-btn svg { width: 20px; height: 20px; padding: 6px; box-sizing: content-box; border-radius: 50%; background: var(--raised); }

/* Her sub-tabs: Profile · Cycle · Arguments */
.subtabs {
  flex: none;
  display: flex;
  gap: 3px;
  margin: 8px var(--pad) 0;
  padding: 3px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--rule);
}
.subtabs a {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 32px;
  border-radius: 6px;
  text-decoration: none;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--ink-soft);
  transition: background var(--t), color var(--t);
}
.subtabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

.banner {
  flex: none;
  padding: 7px var(--pad);
  font-size: var(--fs-md);
  color: #F2C7BE;
  background: #2A1712;
  border-bottom: 1px solid #3A2019;
}

.pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px var(--pad) 24px;
}

.empty { color: var(--ink-faint); font-size: var(--fs-md); padding: 6px 0; }
.empty-block { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding-top: 12px; }

.sec-head {
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
  padding: 4px 0;
}
.sec-row { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rule); }

/* ---------- ? help ---------- */
.help {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  vertical-align: 1px;
  border-radius: 50%;
  background: var(--raised);
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  position: relative;
}
.help::after { content: ""; position: absolute; inset: -12px; } /* bigger tap target, same look */
.help-pop {
  position: fixed;
  z-index: 40;
  max-width: min(280px, calc(100vw - 16px));
  padding: 8px 11px;
  border-radius: var(--r);
  background: var(--raised-hi);
  color: var(--ink);
  font-size: var(--fs-md);
  line-height: 1.35;
  box-shadow: 0 8px 24px -6px rgb(0 0 0 / .6);
  animation: fade-in var(--t) var(--ease-out);
}

/* ---------- rows ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule-soft);
  transition: background var(--t);
}
.row:active { background: var(--surface); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: var(--fs-md); color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { flex: none; font-size: var(--fs-md); font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.count.is-today { color: var(--accent); font-weight: 700; }
.count.is-past { color: var(--ink-faint); font-weight: 400; }
.row.is-holiday .row-title { font-weight: 400; color: var(--ink-soft); }

/* ---------- buttons and forms ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r);
  background: var(--raised);
  color: var(--ink);
  font-weight: 600;
  font-size: var(--fs-lg);
  transition: transform 100ms, background var(--t);
}
.btn:active { transform: scale(.97); background: var(--raised-hi); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:active { background: var(--accent); }
.btn-danger { color: var(--danger); }
.btn-danger.armed { background: var(--danger); color: #1A0805; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.btn-help { display: flex; align-items: center; gap: 8px; }
.btn-help .btn { flex: 1; }

.narrow { max-width: 420px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span, .switch-row > span { font-size: var(--fs-md); color: var(--ink-faint); font-weight: 600; }
.field input, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.field input[type="date"] { display: block; }
.field textarea { resize: vertical; line-height: 1.35; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.form-msg { min-height: 1.4em; font-size: var(--fs-md); color: var(--ink-faint); }
.form-msg.is-error { color: var(--danger); }

.seg { display: flex; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 36px; border-radius: 6px; text-align: center; font-size: var(--fs-md); font-weight: 600; color: var(--ink-soft); transition: background var(--t), color var(--t); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }

.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.switch-row > span { font-size: var(--fs-lg); color: var(--ink); font-weight: 400; }
.switch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 999px;
  background: var(--raised-hi);
  position: relative;
  cursor: pointer;
  transition: background var(--t);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .4);
  transition: transform var(--t) var(--ease-out);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- editor: full screen on a phone ---------- */
.editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--ground);
  animation: fade-in var(--t) var(--ease-out);
}
.editor-backdrop.leaving { opacity: 0; transition: opacity 150ms; pointer-events: none; }
.editor { height: 100%; display: flex; flex-direction: column; animation: editor-in 220ms var(--ease-out); }
@keyframes editor-in { from { transform: translateY(16px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.editor-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) var(--pad) 6px;
  border-bottom: 1px solid var(--rule-soft);
}
.editor-head h2 { flex: 1; text-align: center; font-size: var(--fs-lg); font-weight: 700; }
.link-btn { min-height: 40px; padding: 0 4px; color: var(--ink-soft); font-size: var(--fs-lg); }
.link-btn.strong { color: var(--accent); font-weight: 700; }
.editor .form { flex: 1; min-height: 0; overflow-y: auto; padding: 14px var(--pad) 24px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + var(--safe-b) + 12px);
  transform: translateX(-50%);
  z-index: 30;
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border-radius: var(--r);
  background: var(--raised-hi);
  font-size: var(--fs-md);
  animation: fade-in var(--t) var(--ease-out);
}

/* ---------- laptop: sidebar, bigger text, wider panes ---------- */
@media (min-width: 860px) {
  :root { --pad: 28px; --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 24px; }
  #app { flex-direction: row; }
  .navbar {
    height: auto;
    width: 220px;
    flex-direction: column;
    gap: 2px;
    padding: 20px 10px;
    border-top: 0;
    border-right: 1px solid var(--rule);
  }
  .navbar a {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 7px;
    font-size: var(--fs-lg);
  }
  .navbar a[aria-current="page"] { background: var(--accent-dim); }
  .nav-brand { display: block; padding: 2px 12px 14px; font-weight: 700; font-size: var(--fs-lg); }
  .navbar .nav-extra { display: flex; }
  .navbar .nav-first-extra { margin-top: auto; }
  .hub-ring { width: auto; height: auto; margin: 0; background: none; box-shadow: none; color: inherit; }
  .navbar .nav-hub svg { width: 21px; height: 21px; }
  .navbar .nav-hub[aria-current="page"] .hub-ring { background: none; color: inherit; }
  .topbar { min-height: 60px; }
  .topbar .avatar-btn, .topbar .phone-only { display: none; }
  .topbar .icon-btn[data-back] { display: none; }
  .subtabs { max-width: 420px; margin-top: 12px; }
  .pane { padding-top: 16px; }
  .narrow { max-width: 460px; }

  .editor-backdrop { background: rgb(0 0 0 / .55); display: grid; place-items: center; }
  .editor {
    width: 460px;
    height: auto;
    max-height: calc(100dvh - 80px);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 16px 36px -8px rgb(0 0 0 / .6);
    overflow: hidden;
  }
  .editor-head { padding-top: 6px; }
  .field input, .field textarea { background: var(--ground); }
  .toast { bottom: 24px; }
}

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