:root {
  --bg: #faf6f1; --surface: #ffffff; --surface-2: #f3ece4; --text: #1d1611; --muted: #7a6a5c;
  --line: #e6dbcf; --accent: #e07a2c; --accent-ink: #ffffff; --gold: #b8892b;
  --ok: #2f8f4e; --bad: #c8412f; --warn: #b7791f; --info: #2f6fb0;
  --radius: 14px; --shadow: 0 1px 2px rgba(40,25,10,.06), 0 4px 16px rgba(40,25,10,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16110d; --surface: #211a14; --surface-2: #2b221a; --text: #f4ece4; --muted: #a8988a;
    --line: #3a2f25; --accent: #f08a3a; --accent-ink: #1a120b; --gold: #d9ae55;
    --ok: #4cbf6e; --bad: #ec6a56; --warn: #e3a948; --info: #6aa7e6;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* header + tabs */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; letter-spacing: .2px; }
.brand img { border-radius: 8px; }
.clock { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
.tab { display: none; } .tab.active { display: block; }
h2 { font-size: 20px; margin: 8px 0 12px; } h2 small { color: var(--muted); font-weight: 400; font-size: 13px; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; border: 0; background: none; padding: 6px 0; display: flex; flex-direction: column; align-items: center;
  font-size: 11px; color: var(--muted); gap: 2px; min-height: 48px;
}
.tabbar button span { font-size: 20px; }
.tabbar button.active { color: var(--accent); font-weight: 600; }

/* day bar */
.daybar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.daylabel { font-weight: 700; font-size: 17px; text-align: center; }
.daylabel small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-title { font-weight: 700; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.badge.busy { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.muted { color: var(--muted); font-size: 14px; }
.idea-text { white-space: pre-wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin: 0 0 10px; }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=time], input[type=datetime-local], input[type=number], textarea, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  font-size: 16px; /* prevents iOS zoom */
}
textarea { min-height: 84px; resize: vertical; }
textarea.short { min-height: 60px; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.seg button { border: 0; background: none; padding: 10px 6px; border-radius: 9px; font-size: 14px; min-height: 44px; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.row { display: flex; gap: 8px; } .row > * { flex: 1; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 12px 14px; border-radius: 12px; min-height: 46px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; } .actions .btn { flex: 1 1 auto; }

.savebar { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); padding: 8px 0; }

/* cost + progress */
.cost { margin-top: 12px; padding: 10px 12px; border-radius: 10px; border: 1px dashed var(--gold); background: color-mix(in srgb, var(--gold) 8%, transparent); font-size: 14px; }
.cost b { font-size: 16px; }
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* slides */
.slides { display: grid; gap: 12px; }
.slide { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.slide.approved { border-color: var(--ok); } .slide.rejected { border-color: var(--bad); }
.slide-img { aspect-ratio: 1 / 1; width: 100%; object-fit: cover; background: var(--surface-2); cursor: zoom-in; }
.slide-ph { aspect-ratio: 1 / 1; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.slide-body { padding: 10px; }
.slide-n { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.slide-scene { font-size: 14px; margin: 4px 0 0; }
.slide-sign { font-weight: 700; margin-top: 4px; }
.vote { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.vote .btn.on.okb { background: var(--ok); color: #fff; border-color: var(--ok); }
.vote .btn.on.badb { background: var(--bad); color: #fff; border-color: var(--bad); }
.thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.thumbs img { aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; }

/* banners + errors */
.banner { padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; font-size: 14px; background: color-mix(in srgb, var(--warn) 14%, transparent); }
.banner.info { background: color-mix(in srgb, var(--info) 12%, transparent); }
.err { color: var(--bad); font-size: 14px; white-space: pre-wrap; }
.errbox { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; margin-top: 10px; word-break: break-word; }

/* queue */
.q { display: flex; gap: 12px; align-items: center; }
.q img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; }
.q-main { flex: 1; min-width: 0; }
.q-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.q-label { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.downloads { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.downloads a { font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); }
.toggle { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 15px; margin-top: 12px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.check { list-style: none; padding: 0; margin: 0; } .check li { padding: 4px 0; }
.log { font-size: 12px; color: var(--muted); margin-top: 10px; } .log div { padding: 1px 0; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-top: 10px; }

/* lightbox + toast */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-height: 100%; border-radius: 8px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; text-align: center; font-size: 14px; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); display: grid; gap: 12px; text-align: center; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-logo { margin: 0 auto; border-radius: 20px; }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.share .btn { font-size: 13px; padding: 6px 10px; }
.shares { margin-top: 10px; }
.shares summary { cursor: pointer; font-size: 14px; }
.share-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }

.warn { color: var(--warn); font-size: 13px; }
.check { margin-top: 8px; padding: 8px 10px; border-radius: 10px; font-size: 14px; background: color-mix(in srgb, var(--info) 10%, transparent); display: grid; gap: 4px; }
.check .btn { justify-self: start; font-size: 13px; padding: 6px 10px; margin-top: 4px; }

.igcap { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.caption-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; margin: 6px 0; }
.capedit { width: 100%; min-height: 160px; }

.add-idea { margin: 4px 0 16px; text-align: center; }
.add-idea .btn { width: 100%; border-style: dashed; }
.add-idea .muted { font-size: 13px; margin-top: 6px; }


/* ---------------- calendar */
.badge.info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.btn.small { font-size: 13px; padding: 6px 10px; min-height: 0; }
.small { font-size: 13px; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-title { flex: 1; text-align: center; font-weight: 700; font-size: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; text-transform: uppercase; letter-spacing: .04em; }
.cal-cell { min-height: 64px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 4px; text-align: left;
  display: flex; flex-direction: column; gap: 2px; color: var(--text); cursor: pointer; font: inherit; }
.cal-cell.blank { border: none; background: transparent; cursor: default; }
.cal-cell.past { opacity: .6; }
.cal-cell.today .num { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; }
.cal-cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-cell.drop { outline: 2px dashed var(--info); outline-offset: -2px; background: color-mix(in srgb, var(--info) 10%, var(--surface)); }
.cal-cell .num { font-weight: 700; font-size: 13px; align-self: flex-start; }
.cnts { display: flex; flex-wrap: wrap; gap: 2px; }
.cnt { font-size: 10px; line-height: 1.4; padding: 0 4px; border-radius: 6px; font-weight: 700; }
.cnt.pub { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.cnt.sch { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.cnt.prep { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.cnt.fail { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.cal-legend { font-size: 12px; margin: 8px 0 12px; }
.cal-day { margin-top: 4px; }
.cal-slot { display: grid; grid-template-columns: 54px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.cal-time { font-weight: 700; font-size: 15px; padding-top: 4px; }
.cal-empty { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-post { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 6px 0; }
.cal-post[draggable="true"] { cursor: grab; }
.cal-post img, .cal-post .ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 24px; }
.cp-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.cp-label { font-size: 14px; margin-top: 2px; word-break: break-word; }
.cal-post .actions { margin-top: 4px; }
.cal-move { margin-top: 8px; padding: 8px; border: 1px dashed var(--line); border-radius: 10px; display: grid; gap: 4px; }
.cal-sub { font-size: 14px; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
@media (max-width: 520px) {
  .cal-cell { min-height: 48px; padding: 3px; border-radius: 8px; }
  .cal-cell .num { font-size: 12px; }
  .cnt { font-size: 9px; padding: 0 3px; }
  .desk-only { display: none; }
}
@media (min-width: 900px) {
  main:has(#tab-calendar.active) { max-width: 1120px; }
  #calendar { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  .cal-cell { min-height: 84px; }
  .cal-day { position: sticky; top: 70px; max-height: calc(100vh - 160px); overflow: auto; }
}

