:root {
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --bg: #f6f5f2;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-2: #fbfbfa;
  --ink: #111110;
  --muted: #53504a;
  --muted-2: #6b6760;
  --border: rgba(24, 24, 21, 0.12);
  --border-strong: rgba(24, 24, 21, 0.18);

  --accent: #f59e0b;
  --accent-2: #fb7185;
  --ring: rgba(245, 158, 11, 0.22);

  --ok: #047857;
  --bad: #be123c;
  --info: #1d4ed8;
  --modified: #6d28d9;

  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 11px;

  --shadow-sm: 0 1px 2px rgba(17, 17, 16, 0.06), 0 12px 22px rgba(17, 17, 16, 0.05);
  --shadow-md: 0 18px 48px rgba(17, 17, 16, 0.14);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 900px at 18% 12%, rgba(245,158,11,0.14), transparent 55%),
    radial-gradient(1000px 780px at 86% 22%, rgba(29,78,216,0.10), transparent 58%),
    radial-gradient(900px 720px at 40% 92%, rgba(190,18,60,0.08), transparent 60%),
    linear-gradient(transparent, transparent);
  filter: saturate(1.02);
  opacity: 0.9;
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 360px 1fr;
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: sticky; top: 0; z-index: 2; }
}

.rail {
  background: rgba(255,255,255,0.72);
  border-right: 1px solid var(--border);
  padding: 1rem 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.75rem;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(180px 120px at 12% 20%, rgba(245,158,11,0.28), transparent 62%),
    radial-gradient(240px 160px at 88% 10%, rgba(29,78,216,0.12), transparent 65%),
    linear-gradient(135deg, rgba(255,255,255,0.75), rgba(255,255,255,0.35));
  border: 1px solid rgba(24, 24, 21, 0.10);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
}
.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffb224, #f59e0b);
  display: grid;
  place-items: center;
  color: #0b0a08;
  flex-shrink: 0;
  box-shadow: 0 16px 30px rgba(245,158,11,0.28);
}
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: -0.03em;
}
.brand p {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.82);
  box-shadow: var(--shadow-sm);
  padding: 0.95rem;
  backdrop-filter: blur(10px);
}

.label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 0.35rem;
}
.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
  outline: none;
  background: rgba(255,255,255,0.92);
  color: var(--ink);
}
.input:focus {
  border-color: rgba(245,158,11,0.55);
  box-shadow: 0 0 0 4px var(--ring);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-md) + 1px);
  padding: 0.7rem 0.9rem;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn-small {
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.tips {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.55;
  display: grid;
  gap: 0.25rem;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #1c1917, #111110); color: #fff; }
.btn-primary:hover { background: linear-gradient(180deg, #292524, #151413); }
.btn-ghost { background: rgba(255,255,255,0.88); border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { border-color: rgba(245,158,11,0.45); color: #7c2d12; }

.btn:focus-visible,
.input:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255,255,255,0.72);
}
.pill.ok { border-color: rgba(4,120,87,0.28); background: rgba(4,120,87,0.10); color: var(--ok); }
.pill.bad { border-color: rgba(190,18,60,0.28); background: rgba(190,18,60,0.10); color: var(--bad); }

.main { padding: 1.25rem; min-width: 0; }
.main-inner { display: grid; grid-template-rows: auto 1fr; gap: 0.9rem; min-height: calc(100dvh - 2.5rem); }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}
.topbar h2 { margin: 0; font-family: var(--font-display); font-size: 1.1rem; letter-spacing: -0.02em; }
.topbar .muted { font-size: 0.85rem; color: var(--muted-2); }

.topbar-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.62);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
}

.rail-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.tool-switch--rail {
  width: 100%;
  justify-content: flex-start;
  padding: 0.65rem 0.75rem;
}

.tool-switch--rail .tool-switch-text {
  display: inline;
  font-size: 0.82rem;
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.7) inset;
  border: 1px solid rgba(17,17,16,0.12);
}
.legend-dot.pending { background: var(--accent); }
.legend-dot.confirmed { background: var(--ok); }
.legend-dot.cancelled { background: var(--bad); }
.legend-dot.waitlist { background: var(--info); }
.legend-dot.modified { background: var(--modified); }

.tool-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.45rem 0.65rem;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tool-switch:hover {
  border-color: rgba(245,158,11,0.38);
  background: rgba(245,158,11,0.10);
}

.tool-switch:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.tool-switch[aria-pressed="true"] {
  border-color: rgba(245,158,11,0.45);
  background: rgba(245,158,11,0.14);
  color: var(--ink);
}

.tool-switch-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(24,24,21,0.10);
}

.tool-switch[aria-pressed="true"] .tool-switch-icon {
  background: rgba(245,158,11,0.18);
  border-color: rgba(245,158,11,0.22);
}

.tool-switch-text {
  font-size: 0.78rem;
  display: none;
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.helper {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted-2);
  line-height: 1.35;
}

@media (max-width: 520px) {
  .edit-grid { grid-template-columns: 1fr; }
}

