/* Two themes share this file:
   .theme-comic — home, about, blog: ink outlines, hard offset shadows, halftone paper,
                  hand-lettered display type, to match the home illustration.
   .theme-plain — calendar, dashboard: quiet, readable, functional. */

:root {
  /* comic */
  --ink: #16140f;
  --paper: #f5ecd7;
  --white: #fffdf7;
  --sky: #3f86d4;
  --red: #d4432c;
  --yellow: #ffd63a;
  --leaf: #5e8b3b;
  --muted: #5b564c;
  --shadow: 6px 6px 0 var(--ink);
  --display: "Bangers", "Impact", sans-serif;
  --body: "Nunito", system-ui, sans-serif;
  --halftone: radial-gradient(circle, rgba(22, 20, 15, .13) 1.1px, transparent 1.6px);

  /* plain */
  --p-bg: #f4f5f7;
  --p-surface: #ffffff;
  --p-text: #1d2230;
  --p-muted: #5d6474;
  --p-border: #dde1e8;
  --p-hover: #eef0f4;
  --p-accent: #2f6fdb;
  --p-accent-dark: #2459b3;
  --p-accent-soft: #e7effc;
  --p-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --topbar-h: 92px;
}
.theme-plain { --topbar-h: 64px; }
@media (max-width: 760px) {
  :root, .theme-plain { --topbar-h: 68px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
.theme-comic {
  font-family: var(--body);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--halftone);
  background-size: 11px 11px;
}
.theme-plain {
  font-family: var(--p-font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--p-text);
  background: var(--p-bg);
}

img { max-width: 100%; height: auto; display: block; }

/* =====================================================================
   Top bar: app icons (desktop) / menu button (mobile) + account control
   ===================================================================== */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px;
}
.theme-comic .topbar {
  background-color: var(--paper);
  background-image: var(--halftone);
  background-size: 11px 11px;
  border-bottom: 3px solid var(--ink);
}
.theme-plain .topbar {
  background: var(--p-surface);
  border-bottom: 1px solid var(--p-border);
}

.account { position: relative; margin-left: auto; }

.app-nav { display: flex; align-items: center; gap: 6px; }
.topbar .nav-toggle { display: none; }

@media (max-width: 760px) {
  .app-nav { display: none; }
  .topbar .nav-toggle { display: grid; }
}

.app-link {
  text-decoration: none;
  color: inherit;
}
.app-icon { display: grid; place-items: center; flex: none; }

/* comic nav: round ink buttons with a lettered caption */
.theme-comic .app-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
}
.theme-comic .app-icon {
  width: 46px;
  height: 46px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s ease, box-shadow .1s ease, background-color .15s ease;
}
.theme-comic .app-label {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: .06em;
  line-height: 1;
}
.theme-comic .app-link:hover .app-icon { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); background: var(--yellow); }
.theme-comic .app-link[aria-current="page"] .app-icon { background: var(--sky); color: var(--white); }
.theme-comic .app-link:focus-visible { outline: none; }
.theme-comic .app-link:focus-visible .app-icon { outline: 3px solid var(--sky); outline-offset: 3px; }

/* plain nav: quiet tabs */
.theme-plain .app-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--p-muted);
  border-radius: 8px;
}
.theme-plain .app-icon svg { width: 20px; height: 20px; }
.theme-plain .app-link:hover { background: var(--p-hover); color: var(--p-text); }
.theme-plain .app-link[aria-current="page"] { background: var(--p-accent-soft); color: var(--p-accent); }
.theme-plain .app-link:focus-visible { outline: 2px solid var(--p-accent); outline-offset: 2px; }

/* Round icon buttons: account, menu toggle, drawer close */
.icon-btn {
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.theme-comic .icon-btn {
  width: 50px;
  height: 50px;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .1s ease, box-shadow .1s ease, background-color .15s ease;
}
.theme-comic .icon-btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); background: var(--yellow); }
.theme-comic .icon-btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.theme-comic .icon-btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.theme-comic .icon-btn[aria-expanded="true"] { background: var(--yellow); }

.theme-plain .icon-btn {
  width: 40px;
  height: 40px;
  color: var(--p-text);
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 50%;
}
.theme-plain .icon-btn svg { width: 22px; height: 22px; }
.theme-plain .icon-btn:hover, .theme-plain .icon-btn[aria-expanded="true"] { background: var(--p-hover); }
.theme-plain .icon-btn:focus-visible { outline: 2px solid var(--p-accent); outline-offset: 2px; }

