:root {
  --sun: #e8a33d;
  --terracotta: #b5451f;
  --terracotta-dark: #8f3416;
  --ink: #2a2118;
  --paper: #fbf6ee;
  --card: #ffffff;
  --muted: #8a7d6d;
  --line: #ece1d2;
  --danger: #c0392b;
  --shadow: 0 10px 30px rgba(70, 45, 20, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, #fdeccd 0%, transparent 60%),
    var(--paper);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  max-width: 900px; margin: 0 auto;
  padding: 14px 18px calc(14px + env(safe-area-inset-top));
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
}
.brand__kicker {
  font-size: 12px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--terracotta); font-weight: 600;
}
.brand__title {
  font-family: "Fraunces", serif; font-weight: 600;
  font-size: clamp(30px, 8vw, 44px); line-height: .95; margin: 2px 0 0;
}
.brand__right { display: flex; align-items: center; gap: 12px; }
.brand__meta { font-size: 12px; color: var(--muted); text-align: right; }
.btn--ghost {
  background: transparent; color: var(--terracotta); border: 1px solid var(--line);
  padding: 8px 14px; font-size: 14px;
}

.invite__hint { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 6px; }
.invite__result { display: flex; gap: 8px; margin-top: 14px; }
.invite__result input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 13px; background: var(--paper); font-family: inherit;
}

/* Feed */
.feed { max-width: 900px; margin: 0 auto; padding: 22px 16px 120px; }
.state { text-align: center; color: var(--muted); padding: 48px 12px; }
.state--error { color: var(--danger); }

.day { margin-bottom: 34px; }
.day__header {
  position: sticky; top: 74px; z-index: 5;
  display: flex; align-items: baseline; gap: 10px;
  padding: 6px 0; margin-bottom: 12px;
  background: linear-gradient(var(--paper) 60%, transparent);
}
.day__date { font-family: "Fraunces", serif; font-size: 22px; font-weight: 600; }
.day__count { font-size: 13px; color: var(--muted); }

.grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.tile {
  position: relative; border: none; padding: 0; margin: 0; cursor: pointer;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); aspect-ratio: 1 / 1;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile__badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 3px 8px; display: flex; align-items: center; gap: 4px;
}
.tile__caption {
  position: absolute; inset: auto 0 0 0; padding: 18px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  color: #fff; font-size: 12px; text-align: left;
}

.note {
  grid-column: 1 / -1;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; border-left: 4px solid var(--sun);
  font-size: 15px; line-height: 1.5; white-space: pre-wrap;
}
.note.is-owned { cursor: default; }
.note__del, .tile__del { display: none; }

/* FAB */
.fab {
  position: fixed; right: 20px; bottom: calc(22px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: var(--terracotta); color: #fff; font-size: 32px; line-height: 1;
  box-shadow: 0 12px 26px rgba(150, 55, 20, .4); cursor: pointer; z-index: 20;
  transition: transform .12s ease;
}
.fab:active { transform: scale(.94); }

/* Buttons */
.btn {
  border: none; border-radius: 12px; padding: 12px 18px; font-size: 15px;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn--primary { background: var(--terracotta); color: #fff; }
.btn--primary:disabled { opacity: .5; cursor: default; }
.btn--danger { background: var(--danger); color: #fff; }
.icon-btn {
  border: none; background: transparent; font-size: 18px; cursor: pointer;
  color: inherit; width: 36px; height: 36px; border-radius: 8px;
}

/* Sheet (bottom) */
.sheet {
  border: none; padding: 0; border-radius: 20px 20px 0 0; width: 100%;
  max-width: 560px; margin: auto auto 0; background: var(--card);
  box-shadow: 0 -10px 40px rgba(0,0,0,.25);
}
.sheet::backdrop { background: rgba(30,20,10,.45); }
.sheet__form { padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet__tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  flex: 1; border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 9px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.tab.is-active { background: var(--terracotta); color: #fff; border-color: var(--terracotta); }

.picker {
  display: block; border: 2px dashed var(--line); border-radius: 14px;
  padding: 22px; text-align: center; color: var(--terracotta); font-weight: 600;
  cursor: pointer; margin-bottom: 12px;
}
.picker input { display: none; }

.queue { display: flex; flex-direction: column; gap: 12px; max-height: 46vh; overflow: auto; }
.qitem { display: flex; gap: 12px; align-items: flex-start; }
.qitem__thumb {
  width: 72px; height: 72px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--line);
}
.qitem__fields { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.qitem input[type="text"], .qitem input[type="date"], .note-text, .field input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  font-size: 14px; font-family: inherit; background: var(--paper);
}
.qitem__status { font-size: 12px; color: var(--muted); }
.qitem__status.is-done { color: #2e7d32; }
.qitem__status.is-error { color: var(--danger); }

.note-text { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 13px; color: var(--muted); }

.sheet__foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.sheet__foot .btn { margin-left: auto; }
.progress { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.progress__bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; position: relative; }
.progress__bar::after {
  content: ""; position: absolute; inset: 0; width: var(--pct, 0%);
  background: var(--terracotta); transition: width .2s ease;
}

/* Lightbox */
.lightbox { border: none; padding: 0; background: transparent; max-width: 100vw; max-height: 100dvh; width: 100%; height: 100%; }
.lightbox::backdrop { background: rgba(10,8,6,.92); }
.lightbox__close { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 12px; color: #fff; font-size: 22px; z-index: 2; }
.lightbox__stage { display: flex; align-items: center; justify-content: center; height: 100dvh; padding: 12px; }
.lightbox__stage img, .lightbox__stage video { max-width: 100%; max-height: 82dvh; border-radius: 10px; }
.lightbox__bar {
  position: fixed; inset: auto 0 0 0; padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
}
.lightbox__caption { color: #fff; font-size: 14px; margin: 0; flex: 1; }
