:root {
  --bg: #16140f; --panel: #211e17; --panel2: #2a261d; --line: #3d372a;
  --ink: #ece4d2; --muted: #a39a85; --accent: #d9a441; --accent-ink: #1a1408;
  --danger: #d0604d; --secret: #8b5cc4; --good: #6fb37a;
  --radius: 10px; --serif: 'Cormorant Garamond', Georgia, serif; --sans: Inter, system-ui, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4eee1; --panel: #fffaf0; --panel2: #f1e8d6; --line: #dccfb4; --ink: #2b2417; --muted: #7a6e57; --accent: #a8741a; --accent-ink: #fff; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--serif); margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.25rem; } h4 { font-size: 1.1rem; }
.muted { color: var(--muted); } .small, small { font-size: .82rem; } .pad { padding: 0 4px; }
.pre { white-space: pre-wrap; margin: .3em 0; } .bad { color: var(--danger); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font: 700 1.4rem var(--serif); color: var(--ink); letter-spacing: .02em; }
#topnav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
main { max-width: 1180px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.narrow { max-width: 460px; margin: 30px auto; width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row.spread { justify-content: space-between; margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.lbl { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.inline { display: inline-flex; gap: 6px; align-items: center; }

input, select, textarea, button, .button {
  font: inherit; color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 36px; width: 60px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button { cursor: pointer; display: inline-block; font-weight: 500; }
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: wait; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
button.small, .button.small { padding: 4px 9px; font-size: .85rem; }
button.link { background: none; border: 0; color: var(--accent); padding: 0 4px; }
button.on { background: var(--accent); color: var(--accent-ink); }
.w-num { width: 74px; } .w-year { width: 88px; } .w-day { width: 64px; } .grow { flex: 1 1 200px; }
.datepick { display: inline-flex; gap: 4px; flex-wrap: wrap; }

.tbl { width: 100%; border-collapse: collapse; } .tbl td, .tbl th { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.camplist { list-style: none; padding: 0; margin: 0; }
.camplist li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.camplist a { display: flex; gap: 10px; align-items: center; font-size: 1.1rem; }
.role { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: 2px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-left: 8px; }
.role.gm { color: var(--accent); border-color: var(--accent); }
.listrow { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.listrow:last-child { border-bottom: 0; }

/* now bar */
.nowbar { background: linear-gradient(135deg, var(--panel), var(--panel2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.now-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; } .now-title h1 { margin: 0; }
.now-date { font: 700 1.35rem var(--serif); color: var(--ink); display: block; }
.now-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.passtime { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-top: 10px; border-top: 1px dashed var(--line); }
.chip { display: inline-block; color: #fff; font-size: .75rem; padding: 1px 7px; border-radius: 99px; margin: 1px 2px 1px 0; text-shadow: 0 1px 1px rgba(0,0,0,.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.moon { font-size: 1.05rem; }
.vis { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; border: 1px solid transparent; }
.vis.v0 { background: #000; color: #8b8b8b; border-color: #444; } .vis.v1 { background: #1d2333; color: #9aa6c4; }
.vis.v2 { background: #36405a; color: #d3dbef; } .vis.v3 { background: #6b6a58; color: #fff8dc; }
.vis.v4 { background: #c9a548; color: #241a03; } .vis.v5 { background: #f4dc80; color: #3a2a00; }
.nowtag { font: 600 .65rem var(--sans); letter-spacing: .1em; background: var(--accent); color: var(--accent-ink); padding: 2px 6px; border-radius: 4px; margin-left: 8px; vertical-align: middle; }
.secret-tag { font: 600 .68rem var(--sans); color: #fff; background: var(--secret); padding: 2px 6px; border-radius: 4px; margin-right: 6px; vertical-align: middle; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* calendar */
.calbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.calbar h2 { margin: 0 6px; }
.seg { display: inline-flex; } .seg button { border-radius: 0; } .seg button:first-child { border-radius: 7px 0 0 7px; } .seg button:last-child { border-radius: 0 7px 7px 0; }
.jump { display: inline-flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.grid-head, .grid, .grid-free { display: grid; gap: 4px; }
.grid-head div { text-align: center; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 0; overflow: hidden; }
.daycell { min-height: 92px; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 5px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; overflow: hidden; min-width: 0; }
.daycell:hover { border-color: var(--accent); }
.daycell.empty { background: transparent; border-style: dashed; opacity: .35; }
.daycell.past { opacity: .72; }
.daycell.today { border: 2px solid var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); opacity: 1; }
.daycell.festival { background: color-mix(in srgb, var(--accent) 14%, var(--panel2)); }
.dc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.dnum { font: 700 1.05rem var(--serif); }
.dc-icons { font-size: .85rem; white-space: nowrap; }
.evline { font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evline.secret { color: var(--secret); }

.weeklist { display: flex; flex-direction: column; gap: 8px; }
.weekrow { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; color: var(--ink); }
.weekrow:hover { border-color: var(--accent); } .weekrow.today { border: 2px solid var(--accent); }
.wr-shifts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.shiftbox { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px; min-width: 0; }
.shiftbox.now { border-color: var(--accent); }
.sb-head { display: flex; justify-content: space-between; gap: 4px; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
.sb-act { font-size: .85rem; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

/* day */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kv > div { display: flex; flex-direction: column; gap: 2px; }
.dayedit { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.shifts { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.shiftcard { display: flex; flex-direction: column; gap: 6px; }
.shiftcard.now { border: 2px solid var(--accent); }
.event { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 10px; background: var(--panel2); }
.event.secret { border-left: 4px solid var(--secret); }
.event.editing { border-color: var(--accent); }
.enotes { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.enote { background: var(--panel); border-radius: 6px; padding: 6px 10px; border-left: 3px solid var(--line); }
.event .row textarea { flex: 1 1 240px; width: auto; }

/* travel */
.result { background: var(--panel2); border-radius: 8px; padding: 12px; margin-top: 12px; border-left: 4px solid var(--accent); }
.result ul { margin: .3em 0 0; padding-left: 1.2em; }
.depart { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
details summary { cursor: pointer; color: var(--accent); margin: 8px 0; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 8px; transition: transform .25s; z-index: 20; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); } #toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 720px) {
  main { padding: 10px; }
  .daycell { min-height: 58px; padding: 3px; }
  .daycell .chip, .daycell .evline { display: none; }
  .daycell .dc-icons { font-size: .7rem; }
  .daycell.has-ev::after { content: '•'; color: var(--accent); font-size: 1.2rem; line-height: .6; }
  .weekrow { grid-template-columns: 1fr; }
  .wr-shifts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jump { margin-left: 0; }
  h1 { font-size: 1.5rem; }
}

/* seasons */
.season { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel2); white-space: nowrap; }
.season.s-spring { border-color: #6fb37a; color: #6fb37a; } .season.s-summer { border-color: #d9a441; color: #d9a441; }
.season.s-autumn { border-color: #c0632b; color: #c0632b; } .season.s-winter { border-color: #6fa3d0; color: #6fa3d0; }
.seasonseg { margin-right: 10px; white-space: nowrap; }
.seasonline { margin: -4px 0 10px; }
.seasonrow { margin-top: 4px; flex-wrap: nowrap; gap: 6px; } .seasonrow > input, .seasonrow > select { width: auto; min-width: 0; }
.seasonrow input.grow { flex: 1 1 110px; } .seasonrow select[data-k=month] { flex: 0 1 150px; } .seasonrow select[data-k=type] { flex: 0 1 120px; }
.seasonmap { max-height: 320px; overflow: auto; } .seasonmap .tbl td { padding: 3px 6px; }
.builderwrap { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 6px 0; }
.tbl.builder td, .tbl.builder th { padding: 3px 4px; } .tbl.builder select { max-width: 9rem; }
.tbl.baseline td { padding: 4px 6px; vertical-align: top; } .tbl.baseline td:first-child { width: 1%; }

/* tooltips */
.tip { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 6px; border-radius: 50%;
  border: 1px solid var(--muted); color: var(--muted); font: 600 .68rem/1 var(--sans); text-transform: none; letter-spacing: 0; cursor: help; vertical-align: middle; }
.tip:hover, .tip:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
#tipbox { position: fixed; z-index: 50; max-width: min(320px, calc(100vw - 16px)); padding: 8px 10px; border-radius: 7px; pointer-events: none;
  background: var(--ink); color: var(--bg); font: 400 .82rem/1.4 var(--sans); white-space: pre-line; box-shadow: 0 4px 14px rgb(0 0 0 / .35);
  opacity: 0; visibility: hidden; transition: opacity .12s; }
#tipbox.show { opacity: 1; visibility: visible; }
.lightlv { display: flex; gap: 8px; flex-wrap: wrap; }
.lightlv > span { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.lightlv.off { opacity: .5; }