/* Account dropdown */
.menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 240px;
  padding: 8px;
}
.menu-who { margin: 4px 8px 10px; font-size: .9rem; overflow-wrap: anywhere; }
.menu form { margin: 0; padding-top: 6px; }
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 8px;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}
.theme-comic .menu { background: var(--white); border: 3px solid var(--ink); box-shadow: var(--shadow); }
.theme-comic .menu-who { color: var(--muted); }
.theme-comic .menu-who strong { color: var(--ink); }
.theme-comic .menu form { border-top: 2px dashed var(--ink); }
.theme-comic .menu-item { font: 800 1rem var(--body); color: var(--ink); }
.theme-comic .menu-item:hover, .theme-comic .menu-item:focus-visible { background: var(--yellow); outline: none; }

.theme-plain .menu { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 30, 50, .15); }
.theme-plain .menu-who { color: var(--p-muted); }
.theme-plain .menu-who strong { color: var(--p-text); }
.theme-plain .menu form { border-top: 1px solid var(--p-border); }
.theme-plain .menu-item { font: 600 .95rem var(--p-font); color: var(--p-text); border-radius: 6px; }
.theme-plain .menu-item:hover, .theme-plain .menu-item:focus-visible { background: var(--p-hover); outline: none; }

/* =====================================================================
   Mobile app menu (slide-in drawer)
   ===================================================================== */

.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(320px, 86vw);
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
}
.drawer[open] { animation: slide-in .2s ease-out; }
@keyframes slide-in { from { transform: translateX(-100%); } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 16px;
}
.drawer-nav { display: flex; flex-direction: column; gap: 6px; padding: 12px; }
.drawer-link { display: flex; align-items: center; gap: 14px; padding: 10px 8px; text-decoration: none; color: inherit; }

.theme-comic .drawer {
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--halftone);
  background-size: 11px 11px;
  border-right: 4px solid var(--ink);
  box-shadow: 8px 0 0 var(--ink);
}
.theme-comic .drawer::backdrop { background: rgba(22, 20, 15, .5); }
.theme-comic .drawer-head { border-bottom: 3px solid var(--ink); }
.theme-comic .drawer-title { font-family: var(--display); font-size: 2rem; letter-spacing: .05em; }
.theme-comic .drawer-link .app-label { font-family: var(--display); font-size: 1.8rem; letter-spacing: .05em; line-height: 1; }
.theme-comic .drawer-link:hover .app-icon { background: var(--yellow); }
.theme-comic .drawer-link[aria-current="page"] .app-label { text-decoration: underline 3px; text-underline-offset: 5px; }

.theme-plain .drawer { color: var(--p-text); background: var(--p-surface); box-shadow: 0 0 40px rgba(20, 30, 50, .25); }
.theme-plain .drawer::backdrop { background: rgba(15, 20, 30, .4); }
.theme-plain .drawer-head { border-bottom: 1px solid var(--p-border); }
.theme-plain .drawer-title { font-weight: 700; font-size: 1.1rem; }
.theme-plain .drawer-link { border-radius: 8px; font-weight: 600; font-size: 1.05rem; color: var(--p-muted); }
.theme-plain .drawer-link:hover { background: var(--p-hover); color: var(--p-text); }
.theme-plain .drawer-link[aria-current="page"] { background: var(--p-accent-soft); color: var(--p-accent); }

/* =====================================================================
   Comic components
   ===================================================================== */

.panel {
  margin: 0;
  background: var(--white);
  border: 4px solid var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
}

.title {
  margin: 0 0 .35em;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(4rem, 11vw, 8.5rem);
  line-height: .88;
  letter-spacing: .02em;
  color: var(--yellow);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 7px 7px 0 var(--ink);
  transform: rotate(-3deg);
}

.btn {
  display: inline-block;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}
.theme-comic .btn {
  padding: .4em 1.05em .32em;
  font-family: var(--display);
  font-size: 1.65rem;
  letter-spacing: .05em;
  line-height: 1.1;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform .1s ease, box-shadow .1s ease;
}
.theme-comic .btn:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.theme-comic .btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.theme-comic .btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 4px; }
.theme-comic .btn-sky { background: var(--sky); color: var(--white); }
.theme-comic .btn-red { background: var(--red); color: var(--white); }
.theme-comic .btn-yellow { background: var(--yellow); }

/* The "Leave Constructive Criticism" button that runs away. */
.dodge {
  touch-action: none;
  transform: rotate(var(--tilt, 0deg));
}
.theme-comic .dodge:hover, .theme-comic .dodge:active { transform: rotate(var(--tilt, 0deg)); box-shadow: 5px 5px 0 var(--ink); }
.dodge.loose {
  position: fixed;
  z-index: 40;
  margin: 0;
  white-space: nowrap;
  transition: left .35s cubic-bezier(.34, 1.56, .64, 1), top .35s cubic-bezier(.34, 1.56, .64, 1), transform .35s ease;
}
.dodge-placeholder { display: inline-block; visibility: hidden; }

