/* tinyfiles — base styles on the meanbrian Liquid Glass tokens: Apple neutrals, solid content cards,
   iMac green as the one accent. Glass (tab bar, round buttons, sheets, pop-ups) lives in glass.css. App-specific in app.css. */
:root {
  --bg: #f6f6f4;            /* page background */
  --surface: #ffffff;       /* "card": solid content (lists, cards, panels) */
  --raised: #f0f0ec;        /* "chip": fields, quiet fills, segmented tracks */
  --ink: #16181d;
  --ink-2: #6b7079;         /* "muted": secondary text, 4.5:1 on bg and card */
  --line: #e4e4e0;
  --accent: #2e8b57;         /* accent fill (buttons): iMac green, same as "files" in the wordmark */
  --accent-ink: #ffffff;     /* text on an accent fill */
  --accent-fg: #277a4c;      /* accent as text/icons on light surfaces (4.8:1 on bg) */
  --green: #34c759; --red: #ff3b30; --blue: #007aff; /* only for multicolour icons; the app's accent is green */ --orange: #ff9500;
  --seg-off: #dcdcd6;
  --focus: #2e8b57;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --r-group: 22px; --r-control: 22px; --r-item: 12px;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, sans-serif;
  --code: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, sans-serif;
  --brand: #2e8b57;          /* the green of "files" in the wordmark (iMac green) */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --surface: #1a1c20; --raised: #23262b; --ink: #ececec; --ink-2: #9aa0a8; --line: #2a2d33;
    --accent: #278a55; --accent-ink: #ffffff; --accent-fg: #5cc98d; --seg-off: #33363c; --focus: #5cc98d; --brand: #5cc98d;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --surface: #1a1c20; --raised: #23262b; --ink: #ececec; --ink-2: #9aa0a8; --line: #2a2d33;
  --accent: #278a55; --accent-ink: #ffffff; --accent-fg: #5cc98d; --seg-off: #33363c; --focus: #5cc98d; --brand: #5cc98d;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 17px/1.45 var(--body); min-height: 100dvh; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(120px + env(safe-area-inset-bottom)); /* clears the floating tab bar */
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent-fg); }
.hidden { display: none !important; }

/* ---------- shell: page top (glass buttons + large title) ---------- */
main { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) 16px 0; }
.pagetop { margin-bottom: 8px; }
.pt-bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.pt-acts { display: flex; gap: 8px; }
.large-title { font: 700 34px/41px var(--code); letter-spacing: .2px; margin: 6px 0 6px; overflow-wrap: anywhere; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: var(--raised); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 15px; cursor: pointer; min-height: 44px;
  text-decoration: none; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn:active { transform: scale(.97); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; min-height: 50px; border-radius: 16px; font-size: 17px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.link { background: none; border: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; padding: 6px 0; font-size: 14px; }
.iconbtn { background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--ink-2); display: inline-grid; place-items: center; }
.iconbtn svg { width: 20px; height: 20px; }

label.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; font-size: 13px; font-weight: 400; color: var(--ink-2); min-width: 0; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=url], input[type=email], input[type=date], input[type=datetime-local], select, textarea {
  box-sizing: border-box; display: block; width: 100%; min-width: 0; max-width: 100%; border: 1px solid transparent; background: var(--raised); border-radius: 12px;
  padding: 11px 14px; min-height: 44px; color: var(--ink); font-weight: 400; font-size: 17px;
}
textarea { min-height: 70px; resize: vertical; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
/* iPhone date pickers have their own width and centred text: make them behave like the other fields */
input[type=date], input[type=datetime-local] { -webkit-appearance: none; appearance: none; text-align: left; }
input[type=date]::-webkit-date-and-time-value, input[type=datetime-local]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }

.seg { display: flex; border-radius: 12px; overflow: hidden; background: var(--raised); padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; font-weight: 600; font-size: 15px; cursor: pointer; min-height: 38px; color: var(--ink-2); border-radius: 9px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.12); }

