:root {
  --paper: #f7f3ec;
  --paper-deep: #efe8dc;
  --ink: #221e18;
  --ink-soft: #6b6257;
  --gold: #b8892e;
  --gold-bright: #d4a94b;
  --line: #ded4c4;
  --card: #fffdf9;
  --danger: #c0392b;
  --shadow: 0 18px 50px -18px rgba(60, 45, 20, 0.35);
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Archivo', system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(212, 169, 75, 0.14), transparent 60%),
    var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 272px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #262019, #1b1712 70%);
  color: #efe7d8;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.brand { display: flex; flex-direction: column; gap: 10px; }
.brand-logo { width: 190px; height: auto; display: block; }
.brand-sub { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.18em; color: var(--gold-bright); }

.side-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.2em;
  color: #9a8f7d; margin-bottom: 12px; font-weight: 600;
}
.side-hint { font-size: 0.78rem; color: #b3a894; line-height: 1.5; margin-bottom: 10px; }
.side-hint em { color: #e8dcc4; font-style: normal; font-weight: 600; }

.cal-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.cal-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 8px; cursor: pointer;
  font-size: 0.85rem; user-select: none;
  transition: background 0.15s;
}
.cal-item:hover { background: rgba(255, 255, 255, 0.06); }
.cal-item.off { opacity: 0.42; }
.cal-swatch {
  width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.cal-item .tick { margin-left: auto; font-size: 0.75rem; color: var(--gold-bright); }

.feed-btn {
  width: 100%;
  background: transparent; color: var(--gold-bright);
  border: 1px solid rgba(212, 169, 75, 0.5);
  padding: 9px 12px; border-radius: 8px;
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.feed-btn:hover { background: rgba(212, 169, 75, 0.12); }

.side-footer { margin-top: auto; }
.side-footer .ghost-btn { color: #cfc4ae; border-color: rgba(207, 196, 174, 0.35); width: 100%; }
.copyright { margin-top: 14px; font-size: 0.68rem; color: #8a8070; text-align: center; letter-spacing: 0.04em; }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; padding: 26px 34px 34px; min-width: 0; }

.topbar { display: flex; align-items: center; gap: 22px; margin-bottom: 22px; }
.month-nav { display: flex; gap: 6px; }
.nav-btn {
  background: var(--card); border: 1px solid var(--line);
  width: 38px; height: 38px; border-radius: 9px;
  font-size: 1.2rem; color: var(--ink); cursor: pointer;
  transition: all 0.15s;
}
.today-btn { width: auto; padding: 0 14px; font-size: 0.82rem; font-weight: 600; font-family: inherit; }
.nav-btn:hover { border-color: var(--gold); color: var(--gold); }

.month-title {
  font-family: 'Fraunces', serif;
  font-size: 2.1rem; font-weight: 600; letter-spacing: -0.01em;
}
.month-title .yr { color: var(--gold); }

.tz-badge {
  margin-left: auto;
  font-size: 0.74rem; font-weight: 600; color: var(--ink-soft);
  background: var(--paper-deep); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 99px;
  cursor: help; white-space: nowrap;
}

.add-btn {
  background: var(--ink); color: #f5eede;
  border: none; padding: 11px 20px; border-radius: 9px;
  font-family: inherit; font-size: 0.86rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.add-btn:hover { background: var(--gold); color: #1b1712; }

/* ---------- Grid ---------- */
.grid-wrap {
  flex: 1; display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden; box-shadow: var(--shadow);
}
.weekday-row {
  display: grid; grid-template-columns: 52px repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}
.weekday-row div {
  padding: 10px 12px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-soft);
}
.weekday-row div:first-child { text-align: center; }

.month-grid { flex: 1; display: grid; grid-auto-rows: 1fr; }
.week-row { display: grid; grid-template-columns: 52px repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.week-row:last-child { border-bottom: none; }
.cw-cell {
  display: grid; place-items: center;
  font-size: 0.68rem; font-weight: 700; color: var(--gold);
  background: var(--paper-deep); border-right: 1px solid var(--line);
  letter-spacing: 0.05em;
}
.day-cell {
  border-right: 1px solid var(--line);
  padding: 7px 8px 8px;
  min-height: 96px;
  min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; position: relative;
  transition: background 0.12s;
}
.day-cell:last-child { border-right: none; }
.day-cell:hover { background: rgba(212, 169, 75, 0.07); }
.day-cell.other { background: repeating-linear-gradient(-45deg, transparent 0 7px, rgba(120,105,80,0.045) 7px 8px); }
.day-cell.other .day-num { color: #c0b5a2; }
.day-cell.today { background: rgba(212, 169, 75, 0.14); }
.day-cell.today .day-num {
  background: var(--gold); color: #fff;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
}
.day-num { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); align-self: flex-end; }

.chip {
  font-size: 0.72rem; font-weight: 600; line-height: 1.25;
  color: #fff; border-radius: 5px; padding: 3px 7px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  flex-shrink: 0; text-align: left; border: none; cursor: pointer;
  font-family: inherit; width: 100%;
  transition: transform 0.1s, filter 0.1s;
}
.chip:hover { filter: brightness(1.08); transform: translateX(1px); }
.chip .t { font-weight: 400; opacity: 0.85; margin-right: 4px; }

/* ---------- Modal ---------- */
.overlay[hidden] { display: none; }
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(30, 24, 15, 0.5);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(480px, 92vw);
  background: var(--card);
  border-radius: 16px; padding: 26px 28px;
  box-shadow: var(--shadow);
  animation: pop 0.18s cubic-bezier(0.2, 1.4, 0.5, 1);
}
@keyframes pop { from { transform: scale(0.94); opacity: 0; } }
.modal-title { font-family: 'Fraunces', serif; font-size: 1.4rem; font-weight: 600; margin-bottom: 18px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; flex: 1; }
.field > span { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-soft); }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .field select, .field textarea {
  font-family: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; outline: none; transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); }
.field-row { display: flex; gap: 14px; align-items: flex-end; }
.check-field { flex-direction: row; align-items: center; gap: 9px; margin-bottom: 13px; }
.check-field > span { text-transform: none; letter-spacing: 0; font-size: 0.84rem; font-weight: 500; color: var(--ink); }
.check-field input { accent-color: var(--gold); width: 16px; height: 16px; }

.modal-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.spacer { flex: 1; }
.ghost-btn {
  background: transparent; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 9px;
  font-family: inherit; font-size: 0.84rem; font-weight: 600; color: var(--ink);
  cursor: pointer; transition: all 0.15s;
}
.ghost-btn:hover { border-color: var(--gold); color: var(--gold); }
.ghost-btn.danger { color: var(--danger); border-color: rgba(192, 57, 43, 0.4); }
.ghost-btn.danger:hover { background: rgba(192, 57, 43, 0.08); border-color: var(--danger); }

.feed-links { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.feed-link {
  display: flex; align-items: center; gap: 10px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font-size: 0.78rem;
}
.feed-link .fname { font-weight: 700; white-space: nowrap; }
.feed-link code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: 0.72rem; }
.feed-link button {
  background: var(--ink); color: #f5eede; border: none;
  padding: 5px 10px; border-radius: 6px; font-family: inherit;
  font-size: 0.72rem; font-weight: 600; cursor: pointer;
}
.feed-link button:hover { background: var(--gold); color: #1b1712; }
.feed-note { margin-top: 4px; color: var(--ink-soft); }

@media print {
  .sidebar, .add-btn, .month-nav { display: none !important; }
  .main { padding: 0; }
  .grid-wrap { box-shadow: none; }
  body { background: #fff; }
}
