:root {
  --bg: #f4f2ef;
  --surface: #ffffff;
  --surface-2: #f8f6f3;
  --line: #e4dfd8;
  --line-strong: #cfc8bf;
  --ink: #1d1a17;
  --muted: #6e665d;
  --ok: #1d7448;
  --ok-bg: #e2f2e9;
  --warn: #8f5400;
  --warn-bg: #fbeed6;
  --bad: #b3261e;
  --bad-bg: #fbe6e4;
  --brand: #2c2a27;
  --brand-ink: var(--brand);
  --brand-soft: color-mix(in srgb, var(--brand) 9%, var(--surface));
  --on-brand: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1012;
    --surface: #1a1b1e;
    --surface-2: #222327;
    --line: #2d2f34;
    --line-strong: #41444b;
    --ink: #f1efec;
    --muted: #a39c93;
    --ok: #63d59c;
    --ok-bg: rgb(99 213 156 / 0.13);
    --warn: #f2b45a;
    --warn-bg: rgb(242 180 90 / 0.13);
    --bad: #ff8a80;
    --bad-bg: rgb(255 138 128 / 0.12);
    --brand: #e9e6e1;
    --on-brand: #141517;
    --brand-ink: color-mix(in srgb, var(--brand) 50%, white);
    --brand-soft: color-mix(in srgb, var(--brand) 22%, var(--surface));
    --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: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-inner {
  max-width: 640px;
  margin: 0 auto;
  min-height: 52px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.top-title { flex: 1; font-weight: 650; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--brand-ink);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.back::before { content: "\2039"; font-size: 28px; line-height: 1; margin-top: -3px; }
.back:active { background: var(--brand-soft); }
.spacer { flex: 1; }
.link-btn {
  background: none;
  border: 0;
  color: var(--muted);
  min-height: 44px;
  padding: 0 10px;
  font-size: 14px;
}

/* ---------- logo plate (logos are dark ink on transparent) ---------- */
.plate {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
}
.plate img { max-height: 30px; width: auto; object-fit: contain; }
.plate.big { padding: 18px 20px; border-radius: var(--radius); }
.plate.big img { max-height: 40px; }

/* ---------- headings / text ---------- */
h1 { font-size: 24px; line-height: 1.2; margin: 8px 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 28px 0 10px; font-weight: 650; }
.sub { color: var(--muted); margin: 0; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.login-card img.mark { width: 48px; height: 48px; margin-bottom: 14px; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-card form { display: grid; gap: 10px; }
.error { color: var(--bad); font-size: 14px; margin: 4px 0 0; min-height: 1.2em; }

/* ---------- inputs / buttons ---------- */
.field {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 16px;
}
.field:focus { outline: 2px solid var(--brand-ink); outline-offset: 1px; border-color: transparent; }
textarea.field { min-height: 96px; resize: vertical; line-height: 1.4; }
.label { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-weight: 650;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.danger { color: var(--bad); }

/* ---------- venue picker ---------- */
.venue-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .venue-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.venue-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.venue-card:active { transform: scale(0.98); }
.venue-card .plate { height: 64px; padding: 8px 10px; border-color: transparent; background: #fff; }
.venue-card .plate img { max-height: 26px; }
.venue-name { font-weight: 650; font-size: 15px; line-height: 1.2; padding: 0 2px; }
.badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--brand);
  color: #fff;
}

/* ---------- sheet page ---------- */
.sheet-head { display: grid; gap: 12px; margin-top: 4px; }
.date-nav {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: stretch;
  gap: 8px;
  margin-top: 16px;
}
.date-nav .arrow {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  font-size: 26px;
  line-height: 1;
  color: var(--brand-ink);
}
.date-nav .arrow:disabled { opacity: 0.35; }
.date-pick {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  min-height: 58px;
}
.date-pick strong { display: block; font-size: 17px; }
.date-pick span { font-size: 13px; color: var(--muted); }
.date-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.area-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.area-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 14px 14px 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--line-strong);
  text-decoration: none;
  box-shadow: var(--shadow);
  min-height: 72px;
}
.area-card:active { transform: scale(0.99); }
.area-card.signed { border-left-color: var(--ok); }
.area-card.progress { border-left-color: var(--warn); }
.area-name { font-size: 18px; font-weight: 700; }
.area-sub { font-size: 12px; color: var(--muted); grid-column: 1 / -1; margin-top: -2px; }
.area-meta { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.share-card {
  margin-top: 24px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  display: grid;
  gap: 12px;
}
.share-card p { margin: 0; }
.share-card strong { font-size: 17px; }

.night-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.night-list li + li { border-top: 1px solid var(--line); }
.night-list a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; min-height: 52px; }
.night-list a[aria-current="page"] { background: var(--brand-soft); font-weight: 650; }

/* ---------- area page ---------- */
.progress {
  position: sticky;
  top: calc(53px + env(safe-area-inset-top));
  z-index: 9;
  background: var(--bg);
  padding: 10px 0 10px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-bottom: 1px solid var(--line);
}
.progress-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.progress-row strong { font-size: 15px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; width: 0; background: var(--brand-ink); border-radius: 99px; transition: width 0.25s; }
.bar.done > i { background: var(--ok); }
.save-state { font-size: 13px; color: var(--muted); }
.save-state.bad { color: var(--bad); font-weight: 600; }

.area-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.area-title h1 { margin: 0; }

.checklist { margin-top: 12px; display: grid; gap: 8px; }
.group-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 2px 2px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  color: var(--brand-ink);
}
.group-label::after { content: ""; flex: 1; border-top: 1px dashed var(--line-strong); }
.item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  min-height: 60px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  line-height: 1.35;
}
.item.note { font-style: italic; }
.item .box {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid var(--line-strong);
  display: grid;
  place-items: center;
  background: var(--surface);
}
.item .box svg { width: 18px; height: 18px; opacity: 0; transform: scale(0.6); transition: 0.12s; }
.item[aria-checked="true"] { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }
.item[aria-checked="true"] .box { background: var(--ok); border-color: var(--ok); }
.item[aria-checked="true"] .box svg { opacity: 1; transform: none; }
.item[aria-checked="true"] .text { color: var(--muted); }
.item:disabled { cursor: default; opacity: 1; }
.item:not(:disabled):active { transform: scale(0.99); }
@media (prefers-color-scheme: dark) { .item[aria-checked="true"] .box svg path { stroke: #0f1012; } }

.card {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo-grid:empty { display: none; }
.photo {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo button.open { position: absolute; inset: 0; border: 0; padding: 0; background: none; }
.photo .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 30px;
  height: 30px;
  border-radius: 99px;
  border: 0;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}
.photo .status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  text-align: center;
  padding: 6px;
  color: var(--muted);
}
.photo.failed .status { color: var(--bad); font-weight: 600; }
.add-photo { position: relative; margin-top: 10px; }
.add-photo input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

.sig-wrap {
  position: relative;
  margin-top: 6px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  height: 170px;
  touch-action: none;
}
.sig-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.sig-wrap .hint {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 34px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 4px;
  pointer-events: none;
}
.sig-wrap.has-ink .hint span { visibility: hidden; }
.sig-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

.signed-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--ok-bg);
  border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent);
}
.signed-card .who { font-weight: 700; color: var(--ok); font-size: 17px; }
.signed-card .sig { margin-top: 10px; background: #fff; border-radius: 10px; padding: 8px; }
.signed-card .sig img { max-height: 70px; margin: 0 auto; }

.stack { display: grid; gap: 14px; }
.sign-section { margin-top: 12px; }

/* ---------- modal / toast ---------- */
dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h3 { margin: 0 0 8px; font-size: 19px; }
dialog p { margin: 0 0 12px; color: var(--muted); }
dialog ul { margin: 0 0 14px; padding-left: 20px; max-height: 40vh; overflow: auto; }
dialog li { margin: 4px 0; }
.dialog-actions { display: grid; gap: 10px; margin-top: 16px; }
dialog.photo-view { width: min(900px, calc(100vw - 16px)); padding: 8px; background: #000; border-color: #000; }
dialog.photo-view img { max-height: 80dvh; margin: 0 auto; border-radius: 8px; }
dialog.photo-view .btn { margin-top: 8px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  max-width: calc(100vw - 32px);
  z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 99px;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--brand-ink);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { padding: 18px; text-align: center; color: var(--muted); }
.foot { margin-top: 28px; text-align: center; font-size: 13px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0s !important; }
}

/* ---------- archive ---------- */
select.field {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.arch-day { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); }
.arch-item { grid-template-columns: 1fr auto; }
.arch-main { display: grid; gap: 2px; text-decoration: none; min-width: 0; }
.arch-main .area-name { font-size: 17px; }
.arch-venue { font-weight: 650; color: var(--ink); }
.arch-item .btn { min-width: 64px; }
.top-inner .btn.small { min-height: 36px; }
.arch-day .btn { white-space: nowrap; flex: 0 0 auto; }
