/* LicenceWarden, by Sixth Day Studios. Same look as the Sixth Day Studios site: the same tokens,
   light + dark from one set, teal accent. Mobile first. No inline styles anywhere (CSP), so
   everything the app needs lives here. */

:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #eef0f3; --border: #dfe3e8;
  --text: #16191d; --muted: #5d6671; --accent: #0f8f7a; --accent-ink: #ffffff;
  --ok: #1f9d55; --warn: #c97a07; --down: #d64545;
  --glow: rgba(15, 143, 122, .14);
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  color-scheme: light;
}
/* Dark: when the device is dark and the visitor hasn't picked Light, or they picked Dark (theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --border: #2a2f38;
    --text: #e8ebef; --muted: #98a2ad; --accent: #2cc4a8; --accent-ink: #06231d;
    --ok: #3ccf7f; --warn: #f0a93a; --down: #ff6b6b;
    --glow: rgba(44, 196, 168, .12);
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --border: #2a2f38;
    --text: #e8ebef; --muted: #98a2ad; --accent: #2cc4a8; --accent-ink: #06231d;
    --ok: #3ccf7f; --warn: #f0a93a; --down: #ff6b6b;
    --glow: rgba(44, 196, 168, .12);
    --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.offscreen { position: absolute; left: -9999px; top: 0; }
[hidden] { display: none !important; }

/* ── Top bar ── */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent);
       backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 38px; display: block; }   /* the sunrise 6, follows light/dark itself */
.org { color: var(--muted); font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: none; }
.top nav { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: 15px; }
.navlinks { display: none; align-items: center; gap: 18px; }
.navlink { color: var(--muted); white-space: nowrap; padding: 8px 0; }
.navlink:hover { color: var(--text); text-decoration: none; }
.navlink[aria-current="page"] { color: var(--text); font-weight: 600; box-shadow: 0 2px 0 var(--accent); }
.theme-switch { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 999px;
                width: 44px; height: 44px; font-size: 16px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.theme-switch:hover { color: var(--text); border-color: var(--muted); }
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }

