/* Counting Sheep: pasture greens and wool, by day and by night (follows the device). */
:root {
  --bg: #e9ecdf;
  --text: #1f2a1c;
  --text-2: #3a4636;
  --text-3: #4c5848;
  --muted: #5f6b5a;
  --link: #2f5527;
  --card: #f6f7f1;
  --line: #cfd6c4;
  --field: #ffffff;
  --button: #3f6b35;
  --button-text: #f6f7f1;
  --soft: #dde3d1;
  --danger: #9b1c1c;
  --pill-border: #a7b29c;
  --pill-on: #3f6b35;
  --pill-on-text: #f6f7f1;
  --shadow: 0 6px 20px rgba(30, 40, 25, .14);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121510;
    --text: #e6eadf;
    --text-2: #c9d0c0;
    --text-3: #b2baa8;
    --muted: #98a38f;
    --link: #a9cf96;
    --card: #1b2018;
    --line: #2e362a;
    --field: #232a20;
    --button: #9cc48a;
    --button-text: #121510;
    --soft: #262e22;
    --danger: #ff8f8f;
    --pill-border: #4a5544;
    --pill-on: #9cc48a;
    --pill-on-text: #121510;
    --shadow: 0 6px 20px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
/* Phones: no double-tap zoom (pinch is stopped by the viewport line and script). Text boxes are 16px or more,
   so iPhones don't zoom in when you start typing. */
html { touch-action: manipulation; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--link); }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 18px; margin: 28px 0 8px; }
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.link-btn { font: inherit; color: var(--muted); background: none; border: 0; padding: 4px; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--text); }
.btn, .main-btn, .soft-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px;
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; cursor: pointer; text-decoration: none;
}
.btn, .main-btn { background: var(--button); color: var(--button-text); }
.soft-btn { background: var(--soft); color: var(--text); }
.main-btn:disabled, .soft-btn:disabled { opacity: .45; cursor: default; }
.main-btn.wide { width: 100%; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 640px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .14em; }
.brand img { border-radius: 6px; }
.top-end { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yy { display: inline-flex; padding: 4px; border-radius: 50%; }
.yy img { display: block; transition: transform .5s ease; }
.yy:hover img, .yy:focus-visible img { transform: rotate(180deg); }
.top-nav { display: flex; gap: 4px; margin-right: auto; margin-left: 12px; }
.top-nav a { color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 999px; }
.top-nav a.on { color: var(--pill-on-text); background: var(--pill-on); }
@media (max-width: 640px) {
  .brand span, .top .logout { display: none; }
  .who { max-width: 7rem; }
  .top-nav { margin-left: 4px; }
}

.page { max-width: 640px; margin: 0 auto; padding: 0 16px 48px; }
.flash { border-radius: 8px; padding: 10px 14px; margin: 8px auto 16px; max-width: 32rem; background: var(--card); border: 1px solid var(--line); text-align: center; }
.flash-error { color: var(--danger); }
.empty { text-align: center; padding: 40px 0; }
.empty h1 { margin-bottom: 8px; }
.prose { max-width: 680px; }
.prose h2 { font-size: 18px; margin-top: 24px; }
.prose p { color: var(--text-2); }
.center-note { text-align: center; font-size: .9rem; }

/* ---- the stock: totals and mob cards ---- */
.tally-head { display: flex; align-items: baseline; gap: 10px; margin: 12px 0 4px; }
.big-num { font-size: 44px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.class-totals { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 18px; padding: 0; color: var(--text-2); }
.mobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mob-card {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none;
}
.mob-card:hover { border-color: var(--pill-border); }
.mob-name { font-weight: 650; font-size: 17px; }
.mob-total { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; grid-row: span 2; align-self: center; }
.mob-classes, .mob-counted { grid-column: 1 / -1; font-size: 14px; }
.mob-where { font-size: 14px; }
.new-mob-btn { margin-left: auto; align-self: center; flex: none; }
.tally-head > .muted { white-space: nowrap; }
.stock .tally-head { flex-wrap: wrap; }
@media (max-width: 400px) {
  .stock .tally-head { gap: 8px; }
  .stock .big-num { font-size: 38px; }
  .new-mob-btn { padding: 8px 12px; min-height: 40px; }
}
.pending-note { font-size: .9rem; color: var(--text-2); margin: 10px 0; padding: 10px 12px; background: var(--card); border: 1px dashed var(--pill-border); border-radius: 10px; }
.pending-note[hidden] { display: none; }
.pending-note .refused { display: block; color: var(--danger); }

/* ---- a mob ---- */
.crumb { margin: 4px 0 6px; }
.crumb a { color: var(--muted); text-decoration: none; }
.mob-title { font-size: 26px; }
.edit-name { cursor: text; border-radius: 6px; }
.edit-name:hover, .edit-name:focus-visible { background: var(--soft); outline: none; }
.edit-name[hidden] { display: none; }
.name-input { font: inherit; font-size: 26px; font-weight: 700; width: 100%; padding: 0 4px; border: 0; border-bottom: 2px solid var(--button); background: transparent; color: var(--text); outline: none; }
.mob > .mob-where { margin: 0; }
.where-btn { padding: 2px 0; text-decoration: underline dotted; text-underline-offset: 3px; }
.class-rows { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.class-rows a { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.class-rows a:hover { background: var(--card); }
.class-rows strong { font-variant-numeric: tabular-nums; }
.mob-actions { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 8px; margin: 18px 0 0; }
@media (max-width: 480px) {
  .mob-actions { grid-template-columns: 1fr 1fr; }
}
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: flex; align-items: baseline; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.e-date { width: 52px; flex: none; color: var(--muted); font-size: 14px; }
.e-what { flex: 1; min-width: 0; }
.e-note { display: block; font-size: 14px; }
.entries .e-day { font-weight: 650; color: var(--text-2); padding-top: 18px; border-bottom: 0; }
.e-mob { width: 34%; flex: none; color: var(--text-2); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.put-away { margin-top: 18px; text-align: center; }
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 4px; }

/* ---- pop-up sheets ---- */
.sheet {
  width: min(28rem, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); color: var(--text); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet form { display: flex; flex-direction: column; gap: 14px; }
.sheet-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet-row:has(> :only-child) { grid-template-columns: 1fr; }
.sheet label, .sheet legend { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--text-2); }
input:not([type=radio]), select {
  font: inherit; font-size: 16px; padding: 10px; min-height: 44px; width: 100%; min-width: 0;
  border: 1px solid var(--pill-border); border-radius: 8px; background: var(--field); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--button); outline-offset: -1px; border-color: transparent; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }
.class-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.sheet-error { color: var(--danger); margin: 0; }
.sheet-error[hidden] { display: none; }
.sheet-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }

/* Dropdowns open their list inside the page (where the browser can), so it's click to open,
   click to pick, the same in every Dosian app (as HUGE's). iPhones keep their own picker. */
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { display: flex; align-items: center; gap: 8px; cursor: pointer; }
  select::picker-icon { color: var(--muted); transition: rotate .15s; }
  select:open::picker-icon { rotate: 180deg; }
  ::picker(select) {
    margin-top: 4px; padding: 4px; max-height: min(450px, 60vh);
    border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); box-shadow: var(--shadow);
  }
  option { padding: 9px 10px; border-radius: 7px; cursor: pointer; }
  option:hover, option:focus-visible { background: var(--soft); outline: none; }
  option:checked { font-weight: 600; }
  option::checkmark { color: var(--button); }
}