.bubble {
  position: relative;
  margin: 0;
  padding: .7em 1.1em .6em;
  font-family: var(--display);
  font-size: clamp(2rem, 6vw, 3.1rem);
  line-height: 1.05;
  letter-spacing: .03em;
  text-align: center;
  background: var(--white);
  border: 4px solid var(--ink);
  border-radius: 48% / 42%;
  box-shadow: var(--shadow);
  transform: rotate(-2deg);
}
/* Tail: an ink triangle with a white one inside it. */
.bubble::before, .bubble::after {
  content: "";
  position: absolute;
  left: 58%;
  border-style: solid;
  border-color: transparent;
}
.bubble::before { top: 100%; border-width: 34px 10px 0 26px; border-top-color: var(--ink); margin-top: 1px; }
.bubble::after  { top: 100%; border-width: 25px 7px 0 19px; border-top-color: var(--white); margin: -3px 0 0 5px; }

/* ---------- Home ---------- */

.home {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(32px, 6vw, 88px);
  max-width: 1120px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 32px) 32px 56px;
}

/* The panel is sized so the whole image always fits: the smallest of 480px,
   the column width, and the height available (times the image's 3:4 ratio). */
.panel-hero {
  justify-self: end;
  width: min(480px, 100%, calc((100dvh - var(--topbar-h) - 110px) * .749));
  transform: rotate(-2deg);
}
.panel-hero img { width: 100%; }

.actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 22px;
  padding-left: 8px;
}

@media (max-width: 760px) {
  .home {
    grid-template-columns: 1fr;
    justify-items: center;
    align-content: start;
    gap: 28px;
    padding: calc(var(--topbar-h) + 24px) 20px 40px;
    text-align: center;
  }
  .panel-hero { justify-self: center; width: min(360px, 100%, calc(44dvh * .749)); }
  .home-text { display: flex; flex-direction: column; align-items: center; }
  .title { font-size: clamp(3.4rem, 17vw, 4.6rem); margin-bottom: .3em; }
  .actions { align-items: center; padding-left: 0; gap: 18px; }
  .theme-comic .btn { font-size: 1.45rem; }
}

/* ---------- About & Blog ---------- */

.about, .blog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 44px;
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 40px) 20px 56px;
  text-align: center;
}
.blog .title { font-size: clamp(3.4rem, 10vw, 6.5rem); margin: 0; }

.panel-small { width: min(320px, 80vw); transform: rotate(2deg); }

/* ---------- Cards: verify, members-only ---------- */

.verify, .denied {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--topbar-h) + 24px) 20px 48px;
}
.theme-comic .card, .panel-card {
  max-width: 440px;
  padding: 28px 32px 32px;
  text-align: center;
  background: var(--white);
  border: 4px solid var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
}
.theme-comic .card h1, .panel-card h1 { margin: 0 0 .3em; font-family: var(--display); font-weight: 400; font-size: 2.6rem; letter-spacing: .04em; }
.theme-comic .card p, .panel-card p { margin: 0 0 1.4em; overflow-wrap: anywhere; }

/* =====================================================================
   Plain components
   ===================================================================== */

.plain-page {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 32px) 24px 48px;
}
.plain-page h1 { margin: 0 0 20px; font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; }

.theme-plain .card {
  padding: 24px;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(20, 30, 50, .05);
}
.theme-plain .card p { margin: 0; }
.theme-plain .denied .card { max-width: 420px; text-align: center; }
.theme-plain .denied .card h1 { margin: 0 0 8px; font-size: 1.4rem; }
.theme-plain .denied .card p { margin-bottom: 20px; color: var(--p-muted); }

.theme-plain .btn {
  padding: .6em 1.2em;
  font: 600 1rem var(--p-font);
  color: #fff;
  background: var(--p-accent);
  border: 1px solid var(--p-accent);
  border-radius: 8px;
}
.theme-plain .btn:hover { background: var(--p-accent-dark); border-color: var(--p-accent-dark); }
.theme-plain .btn:focus-visible { outline: 2px solid var(--p-accent); outline-offset: 2px; }

/* ---------- Plain: page furniture ---------- */

.plain-wide { max-width: 1200px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--p-muted); }
.hint { margin: -4px 0 12px; font-size: .9rem; color: var(--p-muted); }