/* ── Buttons ── */
.btns { display: flex; flex-wrap: wrap; gap: 10px; }
.btns.end { justify-content: flex-end; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px;
       border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
       font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.small, .btns.small .btn { min-height: 44px; padding: 0 14px; font-size: 15px; }
.btn.danger { color: var(--down); }
.btn.danger:hover { border-color: var(--down); }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Cards, text ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-title { margin: 0 0 10px; font-size: 18px; }
.note { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.note.break { word-break: break-word; }
.nowrap { white-space: nowrap; }
.hint { font-weight: 400; font-size: 13px; color: var(--muted); }
.warntext { font-size: 14px; color: var(--warn); }
.msg { font-size: 15px; padding: 10px 12px; border-radius: 10px; overflow-wrap: anywhere; }
.msg.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.msg.bad { color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; display: inline-block; line-height: 1.5; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.pill.down { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
.pill.muted { color: var(--muted); background: color-mix(in srgb, var(--muted) 16%, transparent); }
.pill.info { color: var(--accent); background: var(--glow); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ── Forms ── */
form.card, .form-grid { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
input, textarea, select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
                  background: var(--bg); color: var(--text); font: inherit; font-weight: 400; min-height: 46px; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
input:disabled { opacity: .5; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--accent); flex: none; }
input.code { font-size: 22px; letter-spacing: .3em; text-align: center; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
.tick-row, .pick-row { display: flex; align-items: center; gap: 12px; font-weight: 500; font-size: 16px; min-height: 48px; cursor: pointer; }
.pick-row.inner { padding: 6px 0; border-bottom: 1px solid var(--border); }
.pick-row.inner:last-child { border-bottom: 0; }
label.card.pick-row { padding: 10px 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%; }
.inline-form input { flex: 1 1 180px; width: auto; min-width: 0; }
.secret { font-family: Consolas, "SF Mono", monospace; font-size: 20px; letter-spacing: .08em; padding: 14px; text-align: center;
          background: var(--bg); border: 1px dashed var(--border); border-radius: 12px; overflow-wrap: anywhere; user-select: all; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.copy { font-family: Consolas, monospace; font-size: 13px; }

/* switch (like the site's) */
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muted); cursor: pointer; min-height: 44px; font-weight: 500; }
.switch input { appearance: none; -webkit-appearance: none; margin: 0; width: 42px; height: 24px; min-height: 0; padding: 0; border-radius: 999px; flex: none;
                background: var(--border); position: relative; cursor: pointer; transition: background .15s; border: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
                       background: var(--surface); transition: left .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 21px; }
@media (prefers-reduced-motion: reduce) { .switch input, .switch input::after { transition: none; } }

/* ── Page layout ── */
main.page { padding: 20px 0 32px; flex: 1; outline: none; }
main.page > .wrap { display: grid; gap: 16px; align-content: start; }
.narrow { max-width: 480px; }
.auth { display: grid; gap: 14px; }
.auth h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.page-head h1 { margin: 0; font-size: clamp(26px, 4vw, 34px); line-height: 1.2; }
.page-head .sub { margin: 2px 0 0; color: var(--muted); }
.page-head .btns { margin-left: auto; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 20px; }
.back { margin: 0; }
.tiles { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 220px; width: auto; min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.empty-state { text-align: center; padding: 28px 16px; color: var(--muted); display: grid; gap: 14px; justify-items: center; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state p { margin: 0; }

/* stat tiles */
.stats-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-n { font-size: 32px; font-weight: 800; line-height: 1.1; }
.stat-l { font-size: 14px; color: var(--muted); }
.stat.warn .stat-n { color: var(--warn); }
.stat.down .stat-n { color: var(--down); }

/* lists */
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--text); min-height: 56px; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { text-decoration: none; background: var(--surface-2); }
.list-row.wrap-row { flex-wrap: wrap; }
.right-col { text-align: right; display: grid; gap: 2px; justify-items: end; flex: none; }
.list-cards { display: grid; gap: 10px; }
.card.link { display: flex; align-items: center; gap: 12px; color: var(--text); padding: 12px 14px; }
.card.link:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
          background: var(--surface-2); color: var(--accent); font-weight: 800; font-size: 16px; }
.avatar.big { width: 56px; height: 56px; font-size: 20px; border-radius: 14px; }
.person-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.person-head h1 { margin: 0; font-size: 24px; line-height: 1.2; overflow-wrap: anywhere; }
.stephead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stephead h2 { margin: 0; font-size: 20px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 10px 16px; min-height: 44px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
        color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.some { border-color: var(--accent); color: var(--text); }

/* sticky action bar above the tab bar */
.actionbar { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); display: flex; gap: 10px; justify-content: flex-end;
             padding: 10px 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); z-index: 5; }
.actionbar .btn { flex: 1 1 auto; }
.actionbar.inline { position: static; background: none; backdrop-filter: none; padding: 0; }

/* card tiles + photos */
.tile { display: grid; gap: 12px; }
.tile-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.tile-title { font-size: 17px; overflow-wrap: anywhere; }
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-slot { margin: 0; display: grid; gap: 6px; align-content: start; min-width: 0; }
.photo-slot figcaption { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.photo-box { aspect-ratio: 3 / 2; background: var(--surface-2); border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.card-photo { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0; min-height: 0; padding: 0; border: 0; }
.photo-empty { font-size: 13px; color: var(--muted); padding: 8px; text-align: center; }
.slot-actions { display: none; }
.tile.open .slot-actions { display: flex; }
.tile.open .photo-box { aspect-ratio: auto; min-height: 120px; }
.tile.open .card-photo { height: auto; object-fit: contain; }
@media (max-width: 599px) { .tile.open .photo-grid { grid-template-columns: 1fr; } }
.tile-detail { display: grid; gap: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.photo-picker { display: grid; gap: 6px; }
.photo-row { display: flex; gap: 12px; align-items: center; }
.photo-actions { display: grid; gap: 6px; min-width: 0; }
.thumb-pick { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; padding: 0; border: 0; min-height: 0; }
.label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* settings */
.settings-section > summary { cursor: pointer; font-weight: 700; font-size: 17px; min-height: 44px; display: flex; align-items: center; list-style-position: inside; }
.settings-section[open] > summary { margin-bottom: 8px; }
.section-body { display: grid; gap: 14px; }
.section-body h3 { margin: 6px 0 0; font-size: 16px; }
.kv { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kv > div { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; justify-items: start; }
.danger-zone { border-color: color-mix(in srgb, var(--down) 55%, var(--border)); }
.danger-zone > summary { color: var(--down); }
.btn.danger.primary, button.btn.danger[type="submit"] { background: var(--down); border-color: var(--down); color: #fff; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.seg { min-height: 44px; padding: 0 18px; border: 0; background: var(--surface); color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--border); }
.seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.audit-row { align-items: flex-start; }

/* dialog (confirm steps) */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
          padding: 20px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog h2 { margin: 0 0 8px; font-size: 20px; }
.dialog-body p { margin: 0 0 16px; overflow-wrap: anywhere; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translate(-50%, 200%); opacity: 0;
         padding: 10px 18px; border-radius: 12px; font-weight: 600; transition: all .2s ease; z-index: 50; max-width: calc(100vw - 32px);
         background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); pointer-events: none; }
.toast.ok, .toast.bad { transform: translate(-50%, 0); opacity: 1; }
.toast.ok { color: var(--ok); }
.toast.bad { color: var(--down); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ── Bottom tab bar (phones) ── */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: none; background: var(--surface);
          border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
body[data-mode="in"] .tabbar { display: flex; }
.tab-item { flex: 1 1 0; min-width: 0; min-height: 56px; display: grid; place-items: center; align-content: center; gap: 2px;
            color: var(--muted); font-size: 11px; font-weight: 600; padding: 6px 2px; }
.tab-item:hover { text-decoration: none; color: var(--text); }
.tab-item[aria-current="page"] { color: var(--accent); }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body[data-mode="in"] main.page { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

/* ── Footer ── */
footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: 14px; }
body[data-mode="in"] footer { display: none; }

/* ── Wide screens: top nav instead of tab bar ── */
@media (min-width: 800px) {
  .navlinks { display: flex; }
  .org { display: block; }
  body[data-mode="in"] .tabbar { display: none; }
  body[data-mode="in"] main.page { padding-bottom: 40px; }
  body[data-mode="in"] footer { display: block; }
  .actionbar { bottom: 0; }
  .toast { bottom: 80px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  main.page { padding-top: 32px; }
}