/* pill choices (radio buttons) */
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill { position: relative; display: inline-flex; flex-direction: row; }
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pill span {
  display: inline-block; padding: 7px 13px; border: 1px solid var(--pill-border); border-radius: 999px;
  color: var(--text-2); font-size: .9rem; line-height: 1.2;
}
.pill input:checked + span { background: var(--pill-on); border-color: var(--pill-on); color: var(--pill-on-text); }
.pill input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
fieldset.pills legend { width: 100%; }

/* ---- the tally counter ---- */
.counter { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 6px; }
.count-pick { width: 100%; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.count-pick select { max-width: 22rem; font-weight: 600; }
.count-pick .pills { justify-content: center; gap: 5px; }
@media (max-width: 480px) {
  #count-classes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 22rem; }
  #count-classes .pill span { width: 100%; text-align: center; }
}
.book { margin: 4px 0 0; min-height: 1.5em; }
.tap {
  width: min(78vw, 300px); aspect-ratio: 1; border-radius: 50%; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--button); color: var(--button-text); box-shadow: 0 6px 0 color-mix(in srgb, var(--button) 60%, #000);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform .05s ease, box-shadow .05s ease;
}
.tap:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--button) 60%, #000); }
.tap-num { font-size: clamp(56px, 20vw, 88px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tap-num.bump { animation: bump .12s ease-out; }
@keyframes bump { from { transform: scale(1.08); } to { transform: scale(1); } }
.tap-hint { font-size: 14px; opacity: .8; }
.count-tools { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.soft-btn.round { width: 52px; height: 52px; padding: 0; border-radius: 50%; font-size: 26px; line-height: 1; }
.step .pill span { padding: 6px 10px; }
.diff { margin: 0; min-height: 1.5em; font-weight: 600; color: var(--text-2); }
.diff.off { color: var(--danger); }
.counter .main-btn.wide { max-width: 22rem; }
.saved-note { margin: 0; text-align: center; color: var(--text-2); }
.saved-note.bad { color: var(--danger); }
.saved-note[hidden] { display: none; }
@media (max-height: 700px) {
  .tap { width: min(62vw, 240px); }
}

/* no signal (static/app.js) */
.offline-bar {
  padding: 6px 16px; padding-top: max(6px, env(safe-area-inset-top)); text-align: center;
  font-size: 14px; font-weight: 600; background: #e0b84a; color: #1a1a1a;
}
.offline-bar[hidden] { display: none; }

/* the account page */
.account h1 { margin-top: 8px; }
.account .muted:first-of-type { margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 12px; max-width: 24rem; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--text-2); }
.stack .small { font-size: .85rem; margin: 0; }
a.who { text-decoration: none; }
a.who:hover { color: var(--text); text-decoration: underline; }
.account-out { margin-top: 28px; }

/* ---- notes ---- */
.note-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.note { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.note-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; }
.note-head a { color: var(--link); text-decoration: none; }
.note-body { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; margin-top: 10px; }
.note-photos .photo { position: relative; display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--soft); }
.note-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.note-photos.picked:empty { display: none; }
.photo-x {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}
.photo-pick { display: flex; align-items: center; gap: 12px; }
.photo-btn { cursor: pointer; }
.photo-btn.full { opacity: .45; pointer-events: none; }
.small { font-size: .85rem; }
textarea {
  font: inherit; font-size: 16px; padding: 10px; width: 100%; min-width: 0; resize: vertical;
  border: 1px solid var(--pill-border); border-radius: 8px; background: var(--field); color: var(--text);
}
textarea:focus { outline: 2px solid var(--button); outline-offset: -1px; border-color: transparent; }
.notes .crumb { margin-top: 0; }
.viewer { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
.viewer::backdrop { background: rgba(0, 0, 0, .9); }
.viewer img { display: block; max-width: 100vw; max-height: 100vh; max-height: 100dvh; object-fit: contain; }
.mob-notes { margin: 14px 0 0; }
@media (max-width: 380px) {
  .top { gap: 6px; }
  .top-nav { gap: 0; margin-left: 0; }
  .top-nav a { padding: 4px 8px; }
  .who { max-width: 4.5rem; }
}
.note-tools { display: inline-flex; gap: 6px; align-items: baseline; }