/* Toasts */
.toast-wrap {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: grid;
  gap: 0.6rem;
  width: min(380px, calc(100vw - 2rem));
}
.toast {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}
.toast .icon {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.toast.success .icon { background: rgba(4,120,87,0.12); color: var(--ok); border-color: rgba(4,120,87,0.22); }
.toast.error .icon { background: rgba(190,18,60,0.12); color: var(--bad); border-color: rgba(190,18,60,0.22); }
.toast .title { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; }
.toast .msg { margin-top: 0.15rem; color: var(--muted); font-size: 0.92rem; line-height: 1.35; }

/* Modal */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(12,10,9,0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 31;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.modal-card {
  width: min(520px, 92vw);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal-head {
  padding: 1rem 1rem 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.03em; }
.modal-desc { color: var(--muted-2); font-size: 0.9rem; line-height: 1.35; margin-top: 0.15rem; }
.modal-actions { padding: 0.85rem 1rem 1rem; display: flex; justify-content: flex-end; }

.modal.is-open,
.modal-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

html[data-theme="dark"] .toast,
html[data-theme="dark"] .modal-card {
  background: rgba(18,17,16,0.78);
  border-color: var(--border);
}
html[data-theme="dark"] .toast .msg { color: var(--muted); }

@media (min-width: 980px) {
  .tool-switch-text { display: inline; }
}

#calendar {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.86);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem;
  min-height: 650px;
  backdrop-filter: blur(10px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(520px, 92vw);
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transform: translateX(110%);
  transition: transform 0.18s ease;
  z-index: 10;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.drawer-head h3 { margin: 0; font-family: var(--font-display); font-size: 1.05rem; }
.drawer-body { padding: 1rem; overflow: auto; display: grid; gap: 0.85rem; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 0.4rem 0.85rem; font-size: 0.92rem; }
.kv .k { color: var(--muted-2); font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 9, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 9;
}
.overlay.on { opacity: 1; pointer-events: auto; }

/* FullCalendar restyle (tools-grade) */
.fc {
  font-family: var(--font-sans);
}
.fc .fc-toolbar-title {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}
.fc .fc-button {
  border-radius: 999px !important;
  border: 1px solid var(--border) !important;
  background: rgba(255,255,255,0.80) !important;
  color: var(--ink) !important;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
}
.fc .fc-button:hover {
  border-color: rgba(245,158,11,0.45) !important;
  color: #7c2d12 !important;
}
.fc .fc-button:focus {
  box-shadow: 0 0 0 4px var(--ring) !important;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: rgba(17,17,16,0.92) !important;
  color: #fff !important;
  border-color: rgba(17,17,16,0.25) !important;
}
.fc .fc-col-header-cell-cushion {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.fc .fc-daygrid-day-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.fc .fc-day-today {
  background: rgba(245,158,11,0.12) !important;
}
.fc .fc-event {
  border-radius: 12px;
  border: 1px solid rgba(17,17,16,0.10);
  box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset;
}
.fc .fc-event:hover {
  filter: saturate(1.05);
  transform: translateY(-0.5px);
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .btn, .drawer, .overlay, .fc .fc-event { transition: none !important; }
  .fc .fc-event:hover { transform: none !important; }
}

/* Dark mode */
html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="dark"] body {
  background: #0c0b0a;
}
html[data-theme="dark"] body::before {
  opacity: 0.85;
  background:
    radial-gradient(1200px 900px at 18% 12%, rgba(245,158,11,0.14), transparent 55%),
    radial-gradient(1000px 780px at 86% 22%, rgba(29,78,216,0.12), transparent 58%),
    radial-gradient(900px 720px at 40% 92%, rgba(190,18,60,0.12), transparent 60%),
    linear-gradient(transparent, transparent);
}
html[data-theme="dark"] {
  --bg: #0c0b0a;
  --surface: rgba(18, 17, 16, 0.72);
  --surface-solid: #121110;
  --surface-2: #141312;
  --ink: #f4f1ea;
  --muted: rgba(244, 241, 234, 0.74);
  --muted-2: rgba(244, 241, 234, 0.62);
  --border: rgba(244, 241, 234, 0.14);
  --border-strong: rgba(244, 241, 234, 0.22);
  --ring: rgba(245, 158, 11, 0.28);
}
html[data-theme="dark"] .rail,
html[data-theme="dark"] .card,
html[data-theme="dark"] #calendar,
html[data-theme="dark"] .topbar {
  background: rgba(18, 17, 16, 0.70);
  border-color: var(--border);
}
html[data-theme="dark"] .btn-ghost {
  background: rgba(18, 17, 16, 0.72);
  color: var(--ink);
}
html[data-theme="dark"] .fc .fc-button {
  background: rgba(18, 17, 16, 0.72) !important;
  color: var(--ink) !important;
}

html[data-theme="dark"] .topbar-tools {
  background: rgba(18, 17, 16, 0.60);
  border-color: var(--border);
}

html[data-theme="dark"] .tool-switch-icon {
  background: rgba(18, 17, 16, 0.72);
  border-color: var(--border);
}

html[data-theme="dark"] .legend-dot {
  box-shadow: 0 0 0 3px rgba(18,17,16,0.7) inset;
  border-color: var(--border);
}
html[data-theme="dark"] .fc .fc-daygrid-day-number,
html[data-theme="dark"] .fc .fc-col-header-cell-cushion {
  color: var(--muted-2);
}