.crumbs { margin-bottom: 6px; font-size: .9rem; color: var(--p-muted); }
.crumbs a { color: var(--p-accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.flash {
  margin: 0 0 20px;
  padding: 10px 14px;
  color: #1d5b2c;
  background: #e6f4ea;
  border: 1px solid #b9dfc3;
  border-radius: 8px;
}
.errors {
  margin: 0 0 20px;
  padding: 10px 14px;
  color: #8a1f17;
  background: #fdecea;
  border: 1px solid #f5c2bd;
  border-radius: 8px;
}
.errors p { margin: 0; }
.errors p + p { margin-top: 4px; }

.empty { text-align: center; }
.theme-plain .empty p { margin-bottom: 14px; color: var(--p-muted); }

.list-foot { margin-top: 16px; font-size: .9rem; }
.list-foot a { color: var(--p-muted); }

/* Lists overview */
.list-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.list-card { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.list-card:hover { border-color: var(--p-accent); box-shadow: 0 2px 8px rgba(20, 30, 50, .08); }
.list-card-name { font-weight: 700; font-size: 1.05rem; }
.list-card .muted { font-size: .9rem; }

/* Buttons */
.theme-plain .btn-secondary { color: var(--p-text); background: var(--p-surface); border-color: var(--p-border); }
.theme-plain .btn-secondary:hover { background: var(--p-hover); border-color: var(--p-border); }
.theme-plain .btn-danger { color: #b3261e; background: var(--p-surface); border-color: #f0b8b3; }
.theme-plain .btn-danger:hover { color: #fff; background: #b3261e; border-color: #b3261e; }
.link-btn { padding: 0; font: inherit; color: var(--p-accent); background: none; border: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Plain: forms ---------- */

.form h2 { margin: 28px 0 8px; font-size: 1.1rem; }
.form h2:first-child { margin-top: 0; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 6px; font-weight: 600; font-size: .95rem; }
.theme-plain input[type="text"], .theme-plain input[type="number"], .theme-plain select {
  width: 100%;
  padding: 9px 11px;
  font: 1rem var(--p-font);
  color: var(--p-text);
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 8px;
}
.theme-plain input:focus, .theme-plain select:focus { outline: none; border-color: var(--p-accent); box-shadow: 0 0 0 3px var(--p-accent-soft); }
.theme-plain input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--p-accent); }

.field > .hint { display: block; margin: 6px 0 0; font-weight: 400; }
.field > .slug-input {
  display: flex;
  align-items: stretch;
  margin: 0;
  font-weight: 400;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 8px;
}
.field > .slug-input:focus-within { border-color: var(--p-accent); box-shadow: 0 0 0 3px var(--p-accent-soft); }
.slug-prefix { display: flex; align-items: center; padding: 0 2px 0 11px; color: var(--p-muted); white-space: nowrap; }
.theme-plain .slug-input input[type="text"] { min-width: 0; padding-left: 0; border: 0; box-shadow: none; }
@media (max-width: 560px) {
  .slug-prefix { font-size: .85rem; }
}

.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-weight: 600; font-size: .95rem; cursor: pointer; }
.confirm { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding: 10px 12px; font-weight: 600; background: #fff6e0; border: 1px solid #f0d58c; border-radius: 8px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.meta { margin: 4px 0 0; font-size: .9rem; }

.danger-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 24px; }
.danger-zone .muted { font-size: .9rem; }

/* List definition: field rows */
.field-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) 130px 80px; align-items: center; gap: 8px; }
.field-row-head { font-size: .8rem; font-weight: 600; color: var(--p-muted); text-transform: uppercase; letter-spacing: .04em; }
.f-remove { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--p-muted); }
.f-remove.link-btn { color: var(--p-muted); }

.share-rows { display: flex; flex-direction: column; gap: 8px; }
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 12px; }
.share-row > span { overflow-wrap: anywhere; }

