:root, html[data-theme="light"] {
  --bg: #f4efe8;
  --paper: #fffcf8;
  --ink: #2b2723;
  --muted: #7a7168;
  --line: #e6ddd3;
  --sage: #5d7a68;
  --sage-soft: #e7efe9;
  --clay: #c26b4a;
  --glow: #fbeee3;
  --shadow: 0 10px 30px rgba(60, 45, 30, .07);
  --sans: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", sans-serif;
}
html[data-theme="dark"] {
  --bg: #161412;
  --paper: #221f1c;
  --ink: #f4eee7;
  --muted: #b0a59a;
  --line: #3a342e;
  --sage: #8fad9a;
  --sage-soft: #2a332e;
  --clay: #e08a6c;
  --glow: #2a221c;
  --shadow: 0 12px 32px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--ui); }
body { background: radial-gradient(900px 400px at 10% -10%, var(--glow) 0%, transparent 55%), var(--bg); }
h1, h2, h3 { font-family: var(--sans); font-weight: 600; letter-spacing: -.02em; }
a { color: var(--sage); }

body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  width: 100%; max-width: 420px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px 26px;
  box-shadow: var(--shadow);
}
h1 { margin: 0 0 8px; font-size: 1.65rem; }
.sub { color: var(--muted); font-size: .95rem; margin: 0 0 22px; line-height: 1.5; }
label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
input, select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); color: var(--ink); font-size: 1rem; margin-bottom: 12px; font-family: var(--ui);
}
html[data-theme="light"] input, html[data-theme="light"] select { background: #fff; }
input:focus, select:focus { outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }
button, .btn {
  padding: 10px 16px; border: 0; border-radius: 999px; background: var(--sage);
  color: #fff; font-weight: 600; font-size: .92rem; cursor: pointer; font-family: var(--ui);
}
html[data-theme="dark"] button, html[data-theme="dark"] .btn { color: #162018; }
button:hover { filter: brightness(1.05); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--clay); border: 0; }
button:disabled { opacity: .5; cursor: wait; }
.err {
  display: none; margin: 0 0 14px; padding: 10px 12px; border-radius: 12px;
  background: #fbece7; color: #8a3d2a; font-size: .88rem;
}
html[data-theme="dark"] .err { background: #3a241e; color: #f0c4b6; }
.err.show { display: block; }

.app { max-width: 720px; margin: 0 auto; padding: 12px 16px 72px; }
.bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
}
.burger {
  width: 44px; height: 44px; border-radius: 14px; background: var(--paper);
  border: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px; padding: 0;
  color: var(--ink);
}
.burger i { display: block; width: 18px; height: 1.5px; background: currentColor; border-radius: 2px; }
.bar h1 { margin: 0; font-size: 1.55rem; flex: 1; }
.who { color: var(--muted); font-size: .85rem; }
.hint { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.view { display: none; }
.view.on { display: block; }
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px 16px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.panel h2 { margin: 0 0 12px; font-size: 1.15rem; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-nav strong { font-family: var(--sans); font-size: 1.05rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { text-align: center; color: var(--muted); font-size: .7rem; padding: 4px 0; }
.day {
  aspect-ratio: 1; border: 0; border-radius: 12px; background: transparent;
  color: var(--ink); font-size: .85rem; padding: 0; position: relative;
}
.day.mute { color: var(--muted); opacity: .4; }
.day.has::after {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--sage);
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
}
.day.sel { background: var(--sage); color: #fff; }
html[data-theme="dark"] .day.sel { color: #162018; }
.day.sel.has::after { background: currentColor; }
.day.today:not(.sel) { box-shadow: inset 0 0 0 1.5px var(--sage); }
.ev, .item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.ev:last-child, .item:last-child { border-bottom: 0; }
.ev .t, .item .txt { font-weight: 600; flex: 1; }
.ev .m, .item .by { color: var(--muted); font-size: .8rem; margin-top: 2px; font-weight: 400; }
.list-card { margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.list-card:last-child { border-bottom: 0; margin-bottom: 0; }
.list-card h3 { margin: 0 0 8px; font-size: 1.05rem; font-family: var(--sans); }
.badge {
  display: inline-block; font-size: .68rem; color: var(--sage); background: var(--sage-soft);
  padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 600;
}
.item { justify-content: flex-start; }
.item.done .txt { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.item input[type=checkbox] { width: auto; margin: 3px 0 0; accent-color: var(--sage); }
.row { display: flex; gap: 8px; align-items: center; }
.row input, .row select { margin: 0; flex: 1; }
#adminNav { display: none; }

.scrim {
  position: fixed; inset: 0; background: rgba(30, 24, 18, .35); opacity: 0;
  pointer-events: none; transition: opacity .2s; z-index: 40;
}
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 86vw);
  background: var(--paper); z-index: 50; transform: translateX(-105%);
  transition: transform .22s ease; padding: 22px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.drawer.on { transform: none; }
.drawer .hi { font-family: var(--sans); font-size: 1.3rem; margin: 8px 0 18px; }
.navbtn {
  display: block; width: 100%; text-align: left; background: transparent;
  color: var(--ink); border: 0; border-radius: 12px; padding: 12px 12px;
  font-size: 1.05rem; font-weight: 600;
}
.navbtn:hover, .navbtn.on { background: var(--sage-soft); color: var(--sage); }
.navbtn.dim { color: var(--muted); font-weight: 500; font-size: .95rem; }
.switch {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px; margin-top: 8px;
}
.switch span { font-weight: 600; }
.switch button { min-width: 92px; }