.list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
/* press and hold a card for its menu: no iOS link preview { -webkit-touch-callout: none; }
.sw { transition: scale .25s; }
.handle { cursor: grab; touch-action: none; color: var(--ink-2); padding: 6px; margin-left: -6px; }

/* the battery: four segments { display: grid; grid-template-rows: repeat(4, 1fr); gap: 3px; padding: 3px; border: 2px solid var(--ink-2); border-radius: 4px; position: relative; width: 30px; height: 44px; margin-top: 4px; }

.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty h2 { color: var(--ink); font: 700 22px/1.2 var(--code); margin: 0 0 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: var(--r-group); overflow: hidden; margin-bottom: 16px; }
.stats div { background: var(--surface); padding: 12px; }
.stats strong { display: block; font: 700 24px/1.15 var(--code); font-variant-numeric: tabular-nums; }
.stats span { font-size: 13px; color: var(--ink-2); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--bg); color: var(--ink-2); margin-left: 6px; }
.tag.first { background: var(--green); color: #fff; }

/* ---------- groups ---------- */
/* a group folds: its header is a card; open, its items show below as Gear cards */
.group { margin-bottom: 14px; }
.group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--r-group); padding: 12px 10px 12px 14px; box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group .chev { display: grid; color: var(--ink-2); transition: transform .2s; }
.group .chev svg { width: 16px; height: 16px; }
.group[open] .chev { transform: rotate(90deg); }
.group h3 { margin: 0; font: 700 22px/1.2 var(--code); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group > .list { margin-top: 8px; } /* left out of Use next */
@media (prefers-reduced-motion: reduce) { .group .chev { transition: none; } }

/* ---------- settings ---------- */
.panel { background: var(--surface); border-radius: var(--r-group); padding: 14px 16px; box-shadow: var(--shadow); margin: 34px 0 0; position: relative; }
.panel:first-child, .warn + .panel { margin-top: 30px; }
.pagetop + .panel { margin-top: 40px; }
/* the panel's heading sits above it as an uppercase section header (iOS grouped list) */
.panel > h2:first-child { position: absolute; left: 16px; bottom: calc(100% + 7px); margin: 0; font: 400 13px/18px var(--body); letter-spacing: .26px; text-transform: uppercase; color: var(--ink-2); }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.lines li:first-child { border-top: 0; }
.lines .grow { flex: 1; min-width: 140px; }
.lines .grow b { display: block; }
.lines .actions { flex-basis: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
.status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.status.live { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.status.off { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
pre.snippet { background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* ---------- dev ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.kpis div { background: var(--surface); border-radius: 16px; padding: 10px 12px; box-shadow: var(--shadow); }
.kpis strong { font: 700 28px/1 var(--code); display: block; }
.kpis span { font-size: 12px; color: var(--ink-2); }
.event { font-size: 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.event:first-child { border-top: 0; }

/* ---------- inside sheets (the sheet itself is in glass.css) ---------- */
.reader { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #000; }
.reader video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.secret {
  font: 500 16px/1.5 ui-monospace, 'SF Mono', Menlo, monospace; background: var(--bg); padding: 12px;
  border-radius: 8px; word-break: break-all; user-select: all; border: 2px dashed var(--accent);
}
.warn { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--ink); padding: 12px 14px; border-radius: 16px; font-size: 15px; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- login ---------- */
.auth { max-width: 400px; margin: 8vh auto 0; padding: 0 16px; }
.auth h1 { font: 800 60px/1 var(--code); letter-spacing: -.02em; margin: 0 0 6px; }
.auth { padding-top: env(safe-area-inset-top); }
.auth h1 b, .dr-brand b { color: var(--brand); }
.auth .lede { color: var(--ink-2); margin: 0 0 28px; }
.auth .switch { margin-top: 22px; text-align: center; font-size: 14px; color: var(--ink-2); }
.error { color: var(--red); font-size: 14px; font-weight: 600; margin: 0; }
.error:empty { display: none; }

/* ---------- swipe rows ---------- */
.sw { position: relative; overflow: hidden; border-radius: var(--r-group); box-shadow: var(--shadow); }

/* ---------- pull to refresh (home-screen app) ---------- */
.ptr {
  position: fixed; z-index: 40; left: 50%; top: calc(env(safe-area-inset-top) - 30px);
  width: 40px; height: 40px; border-radius: 50%; background: var(--raised); color: var(--ink-2);
  display: grid; place-items: center; box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 0);
  pointer-events: none;
}
.ptr svg { width: 20px; height: 20px; transition: transform .15s; }
.ptr.ready { color: var(--accent); }
.ptr.spin svg { animation: ptrspin .8s linear infinite; }
@keyframes ptrspin { to { transform: rotate(360deg); } }
/* undo: yellow outline { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.folder { border: 1px solid var(--line); border-radius: 16px; background: var(--raised); margin-bottom: 8px; overflow: hidden; }
.folder > summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; min-height: 44px; }
.folder > summary::-webkit-details-marker { display: none; }
.folder > summary .grow { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.folder > summary b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.folder > summary::after { content: "›"; font-size: 20px; color: var(--ink-2); transition: transform .15s; }
.folder[open] > summary::after { transform: rotate(90deg); }
.folder > .lines { margin: 0; padding: 0 12px 4px; border-top: 1px solid var(--line); }

/* logs folded by month */
.month { margin-bottom: 10px; }
.month > summary { display: flex; align-items: center; gap: 10px; padding: 10px 6px; cursor: pointer; list-style: none; font-weight: 700; font-size: 20px; min-height: 44px; }
.month > summary::-webkit-details-marker { display: none; }
.month > summary::before { content: "›"; font-size: 20px; line-height: 1; color: var(--ink-2); width: 12px; transition: transform .15s; }
.month[open] > summary::before { transform: rotate(90deg); }

/* log sheet extras */
details.more > summary { cursor: pointer; font-weight: 600; color: var(--ink-2); padding: 6px 0; }

/* item page bottom: export/import together { margin-top: 4px; }

/* checkboxes are iOS switches: green when on */
input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 51px; height: 31px; border-radius: 999px; background: var(--seg-off); transition: background-color .2s;
}
input[type=checkbox]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .25s cubic-bezier(.32,.72,0,1);
}
input[type=checkbox]:checked { background: var(--green); }
input[type=checkbox]:checked::before { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { input[type=checkbox], input[type=checkbox]::before { transition: none; } }