@media (max-width: 560px) {
  .field-row { grid-template-columns: 56px minmax(0, 1fr); }
  .field-row .f-type { grid-column: 2; }
  .field-row .f-remove { grid-column: 2; }
  .field-row-head { display: none; }
  .field-row + .field-row { padding-top: 10px; border-top: 1px solid var(--p-border); }
  .share-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- Plain: items table ---------- */

.table-wrap { overflow-x: auto; background: var(--p-surface); border: 1px solid var(--p-border); border-radius: 12px; }
.items { width: 100%; border-collapse: collapse; font-size: .95rem; }
.items th, .items td { padding: 10px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--p-border); }
.items th { font-size: .8rem; font-weight: 600; color: var(--p-muted); text-transform: uppercase; letter-spacing: .04em; background: #fafbfc; }
.items tbody tr:last-child td { border-bottom: 0; }
.items tbody tr:hover { background: #fafbfc; }
.items tbody tr:target { background: var(--p-accent-soft); }
.items .col-number { text-align: right; font-variant-numeric: tabular-nums; }
.items .col-bool { width: 1%; text-align: center; }
.items .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.items .col-edit { padding-top: 4px; padding-bottom: 4px; }
.edit-link {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--p-muted);
  border-radius: 8px;
  vertical-align: middle;
}
.edit-link:hover { color: var(--p-accent); background: var(--p-accent-soft); }
.edit-link:focus-visible { outline: 2px solid var(--p-accent); outline-offset: 1px; }
.items .col-actions .muted { margin-right: 8px; font-size: .85rem; }
.items form { margin: 0; }
.items form.inline { display: inline; }

.check {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  font: 700 15px/1 var(--p-font);
  color: #fff;
  background: var(--p-surface);
  border: 2px solid #b9c0cc;
  border-radius: 6px;
  vertical-align: middle;
}
button.check { cursor: pointer; }
button.check:hover { border-color: var(--p-accent); }
.check.on { background: var(--p-accent); border-color: var(--p-accent); }

/* Phones: each item becomes a small card with labelled values. */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; background: none; border: 0; }
  .items thead { display: none; }
  .items, .items tbody, .items tr, .items td { display: block; width: auto; }
  .items tr { margin-bottom: 10px; padding: 6px 0; background: var(--p-surface); border: 1px solid var(--p-border); border-radius: 12px; }
  .items tbody tr:hover { background: var(--p-surface); }
  .items td { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 14px; border: 0; }
  .items td::before { content: attr(data-label); font-size: .8rem; font-weight: 600; color: var(--p-muted); text-transform: uppercase; letter-spacing: .04em; }
  .items .col-bool, .items .col-actions { width: auto; }
  /* The first field is the card's heading: no label, bigger and bolder. */
  .items .col-primary { padding-top: 8px; padding-bottom: 8px; font-size: 1.08rem; font-weight: 700; text-align: left; justify-content: flex-start; }
  .items .col-primary::before { content: none; }
  .items .col-number, .items .col-actions { text-align: right; }
  .items .col-actions { justify-content: flex-end; }
  .items .col-actions::before { content: none; }
  /* Edit icon sits in the card's top-right corner, beside the heading. */
  .items tr { position: relative; }
  .items td.col-edit { position: absolute; top: 4px; right: 4px; padding: 0; }
  .items tr:has(.col-edit) .col-primary { padding-right: 48px; }
}

/* ---------- Plain: calendar ---------- */

/* Person colors: background / text. p-0 = no person. */
.p-0 { --pc-bg: #eef0f4; --pc-fg: #3d4452; }
.p-1 { --pc-bg: #e3edfd; --pc-fg: #1f4fa8; }
.p-2 { --pc-bg: #e2f3e7; --pc-fg: #1d6b36; }
.p-3 { --pc-bg: #fdeadb; --pc-fg: #9a4a0b; }
.p-4 { --pc-bg: #eee6fb; --pc-fg: #5b2fa0; }
.p-5 { --pc-bg: #dcf2f2; --pc-fg: #11676a; }
.p-6 { --pc-bg: #fbe3ee; --pc-fg: #9b1f55; }
.p-7 { --pc-bg: #faf0cc; --pc-fg: #6f5500; }

.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav h2 { min-width: 9.5em; margin: 0; font-size: 1.25rem; text-align: center; }
.theme-plain .btn-icon { padding: .45em .8em; font-size: 1.15rem; line-height: 1; }

.people { display: flex; flex-wrap: wrap; gap: 6px; }
.person-chip {
  display: inline-block;
  padding: 3px 10px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--pc-fg, var(--p-text));
  background: var(--pc-bg, var(--p-surface));
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
}
.people .person-chip:not([class*="p-"]) { border-color: var(--p-border); }
.people .person-chip:hover { border-color: var(--pc-fg, var(--p-accent)); }
.people .person-chip.is-active { color: #fff; background: var(--pc-fg, var(--p-accent)); }

.cal-grid { width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--p-surface); border: 1px solid var(--p-border); border-radius: 12px; overflow: hidden; }
.cal-grid th { padding: 8px; font-size: .8rem; font-weight: 600; color: var(--p-muted); text-transform: uppercase; letter-spacing: .04em; background: #fafbfc; border-bottom: 1px solid var(--p-border); }
.cal-grid td { height: 112px; padding: 4px 4px 6px; vertical-align: top; border: 1px solid var(--p-border); }
.cal-grid td.other-month { background: #fafbfc; }
.cal-grid td.other-month .cal-num { color: #a3a9b5; }
.cal-day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.cal-num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px; font-size: .85rem; font-weight: 600; border-radius: 13px; }
.is-today .cal-num { color: #fff; background: var(--p-accent); }
.cal-add { width: 24px; height: 24px; display: grid; place-items: center; font-size: 1.1rem; color: var(--p-muted); text-decoration: none; border-radius: 6px; opacity: 0; transition: opacity .1s; }
.cal-grid td:hover .cal-add, .cal-add:focus-visible { opacity: 1; }
.cal-add:hover { color: var(--p-accent); background: var(--p-accent-soft); }
.cal-event {
  display: block;
  margin-top: 3px;
  padding: 2px 6px;
  overflow: hidden;
  font-size: .8rem;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--pc-fg);
  background: var(--pc-bg);
  border-radius: 5px;
  text-decoration: none;
}
.cal-event:hover { filter: brightness(.96); }
.cal-event:target { outline: 2px solid var(--pc-fg); }
.cal-time { font-weight: 700; }

.cal-agenda { display: none; }
.agenda-day { margin-bottom: 16px; }
.agenda-day h3 { margin: 0 0 6px; font-size: .9rem; color: var(--p-muted); text-transform: uppercase; letter-spacing: .04em; }
.agenda-day.is-today h3 { color: var(--p-accent); }
.agenda-event {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  padding: 10px 12px;
  color: var(--p-text);
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-left: 4px solid var(--pc-fg);
  border-radius: 10px;
  text-decoration: none;
}
.agenda-time { flex: none; width: 4.2em; font-size: .9rem; font-weight: 600; color: var(--pc-fg); }
.agenda-main { display: flex; flex-direction: column; min-width: 0; }
.agenda-main .muted { font-size: .9rem; }

@media (max-width: 760px) {
  .cal-grid { display: none; }
  .cal-agenda { display: block; }
  .cal-nav h2 { min-width: 0; font-size: 1.1rem; }
}

.trash-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.trash-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 12px 16px; }
.trash-list li > div { display: flex; flex-direction: column; flex: 1 1 240px; }
.trash-list form { margin: 0; }

.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 420px) { .field-pair { grid-template-columns: 1fr; } }
.optional { font-weight: 400; color: var(--p-muted); }
.theme-plain input[type="date"], .theme-plain input[type="time"], .theme-plain textarea {
  width: 100%;
  padding: 9px 11px;
  font: 1rem var(--p-font);
  color: var(--p-text);
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 8px;
}
.theme-plain textarea { resize: vertical; line-height: 1.45; }
.theme-plain textarea:focus { outline: none; border-color: var(--p-accent); box-shadow: 0 0 0 3px var(--p-accent-soft); }

.annual-mark { font-weight: 700; opacity: .75; }

.options { margin: 4px 0 0; padding: 0; border: 0; }
.options legend { margin-bottom: 8px; padding: 0; font-weight: 600; font-size: .95rem; }
.option { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; cursor: pointer; }
.option input[type="checkbox"] { margin-top: 3px; flex: none; }
.option strong { font-weight: 600; font-size: .95rem; }
.option .hint { display: block; margin: 2px 0 0; }

.event-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0 0 16px; }
.event-details dt { font-weight: 600; color: var(--p-muted); }
.event-details dd { margin: 0; }

/* ---------- Plain: small controls shared by apps ---------- */

.small-btn { padding: 3px 9px; font: 600 .8rem var(--p-font); color: var(--p-muted); background: var(--p-surface); border: 1px solid var(--p-border); border-radius: 6px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.small-btn:hover { color: var(--p-text); background: var(--p-hover); }
.icon-only { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; padding: 0; color: var(--p-muted); background: none; border: 0; border-radius: 6px; cursor: pointer; }
.icon-only:hover { color: var(--p-accent); background: var(--p-accent-soft); }
.icon-only.danger:hover { color: #b3261e; background: #fdecea; }
.tag { display: inline-block; padding: 1px 8px; font-size: .75rem; font-weight: 600; color: var(--p-muted); background: var(--p-hover); border-radius: 999px; white-space: nowrap; }
.tag-warn { color: #9a4a0b; background: #fdeadb; }
.tag-blue { color: #1f4fa8; background: #e3edfd; }
.tag-green { color: #1d6b36; background: #e2f3e7; }
.tag-purple { color: #5b2fa0; background: #eee6fb; }
.empty-note { padding: 10px 0; font-size: .9rem; color: var(--p-muted); }
.dash-list { margin: 0; padding: 0; list-style: none; }

.theme-plain .modal .btn { width: auto; }
.modal .form-actions { margin-top: 16px; }
.modal .form-actions .spacer { flex: 1; }
.modal textarea { min-height: 90px; }

/* Date-range filter */
.range { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin: 0 0 16px; padding: 12px 16px; }
.range label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--p-muted); }
.range input { width: auto; }
.range .quick { display: flex; gap: 6px; margin-left: auto; }
.range .btn { padding: .45em 1em; }

/* ---------- Plain: logs (food, exercise) ---------- */

.log-entry { display: grid; grid-template-columns: minmax(0, 2fr) repeat(var(--cols, 2), minmax(0, 1fr)) auto; align-items: end; gap: 12px; }
.log-entry .field { margin: 0; min-width: 0; }
.log-entry input, .log-entry select { height: 41px; width: 100%; min-width: 0; }
.log-entry .btn { height: 41px; }
@media (max-width: 760px) {
  .log-entry { grid-template-columns: 1fr 1fr; }
  .log-entry .field:first-child { grid-column: 1 / -1; }
  .log-entry .btn { grid-column: 1 / -1; }
}
.log-today { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 16px 0 24px; }
.stat { display: flex; flex-direction: column; }
.stat strong { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .85rem; color: var(--p-muted); }
.log-day { margin-bottom: 16px; padding: 4px 16px; }
.log-day h3 { display: flex; justify-content: space-between; margin: 10px 0 4px; font-size: .95rem; }
.log-day h3 span { color: var(--p-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.log-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-top: 1px solid var(--p-border); }
.log-row:target { background: var(--p-accent-soft); }
.log-time { width: 4.5em; flex: none; font-size: .85rem; color: var(--p-muted); }
.log-desc { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.log-desc .tag { margin-left: 6px; }
.log-val { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.log-row form { margin: 0; }

/* Exercise category editor */
.theme-plain .modal.modal-wide { width: min(800px, calc(100vw - 32px)); }
.cat-table select { width: auto; min-width: 96px; }
@media (min-width: 561px) { .cat-types { flex-wrap: nowrap; } }
.cat-wrap { border-radius: 8px; }
.cat-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.cat-table th { padding: 6px; font-size: .75rem; font-weight: 600; color: var(--p-muted); text-align: left; text-transform: uppercase; }
.cat-table td { padding: 4px 6px; vertical-align: middle; }
.cat-table td:first-child { min-width: 140px; }
.cat-types { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: .85rem; }
.cat-types label, .cat-archived label { display: flex; align-items: center; gap: 4px; white-space: nowrap; cursor: pointer; font-size: .85rem; }
.cat-types input, .cat-archived input { width: 16px; height: 16px; }
@media (max-width: 560px) {
  .cat-table thead { display: none; }
  .cat-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--p-border); }
  .cat-table td { padding: 0; }
  .cat-table td:first-child, .cat-table td.cat-types { grid-column: 1 / -1; }
}

/* ---------- Plain: AI assistants page ---------- */

.intro { max-width: 680px; margin: -8px 0 24px; }
.section-title { margin: 32px 0 12px; font-size: 1.15rem; }
.theme-plain code { padding: 1px 5px; font: .9em ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--p-hover); border-radius: 4px; overflow-wrap: anywhere; }
.token-card { margin-bottom: 20px; background: #fffbea; border-color: #f0d58c; }
.token-card h2, .setup-card h2 { margin: 0 0 8px; font-size: 1.1rem; }
.token-card p { margin: 0 0 12px; }
.copy-row { display: flex; gap: 8px; }
.theme-plain .copy-row input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9rem; }
.setup { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
.setup dt { font-weight: 600; }
.setup dd { margin: 0; }
@media (max-width: 560px) {
  .setup { grid-template-columns: 1fr; gap: 2px; }
  .setup dd { margin-bottom: 10px; }
  .copy-row { flex-direction: column; }
}
.assistants tr.revoked td { color: var(--p-muted); }
.link-btn.danger { color: #b3261e; }
.scopes { margin: 0 0 4px; padding: 0; border: 0; }
.scopes legend { margin-bottom: 10px; padding: 0; font-weight: 600; font-size: .95rem; }
.scopes .switch { font-weight: 400; margin-bottom: 10px; }
.scope-edit { margin-top: 6px; }
.scope-edit summary { display: inline; font-size: .9rem; color: var(--p-accent); cursor: pointer; }
.scope-edit form { margin-top: 10px; }
.scope-edit .switch { margin-bottom: 8px; font-weight: 400; }

.role-badge { display: inline-block; padding: 2px 9px; font-size: .8rem; font-weight: 600; border-radius: 999px; color: var(--p-muted); background: var(--p-hover); }
.role-josh { color: #fff; background: var(--p-accent); }
.role-family { color: #1d6b36; background: #e2f3e7; }
.role-friend { color: #9a4a0b; background: #fdeadb; }

.menu a.menu-item { text-decoration: none; }
.theme-comic .menu a.menu-item { color: var(--ink); }

/* =====================================================================
   Sign-in modal
   ===================================================================== */

.modal {
  width: min(430px, calc(100vw - 32px));
  padding: 0;
}
.modal[open] { animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.92) rotate(-1deg); opacity: 0; } }

.modal-body { position: relative; padding: 26px 28px 28px; }
.modal h2 { margin: 0 0 .5em; line-height: 1; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.modal label { display: block; margin-bottom: 6px; }
.modal input[type="email"] {
  display: block;
  width: 100%;
  margin-bottom: 20px;
  padding: 12px 14px;
  font-size: 1.1rem; /* >=16px so iOS doesn't zoom */
}
.modal .btn { width: 100%; }
.modal .btn:disabled { opacity: .6; cursor: wait; }
.modal-status:empty { display: none; }
.modal-status { margin: 18px 0 0; font-weight: 700; overflow-wrap: anywhere; }

.local-users { margin-top: 20px; padding-top: 14px; }
.local-users p { margin: 0 0 8px; font-size: .9rem; }
.local-user {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  margin-top: 6px;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
}
.local-user span { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }

.theme-comic .modal { color: var(--ink); background: var(--white); border: 4px solid var(--ink); box-shadow: 10px 10px 0 var(--ink); }
.theme-comic .modal::backdrop {
  background-color: rgba(22, 20, 15, .55);
  background-image: radial-gradient(circle, rgba(22, 20, 15, .35) 1.1px, transparent 1.6px);
  background-size: 9px 9px;
}
.theme-comic .modal h2 { font-family: var(--display); font-weight: 400; font-size: 2.4rem; letter-spacing: .04em; }
.theme-comic .modal-close:hover { color: var(--red); }
.theme-comic .modal label { font-weight: 800; }
.theme-comic .modal input[type="email"] { font-family: var(--body); color: var(--ink); background: var(--white); border: 3px solid var(--ink); border-radius: 0; }
.theme-comic .modal input[type="email"]:focus { outline: none; box-shadow: 0 0 0 3px var(--sky); }
.theme-comic .modal-status[data-state="error"] { color: var(--red); }
.theme-comic .local-users { border-top: 2px dashed var(--ink); }
.theme-comic .local-users p { color: var(--muted); }
.theme-comic .local-user { font: 700 .95rem var(--body); color: var(--ink); background: #fff6c9; border: 2px solid var(--ink); }
.theme-comic .local-user:hover { background: var(--yellow); }
.theme-comic .local-user span { color: var(--muted); }

.theme-plain .modal { color: var(--p-text); background: var(--p-surface); border: 1px solid var(--p-border); border-radius: 14px; box-shadow: 0 24px 60px rgba(20, 30, 50, .25); }
.theme-plain .modal::backdrop { background: rgba(15, 20, 30, .45); }
.theme-plain .modal[open] { animation-name: fade; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.theme-plain .modal h2 { font-size: 1.4rem; font-weight: 700; }
.theme-plain .modal-close { color: var(--p-muted); border-radius: 50%; }
.theme-plain .modal-close:hover { background: var(--p-hover); color: var(--p-text); }
.theme-plain .modal label { font-weight: 600; font-size: .95rem; }
.theme-plain .modal input[type="email"] { font-family: var(--p-font); color: var(--p-text); background: var(--p-surface); border: 1px solid var(--p-border); border-radius: 8px; }
.theme-plain .modal input[type="email"]:focus { outline: none; border-color: var(--p-accent); box-shadow: 0 0 0 3px var(--p-accent-soft); }
.theme-plain .modal-status { font-weight: 600; }
.theme-plain .modal-status[data-state="error"] { color: #c0392b; }
.theme-plain .local-users { border-top: 1px solid var(--p-border); }
.theme-plain .local-users p { color: var(--p-muted); }
.theme-plain .local-user { font: 600 .95rem var(--p-font); color: var(--p-text); background: #f7f8fa; border: 1px solid var(--p-border); border-radius: 8px; }
.theme-plain .local-user:hover { background: var(--p-accent-soft); border-color: var(--p-accent); }
.theme-plain .local-user span { color: var(--p-muted); }

/* =====================================================================
   Environment badge (not shown in production)
   ===================================================================== */

.env-badge {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 60;
  padding: 2px 10px 0;
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--leaf);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  pointer-events: none;
}
.env-staging { background: var(--red); }
.theme-plain .env-badge { padding: 3px 8px; font: 700 .72rem var(--p-font); border: 0; border-radius: 4px; box-shadow: none; }

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