/* ═══════════════════════════════════════════════════════════════
   IamBusy — Design System · Modern Neobrutalism
   Thick ink borders, hard offset shadows, flat saturated colour,
   heavy type. No gradients, no blur, no soft shadows.
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens (dark is the default theme) ─────────────────────── */
:root {
  --paper: #17171c;
  --paper-2: #202028;
  --card: #262630;
  --card-2: #1f1f27;
  --ink: #f5f2ea;
  --ink-2: #d9d5ca;
  --muted: #a39f94;
  --line-soft: rgba(245, 242, 234, 0.13);
  color-scheme: dark;

  --yellow: #ffd23f;
  --pink: #ff7bb0;
  --lime: #b9f06b;
  --cyan: #7ee3ff;
  --orange: #ffa552;
  --purple: #c9a7ff;
  --red: #ff6b6b;
  --blue: #79aaff;
  --on-accent: #111111;

  --c-curs: var(--blue);
  --c-seminar: var(--orange);
  --c-lab: var(--purple);
  --c-free: var(--lime);
  --c-busy: var(--pink);
  --c-now: var(--yellow);

  --bw: 3px;
  --bw-thin: 2px;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-lg: 8px 8px 0 var(--ink);
  --r: 12px;
  --r-sm: 7px;
  --r-xs: 4px;

  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  --t-fast: 120ms cubic-bezier(.2, .8, .2, 1);
  --t-base: 180ms cubic-bezier(.2, .8, .2, 1);
}

/* Light theme — opt-in via the toggle in the header */
:root[data-theme="light"] {
  --paper: #f3efe4;
  --paper-2: #e9e3d3;
  --card: #ffffff;
  --card-2: #f8f5ec;
  --ink: #111111;
  --ink-2: #3d3d3d;
  --muted: #6f6a60;
  --line-soft: rgba(17, 17, 17, 0.14);
  color-scheme: light;
}

.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: block; }
:root[data-theme="light"] .theme-toggle .ico-sun { display: block; }
:root[data-theme="light"] .theme-toggle .ico-moon { display: none; }

/* ── Reset ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

:focus-visible {
  outline: var(--bw) solid var(--ink);
  outline-offset: 3px;
}

::selection {
  background: var(--yellow);
  color: #111;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ── Primitives ─────────────────────────────────────────────── */
.box {
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  background: var(--card);
  color: var(--ink);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.btn-icon {
  width: 44px;
  padding: 0;
}

.btn-primary {
  background: var(--yellow);
  color: #111;
}

.btn-accent {
  background: var(--lime);
  color: #111;
}

.btn-danger {
  background: var(--red);
  color: #111;
}

.btn-ghost {
  background: var(--card-2);
}

.btn-sm {
  min-height: 34px;
  padding: 0 var(--sp-3);
  font-size: 0.82rem;
  border-width: var(--bw-thin);
  box-shadow: 2px 2px 0 var(--ink);
}

.btn-sm:hover {
  box-shadow: 3px 3px 0 var(--ink);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-xs);
  background: var(--card);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.4;
}

.tag-yellow { background: var(--yellow); color: #111; }
.tag-pink   { background: var(--pink); color: #111; }
.tag-lime   { background: var(--lime); color: #111; }
.tag-cyan   { background: var(--cyan); color: #111; }
.tag-ink    { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tag-curs   { background: var(--c-curs); color: #111; }
.tag-seminar{ background: var(--c-seminar); color: #111; }
.tag-lab    { background: var(--c-lab); color: #111; }

.kind-C .kind-tag { background: var(--c-curs); color: #111; }
.kind-S .kind-tag { background: var(--c-seminar); color: #111; }
.kind-L .kind-tag { background: var(--c-lab); color: #111; }

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--yellow);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  transform: rotate(-1.5deg);
}

.brand-dot {
  width: 10px;
  height: 10px;
  border: 2px solid #111;
  border-radius: 50%;
  background: var(--pink);
}

.topbar-actions {
  display: flex;
  gap: var(--sp-2);
}

/* ── Hero / status ──────────────────────────────────────────── */
.hero {
  position: relative;
  padding: var(--sp-5);
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero.state-busy { background: var(--c-busy); color: #111; }
.hero.state-free { background: var(--c-free); color: #111; }
.hero.state-off  { background: var(--card); }

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}

.hero.state-busy .tag,
.hero.state-free .tag {
  background: #fff;
  color: #111;
  border-color: #111;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 8px;
  border: var(--bw-thin) solid #111;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.4s ease-in-out infinite;
}

.state-busy .state-dot { background: var(--c-busy); }
.state-free .state-dot { background: var(--c-free); }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.clock {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(2.6rem, 12vw, 4rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  margin: var(--sp-1) 0 var(--sp-3);
}

.clock .sec {
  font-size: 0.45em;
  vertical-align: top;
  margin-left: 4px;
  opacity: 0.75;
}

.status-main {
  font-size: clamp(1.15rem, 4.6vw, 1.45rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.status-sub {
  margin-top: var(--sp-2);
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.85;
}

.hero-summary {
  margin-top: var(--sp-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* ── Date navigation ────────────────────────────────────────── */
.datenav {
  display: grid;
  grid-template-columns: 44px 1fr auto 44px;
  gap: var(--sp-2);
  align-items: stretch;
}

.datenav .today-btn {
  padding: 0 var(--sp-3);
  background: var(--yellow);
  color: #111;
}

.date-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-3) 0 var(--sp-4);
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: 0.98rem;
  text-align: left;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  overflow: hidden;
}

.date-display:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.date-display:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.date-display .date-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-display .chev {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  transition: transform var(--t-base);
}

.date-display[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

/* ── Week strip ─────────────────────────────────────────────── */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.strip-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 7px;
  background: var(--card);
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.strip-day:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}

.strip-day.weekend { background: var(--card-2); }
.strip-day.today { background: var(--yellow); color: #111; }
.strip-day.selected {
  background: var(--ink);
  color: var(--paper);
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.strip-name {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.75;
}

.strip-num {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

/* Tiny 07→22 busy bar */
.busybar {
  position: relative;
  width: 100%;
  height: 6px;
  margin-top: 3px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  overflow: hidden;
  opacity: 0.95;
}

.busybar i {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--c-busy);
}

.busybar i.k-C { background: var(--c-curs); }
.busybar i.k-S { background: var(--c-seminar); }
.busybar i.k-L { background: var(--c-lab); }

.strip-day.selected .busybar { border-color: var(--paper); }

/* ── Section heading ────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-meta {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

/* ── Timeline ───────────────────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.course {
  display: grid;
  grid-template-columns: 64px 1fr;
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  animation: rise 260ms both;
}

.course:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
}

.course.current {
  box-shadow: var(--shadow-lg);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.course-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--sp-3) var(--sp-1);
  border-right: var(--bw) solid var(--ink);
  background: var(--card-2);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.1;
}

.course.kind-C .course-time { background: var(--c-curs); color: #111; }
.course.kind-S .course-time { background: var(--c-seminar); color: #111; }
.course.kind-L .course-time { background: var(--c-lab); color: #111; }

.course-time .t-sep {
  width: 14px;
  height: 2px;
  background: currentColor;
  opacity: 0.6;
  margin: 3px 0;
}

.course-body {
  padding: var(--sp-3) var(--sp-4);
  min-width: 0;
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.now-tag {
  background: var(--c-now);
  color: #111;
  animation: pulse-shadow 1.6s ease-in-out infinite;
}

@keyframes pulse-shadow {
  0%, 100% { box-shadow: 0 0 0 0 var(--ink); }
  50% { box-shadow: 2px 2px 0 0 var(--ink); }
}

.course-subject {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.course-room {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
}

.course-room svg {
  width: 13px;
  height: 13px;
}

.progress {
  position: relative;
  height: 12px;
  margin-top: var(--sp-3);
  border: var(--bw-thin) solid var(--ink);
  border-radius: 999px;
  background: var(--card-2);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, 0.25) 6px 12px);
  transition: width 1s linear;
}

/* Break rows */
.gap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 40px;
  padding: 6px var(--sp-3);
  border: var(--bw-thin) dashed var(--ink);
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
}

.gap.current {
  background: var(--c-free);
  color: #111;
  border-style: solid;
  border-width: var(--bw);
  box-shadow: var(--shadow-sm);
}

.gap.edge {
  color: var(--muted);
}

.gap-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gap-label .mono {
  font-weight: 700;
}

.gap-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-xs);
  background: var(--card);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}

.gap-add:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
  background: var(--yellow);
  color: #111;
}

.gap-add:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.gap-add svg {
  width: 14px;
  height: 14px;
}

/* Empty day */
.empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  background: var(--c-free);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.empty-emoji {
  font-size: 2.4rem;
  line-height: 1;
  margin-bottom: var(--sp-3);
}

.empty-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty-sub {
  margin: 6px 0 var(--sp-4);
  font-weight: 500;
  opacity: 0.8;
}

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: var(--sp-4);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.footer a {
  font-weight: 700;
  border-bottom: 2px solid var(--ink);
  color: var(--ink);
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border: 1.5px solid var(--ink);
  border-bottom-width: 3px;
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.7rem;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   Month calendar popover
   ═══════════════════════════════════════════════════════════════ */
.cal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(17, 17, 17, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.cal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.cal {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 0;
  width: min(100%, 600px);
  max-height: 92vh;
  max-height: 92dvh;
  transform: translate(-50%, 110%);
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-bottom: 0;
  border-radius: var(--r) var(--r) 0 0;
  box-shadow: 0 -6px 0 var(--ink);
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  overflow-y: auto;
  transition: transform 240ms cubic-bezier(.2, .8, .2, 1);
  visibility: hidden;
}

.cal.open {
  transform: translate(-50%, 0);
  visibility: visible;
}

@media (min-width: 640px) {
  /* Anchored to the top so a change in content height never moves the
     day grid under the pointer (which would re-trigger hover in a loop). */
  .cal {
    top: 5vh;
    bottom: auto;
    width: min(94vw, 560px);
    max-height: 90vh;
    border-bottom: var(--bw) solid var(--ink);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    transform: translate(-50%, 12px);
    opacity: 0;
    transition: transform var(--t-base), opacity var(--t-base);
  }

  .cal.open {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.cal-grip {
  width: 44px;
  height: 5px;
  margin: -6px auto 0;
  border-radius: 3px;
  background: var(--ink);
  opacity: 0.35;
}

@media (min-width: 640px) {
  .cal-grip { display: none; }
}

.cal-head {
  display: grid;
  grid-template-columns: 40px 1fr auto 40px;
  gap: var(--sp-2);
  align-items: center;
}

.cal-head .btn-icon {
  width: 40px;
  min-height: 40px;
}

.cal-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: capitalize;
  text-align: center;
}

.cal-title small {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

.cal-grid {
  display: grid;
  grid-template-columns: 30px repeat(7, 1fr);
  gap: 4px;
}

.cal-dow {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
  padding: 2px 0 4px;
}

.cal-wk {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  border-right: var(--bw-thin) solid var(--ink);
  margin-right: 2px;
}

.cal-wk.odd { color: var(--ink); }
.cal-wk.vac { opacity: 0.4; }

.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 50px;
  padding: 5px 3px 5px;
  background: var(--card);
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-xs);
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

/* No transform on hover: the cell must not move under the pointer. */
.cal-day:hover,
.cal-day:focus-visible {
  box-shadow: 3px 3px 0 var(--ink);
  background: var(--card-2);
}

.cal-day.other {
  opacity: 0.4;
}

.cal-day.weekend {
  background: var(--card-2);
}

.cal-day.today {
  background: var(--yellow);
  color: #111;
}

.cal-day.selected {
  background: var(--ink);
  color: var(--paper);
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.cal-day.selected .busybar { border-color: var(--paper); }

.cal-day.free .busybar {
  border-style: dashed;
  opacity: 0.35;
}

.cal-num {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
}

.cal-cnt {
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.7;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.cal-legend i {
  display: inline-block;
  width: 12px;
  height: 8px;
  margin-right: 4px;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  vertical-align: middle;
}

/* Preview of the selected day */
.cal-preview {
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  background: var(--card-2);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.cal-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.cal-preview-head {
  min-height: 28px;
}

.cal-preview-title {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fixed height so hovering different days never changes the sheet's
   size (and therefore never shifts the grid under the pointer). */
.cal-preview-body {
  height: 158px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.cal-preview-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

/* One row = [start / end] | subject + meta, with a colour stripe by kind */
.cal-preview-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 5px 10px 5px 0;
  border: var(--bw-thin) solid var(--ink);
  border-left-width: 8px;
  border-radius: var(--r-xs);
  background: var(--card);
}

.cal-preview-list li.k-C { border-left-color: var(--c-curs); }
.cal-preview-list li.k-S { border-left-color: var(--c-seminar); }
.cal-preview-list li.k-L { border-left-color: var(--c-lab); }
.cal-preview-list li.k-x { border-left-color: var(--c-busy); }
.cal-preview-list li.k-free {
  border-style: dashed;
  border-left-style: solid;
  border-left-color: var(--c-free);
  background: transparent;
}

.cal-preview-list .pt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 52px;
  padding-left: 10px;
  border-right: 1.5px solid var(--line-soft);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.15;
}

.cal-preview-list .pt b {
  font-size: 0.86rem;
  font-weight: 700;
}

.cal-preview-list .pt i {
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.cal-preview-list .ps {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cal-preview-list .ps-subject {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-preview-list li.k-free .ps-subject {
  color: var(--muted);
}

.cal-preview-list .ps-meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-preview-empty {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}

.cal-preview-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: 4px;
}

.cal-preview-actions .btn {
  flex: 1;
}

.cal-preview-actions .btn[hidden] {
  display: none;
}

/* Keep the actions row at a constant height even while buttons are hidden. */
.cal-preview-actions {
  min-height: 44px;
}

/* ═══════════════════════════════════════════════════════════════
   Manage page
   ═══════════════════════════════════════════════════════════════ */
.manage {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.manage-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.manage-title {
  flex: 1;
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  text-transform: uppercase;
}

.manage-title small {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.manage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  background: var(--card);
  overflow: hidden;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 var(--sp-4);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  transition: background var(--t-fast);
}

.seg-btn + .seg-btn {
  border-left: var(--bw) solid var(--ink);
}

.seg-btn[aria-selected="true"] {
  background: var(--ink);
  color: var(--paper);
}

.seg-btn .now-mark {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--yellow);
  color: #111;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 14px;
  height: 10px;
  margin-right: 5px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  vertical-align: -1px;
}

.legend i.only {
  background: repeating-linear-gradient(135deg, var(--card) 0 3px, var(--ink) 3px 4.5px);
}

/* Weekly grid */
.grid-wrap {
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  background: var(--card);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 230px);
  max-height: calc(100dvh - 230px);
  min-height: 380px;
}

.wgrid {
  display: grid;
  grid-template-columns: 58px repeat(7, minmax(128px, 1fr));
  grid-auto-rows: 58px;
  min-width: 100%;
  position: relative;
}

.wgrid > * {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.g-corner,
.g-day {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--card-2);
  border-bottom: var(--bw) solid var(--ink) !important;
}

.g-corner {
  left: 0;
  z-index: 4;
  border-right: var(--bw) solid var(--ink) !important;
}

.g-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.g-day small {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: none;
}

.g-day.weekend {
  color: var(--muted);
}

.g-time {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
  background: var(--card-2);
  border-right: var(--bw) solid var(--ink) !important;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.g-cell {
  position: relative;
  cursor: cell;
  transition: background var(--t-fast);
}

.g-cell:hover {
  background: rgba(255, 210, 63, 0.22);
}

.g-cell.weekend {
  background-image: repeating-linear-gradient(135deg, transparent 0 8px, var(--line-soft) 8px 9px);
}

.g-cell.weekend:hover {
  background-color: rgba(255, 210, 63, 0.22);
}

.g-cell.drop-target {
  background: var(--lime);
  outline: var(--bw-thin) dashed var(--ink);
  outline-offset: -3px;
}

/* Activity cards on the grid */
.act {
  position: absolute;
  left: 4px;
  right: 4px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: var(--card);
  color: #111;
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: grab;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.act.kind-C { background: var(--c-curs); }
.act.kind-S { background: var(--c-seminar); }
.act.kind-L { background: var(--c-lab); }

.act:hover {
  z-index: 2;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.act.dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.act.only-week::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(17, 17, 17, 0.09) 10px 12px);
}

.act-subject {
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.15;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.act-room {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.8;
}

.act-time {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
}

.act-week {
  position: absolute;
  right: 26px;
  top: 5px;
  padding: 1px 5px;
  border: 1.5px solid #111;
  border-radius: 3px;
  background: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.act-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #111;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast);
}

.act:hover .act-del,
.act:focus-within .act-del {
  opacity: 1;
}

.act-del:hover {
  background: var(--red);
}

@media (hover: none) {
  .act-del { opacity: 1; }
}

.drag-ghost {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  opacity: 0.92;
  transform: rotate(-2deg) scale(1.03);
  box-shadow: var(--shadow-lg);
  cursor: grabbing;
}

/* ── Modals ─────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(17, 17, 17, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(0.98);
  transition: transform var(--t-base);
}

.overlay.visible .modal {
  transform: none;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: var(--bw) solid var(--ink);
  background: var(--yellow);
  color: #111;
}

.modal-head.warn { background: var(--orange); }
.modal-head.danger { background: var(--red); }

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.modal-close {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--bw-thin) solid #111;
  border-radius: var(--r-xs);
  background: #fff;
  color: #111;
  font-size: 1.3rem;
  line-height: 1;
  box-shadow: 2px 2px 0 #111;
}

.modal-close:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.modal-body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field .hint {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 500;
}

.input,
.select {
  width: 100%;
  min-height: 46px;
  padding: 0 var(--sp-3);
  background: var(--card);
  color: var(--ink);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

.input:focus,
.select:focus {
  outline: none;
  box-shadow: 4px 4px 0 var(--ink);
  transform: translate(-1px, -1px);
  background: var(--card);
}

.input::placeholder {
  color: var(--muted);
  font-weight: 500;
}

.input[type="time"] {
  font-family: var(--mono);
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: var(--bw-thin) solid var(--ink);
  border-bottom: var(--bw-thin) solid var(--ink);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select {
  padding-right: 36px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

/* Segmented radio for week type */
.choice {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  background: var(--card);
}

.choice label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
}

.choice label + label {
  border-left: var(--bw) solid var(--ink);
}

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.choice input + span {
  display: none;
}

.choice input:checked + span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
}

.choice input:focus-visible + span {
  outline: var(--bw) solid var(--yellow);
  outline-offset: -5px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.modal-actions .btn {
  flex: 1;
}

.modal-text {
  font-size: 0.95rem;
  font-weight: 500;
}

.conflict-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.conflict-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-2) var(--sp-3);
  border: var(--bw-thin) solid var(--ink);
  border-left-width: 8px;
  border-left-color: var(--red);
  border-radius: var(--r-xs);
  background: var(--card-2);
}

.conflict-item b {
  font-size: 0.92rem;
}

.conflict-item span {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 300;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  background: var(--lime);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 0.9rem;
  transform: translate(-50%, 30px);
  opacity: 0;
  transition: transform var(--t-base), opacity var(--t-base);
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast-error {
  background: var(--red);
}

/* ── Responsive tweaks ──────────────────────────────────────── */
@media (max-width: 420px) {
  .container { padding: var(--sp-3) var(--sp-3) var(--sp-8); }
  .course { grid-template-columns: 56px 1fr; }
  .course-time { font-size: 0.82rem; }
  .datenav { grid-template-columns: 42px 1fr auto 42px; }
  .btn-icon { width: 42px; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 46px; }
  .cal-preview-list li { grid-template-columns: 88px 1fr; }
}

@media (min-width: 900px) {
  .manage { padding-top: var(--sp-6); }
  .wgrid { grid-auto-rows: 62px; }
}

/* ═══════════════════════════════════════════════════════════════
   Accounts — login, register, account, admin
   ═══════════════════════════════════════════════════════════════ */

.auth-page {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.auth-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* Decorative shapes — flat colour, ink outline, hard shadow */
.auth-deco {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.deco {
  position: absolute;
  border: var(--bw) solid var(--ink);
  box-shadow: var(--shadow);
}

.deco-circle {
  width: 150px;
  height: 150px;
  top: 8%;
  left: max(-40px, calc(50% - 470px));
  border-radius: 50%;
  background: var(--pink);
}

.deco-square {
  width: 120px;
  height: 120px;
  bottom: 10%;
  right: max(-30px, calc(50% - 450px));
  border-radius: var(--r);
  background: var(--cyan);
  transform: rotate(12deg);
}

.deco-bar {
  width: 190px;
  height: 34px;
  bottom: 22%;
  left: max(-60px, calc(50% - 520px));
  border-radius: var(--r-sm);
  background: var(--purple);
  transform: rotate(-9deg);
}

.deco-star {
  top: 14%;
  right: max(10px, calc(50% - 400px));
  border: 0;
  box-shadow: none;
  color: var(--orange);
  font-size: 5rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(14deg);
}

@media (max-width: 860px) {
  .deco-circle { width: 96px; height: 96px; top: -28px; left: -30px; }
  .deco-square { width: 80px; height: 80px; bottom: -22px; right: -22px; }
  .deco-bar,
  .deco-star { display: none; }
}

/* Card */
.auth-card {
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-head {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: var(--bw) solid var(--ink);
  color: #111;
}

.auth-head-yellow { background: var(--yellow); }
.auth-head-lime { background: var(--lime); }

.auth-head .tag-ink {
  background: #111;
  color: #fff;
  border-color: #111;
}

.auth-title {
  margin-top: var(--sp-3);
  font-size: clamp(1.9rem, 8vw, 2.5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.auth-lead {
  margin-top: var(--sp-2);
  font-size: 0.95rem;
  font-weight: 500;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: var(--bw) solid var(--ink);
}

.auth-tab {
  padding: 12px var(--sp-3);
  background: var(--card-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  transition: background var(--t-fast), color var(--t-fast);
}

.auth-tab + .auth-tab {
  border-left: var(--bw) solid var(--ink);
}

.auth-tab:hover {
  color: var(--ink);
}

.auth-tab.is-active {
  background: var(--ink);
  color: var(--paper);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.auth-card .auth-form {
  padding: var(--sp-5);
}

.auth-foot {
  padding: var(--sp-3) var(--sp-5) var(--sp-5);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
}

.auth-foot a,
.panel-card a:not(.btn):not(.chip-link):not(.friend-name) {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-decoration-color: var(--yellow);
  text-underline-offset: 3px;
}

.btn-block {
  width: 100%;
  min-height: 52px;
  font-size: 1.05rem;
  box-shadow: var(--shadow);
}

.btn-block:hover {
  box-shadow: 6px 6px 0 var(--ink);
}

.input-code {
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.input[type="date"],
.input[type="number"] {
  font-family: var(--mono);
}

/* Password field */
.pw-wrap {
  position: relative;
}

.pw-wrap .input {
  padding-right: 92px;
}

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  min-height: 30px;
  padding: 0 10px;
  background: var(--card-2);
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-xs);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pw-toggle[aria-pressed="true"] {
  background: var(--yellow);
  color: #111;
}

.pw-meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  align-items: center;
  gap: 5px;
}

.pw-meter i {
  height: 10px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 3px;
  background: var(--card-2);
}

.pw-meter[data-level="1"] i:nth-child(-n+1) { background: var(--red); }
.pw-meter[data-level="2"] i:nth-child(-n+2) { background: var(--orange); }
.pw-meter[data-level="3"] i:nth-child(-n+3) { background: var(--yellow); }
.pw-meter[data-level="4"] i:nth-child(-n+4) { background: var(--lime); }

.pw-meter-label {
  min-width: 9.5em;
  margin-left: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}

.match-hint {
  color: var(--red) !important;
  font-weight: 700 !important;
}

/* Checkbox */
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
}

.check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.check-box {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-xs);
  background: var(--card);
  box-shadow: 2px 2px 0 var(--ink);
  position: relative;
  transition: background var(--t-fast);
}

.check input:checked + .check-box {
  background: var(--lime);
}

.check input:checked + .check-box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 1px;
  width: 7px;
  height: 13px;
  border: solid #111;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.check input:focus-visible + .check-box {
  outline: var(--bw) solid var(--ink);
  outline-offset: 3px;
}

.check-text {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
}

.check-text small {
  display: block;
  margin-top: 2px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--muted);
}

/* Flash messages */
.flashes {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.flash {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  background: var(--lime);
  color: #111;
  font-size: 0.92rem;
  font-weight: 700;
}

.flash-error {
  background: var(--red);
}

.flash-mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* ── Account & admin panels ─────────────────────────────────── */
.panel-shell {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.panel-wide {
  max-width: 920px;
}

.panel-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-5);
  background: var(--yellow);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.panel-hero-pink { background: var(--pink); }

.panel-hero .tag-ink {
  background: #111;
  color: #fff;
  border-color: #111;
}

.panel-hero .btn {
  margin-top: var(--sp-2);
  border-color: #111;
  box-shadow: 3px 3px 0 #111;
}

.panel-title {
  font-size: clamp(1.7rem, 7vw, 2.3rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.panel-sub {
  font-size: 0.92rem;
  font-weight: 700;
}

.panel-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.panel-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.panel-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-card .hint {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.panel-card .auth-form > .btn {
  align-self: flex-start;
}

.panel-alert {
  background: var(--orange);
  color: #111;
}

.panel-alert .hint { color: #111; }

.secret {
  align-self: flex-start;
  padding: 8px 14px;
  background: #fff;
  color: #111;
  border: var(--bw) solid #111;
  border-radius: var(--r-sm);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  user-select: all;
  overflow-wrap: anywhere;
}

.panel-alert .btn {
  align-self: flex-start;
}

.invite-form {
  display: grid;
  grid-template-columns: 1fr 110px 150px auto;
  align-items: start;
  gap: var(--sp-3);
}

.invite-form .btn {
  margin-top: 22px;
  min-height: 46px;
}

@media (max-width: 720px) {
  .invite-form { grid-template-columns: 1fr 1fr; }
  .invite-form .field-grow,
  .invite-form .btn { grid-column: 1 / -1; }
  .invite-form .btn { margin-top: 0; }
}

.rows {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3);
  background: var(--card-2);
  border: var(--bw-thin) solid var(--ink);
  border-left-width: 8px;
  border-radius: var(--r-sm);
}

.row-current { border-left-color: var(--lime); }
.row-user { border-left-color: var(--blue); }

.row-off {
  border-left-color: var(--muted);
  border-style: dashed;
  border-left-style: solid;
}

.row-off .code {
  text-decoration: line-through;
  color: var(--muted);
}

.row-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px var(--sp-2);
  min-width: 0;
  flex: 1 1 260px;
  overflow-wrap: anywhere;
}

.row-meta {
  flex-basis: 100%;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.code {
  font-size: 1.02rem;
  letter-spacing: 0.08em;
  user-select: all;
}

.row-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.danger-zone summary {
  list-style: none;
  cursor: pointer;
}

.danger-zone summary::-webkit-details-marker {
  display: none;
}

.danger-zone[open] {
  flex-basis: 100%;
}

.danger-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  background: var(--card);
  border: var(--bw-thin) solid var(--red);
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-weight: 500;
}

.danger-form .input {
  max-width: 280px;
}

/* Invite links */
.invite-link {
  flex-basis: 100%;
  padding: 6px 10px;
  background: var(--card);
  border: var(--bw-thin) dashed var(--ink);
  border-radius: var(--r-xs);
  font-size: 0.76rem;
  font-weight: 700;
  user-select: all;
  overflow-wrap: anywhere;
}

.invite-ok {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  background: var(--lime);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.invite-ok small {
  display: block;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

/* ═══════════════════════════════════════════════════════════════
   Categories, friends & sharing
   ═══════════════════════════════════════════════════════════════ */

/* ── Category colours (palette keys from db.CATEGORY_COLORS) ── */
:root { --c-x: var(--cyan); --c-hidden: var(--muted); }

.sw-blue   { --sw: var(--blue); }
.sw-orange { --sw: var(--orange); }
.sw-purple { --sw: var(--purple); }
.sw-cyan   { --sw: var(--cyan); }
.sw-pink   { --sw: var(--pink); }
.sw-yellow { --sw: var(--yellow); }
.sw-lime   { --sw: var(--lime); }
.sw-busy   { --sw: var(--red); }
.sw-x      { --sw: var(--c-x); }

.cal-legend i[class^="sw-"],
.legend i[class^="sw-"],
.ft-legend i,
.dot { background: var(--sw); }

.busybar i.k-blue   { background: var(--blue); }
.busybar i.k-orange { background: var(--orange); }
.busybar i.k-purple { background: var(--purple); }
.busybar i.k-cyan   { background: var(--cyan); }
.busybar i.k-pink   { background: var(--pink); }
.busybar i.k-yellow { background: var(--yellow); }
.busybar i.k-lime   { background: var(--lime); }
.busybar i.k-busy   { background: var(--red); }
.busybar i.k-x      { background: var(--c-x); }

.cal-preview-list li.k-blue   { border-left-color: var(--blue); }
.cal-preview-list li.k-orange { border-left-color: var(--orange); }
.cal-preview-list li.k-purple { border-left-color: var(--purple); }
.cal-preview-list li.k-cyan   { border-left-color: var(--cyan); }
.cal-preview-list li.k-pink   { border-left-color: var(--pink); }
.cal-preview-list li.k-yellow { border-left-color: var(--yellow); }
.cal-preview-list li.k-lime   { border-left-color: var(--lime); }
.cal-preview-list li.k-busy   { border-left-color: var(--red); }

.course.c-blue   { --cc: var(--blue); }
.course.c-orange { --cc: var(--orange); }
.course.c-purple { --cc: var(--purple); }
.course.c-cyan   { --cc: var(--cyan); }
.course.c-pink   { --cc: var(--pink); }
.course.c-yellow { --cc: var(--yellow); }
.course.c-lime   { --cc: var(--lime); }
.course.c-busy   { --cc: var(--red); }
.course.c-x      { --cc: var(--c-x); }
.course[class*=" c-"] .course-time { background: var(--cc); color: #111; }
.course[class*=" c-"] .kind-tag { background: var(--cc); color: #111; }

/* Busy-only blocks: red, hatched, no details */
.course.masked .course-body {
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255, 107, 107, 0.16) 10px 20px);
}

.course.masked .course-subject { letter-spacing: 0.04em; text-transform: uppercase; }

.course-with {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
}

.course-with svg { width: 15px; height: 15px; flex-shrink: 0; }

.act.c-blue   { background: var(--blue); }
.act.c-orange { background: var(--orange); }
.act.c-purple { background: var(--purple); }
.act.c-cyan   { background: var(--cyan); }
.act.c-pink   { background: var(--pink); }
.act.c-yellow { background: var(--yellow); }
.act.c-lime   { background: var(--lime); }
.act.c-x      { background: var(--c-x); }

/* ── Top bar extras ─────────────────────────────────────────── */
.topbar { flex-wrap: wrap; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }

.badge-host { position: relative; }

.badge {
  position: absolute;
  top: -9px;
  right: -9px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 999px;
  background: var(--red);
  color: #111;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  box-shadow: none;
}

@media (max-width: 480px) {
  .hide-narrow { display: none; }
}

.viewing-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--cyan);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
  font-weight: 600;
}

.viewing-banner .tag-ink { background: #111; color: #fff; border-color: #111; }
.viewing-banner a { border-bottom: 2px solid #111; font-weight: 700; }
.viewing-preview { background: var(--yellow); }
.viewing-share { background: var(--lime); }

.strip-day.out,
.cal-day.out {
  opacity: 0.32;
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, var(--line-soft) 6px 7px);
}

.cal-day.out { cursor: not-allowed; }
.cal-day.out:hover { transform: none; box-shadow: 2px 2px 0 var(--ink); }

.empty-out { background: var(--card-2); color: var(--ink); }

/* ── Panels: shared bits ───────────────────────────────────── */
.panel-hero-cyan { background: var(--cyan); }
.panel-hero-lime { background: var(--lime); }

.username-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: #fff;
  color: #111;
  border: var(--bw) solid #111;
  border-radius: var(--r-sm);
  box-shadow: 3px 3px 0 #111;
}

.username-card .btn { margin-top: 0; }
.hint-ink { font-size: 0.78rem; font-weight: 600; }

.username-big {
  font-size: clamp(1.3rem, 6vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  user-select: all;
  overflow-wrap: anywhere;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.hero-links .btn { margin-top: 0; }

.count {
  display: inline-block;
  min-width: 26px;
  padding: 0 6px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: center;
  vertical-align: 2px;
}

.sub-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.select-sm,
.input-sm {
  min-height: 38px;
  font-size: 0.88rem;
  border-width: var(--bw-thin);
  box-shadow: 2px 2px 0 var(--ink);
}

.select.select-sm { padding-right: 32px; }

.chip,
.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 999px;
  background: var(--sw, var(--card));
  color: #111;
  font-size: 0.74rem;
  font-weight: 700;
}

.chip-x { cursor: pointer; }
.chip-x::after { content: "×"; font-size: 0.95rem; line-height: 1; }

.chip-link {
  min-height: 34px;
  padding: 0 12px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 0.82rem;
}

.chip-link[class*="sw-"] { background: var(--sw); color: #111; }

.chip-link.is-active {
  background: var(--ink);
  color: var(--paper);
  box-shadow: none;
  transform: translate(2px, 2px);
}

.dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 50%;
}

/* ── Friends hub ───────────────────────────────────────────── */
.row-request { border-left-color: var(--yellow); }
.row-invite { border-left-color: var(--pink); }

.row-warn {
  flex-basis: 100%;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--orange);
}

.rsvp {
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 3px;
  border: 1.5px solid currentColor;
}

.rsvp-accepted { color: var(--lime); }
.rsvp-pending { color: var(--muted); }
.rsvp-declined { color: var(--red); }
:root[data-theme="light"] .rsvp-accepted { color: #2f7d16; }
:root[data-theme="light"] .rsvp-declined { color: #c22; }

.invite-answer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.news {
  list-style: none;
  display: flex;
  flex-direction: column;
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.news li {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  font-size: 0.88rem;
  font-weight: 500;
  background: var(--card-2);
}

.news li + li { border-top: 1px solid var(--line-soft); }
.news li small { flex-shrink: 0; color: var(--muted); font-size: 0.72rem; }
.news li.unread { background: var(--card); font-weight: 700; box-shadow: inset 6px 0 0 var(--yellow); }

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--sp-3);
}

.search-form .btn { min-height: 46px; }

.result-empty {
  padding: var(--sp-3);
  border: var(--bw-thin) dashed var(--ink);
  border-radius: var(--r-sm);
  font-weight: 600;
}

.friend-row { border-left-color: var(--muted); }
.friend-row.state-busy { border-left-color: var(--red); }
.friend-row.state-free { border-left-color: var(--lime); }

.presence {
  width: 12px;
  height: 12px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 50%;
  background: var(--muted);
}

.state-busy .presence { background: var(--red); }
.state-free .presence { background: var(--lime); }
.friend-name { border-bottom: 2px solid var(--ink); }
.friend-status { font-size: 0.8rem; color: var(--ink-2); }

/* ── Privacy page ──────────────────────────────────────────── */
.level-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin-top: var(--sp-2);
  font-size: 0.82rem;
}

.level-legend dt { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.level-legend dd { margin-left: 20px; font-weight: 500; opacity: 0.8; }

.lv-dot {
  width: 13px;
  height: 13px;
  border: 2px solid #111;
  border-radius: 3px;
}

.lv-dot.lv-full { background: var(--lime); }
.lv-dot.lv-busy { background: var(--red); }
.lv-dot.lv-hidden { background: #fff; border-style: dashed; }

.subject-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

.subject-friend { min-width: 200px; }

.rule-rows {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.rule-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--card-2);
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
}

.rule-cat { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rule-cat small { color: var(--muted); font-size: 0.72rem; font-weight: 600; }

.rule-effective {
  grid-column: 1 / -1;
  font-size: 0.74rem;
  color: var(--muted);
}

.levels {
  display: inline-flex;
  flex-wrap: wrap;
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--card);
}

.lv { position: relative; cursor: pointer; }
.lv + .lv { border-left: var(--bw-thin) solid var(--ink); }

.lv input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.lv span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 2px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.lv span small { font-size: 0.62rem; font-weight: 600; opacity: 0.75; }
.lv input:checked + span { background: var(--ink); color: var(--paper); }
.lv-full input:checked + span { background: var(--lime); color: #111; }
.lv-busy input:checked + span { background: var(--red); color: #111; }
.lv-hidden input:checked + span { background: var(--ink); color: var(--paper); }
.lv input:focus-visible + span { outline: var(--bw) solid var(--yellow); outline-offset: -4px; }

@media (max-width: 640px) {
  .rule-row { grid-template-columns: 1fr; }
}

.group-pick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: var(--bw-thin) dashed var(--ink);
  border-radius: var(--r-sm);
}

.group-pick legend {
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.check-chip { position: relative; cursor: pointer; }

.check-chip input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.check-chip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--ink);
}

.check-chip input:checked + span {
  background: var(--sw, var(--lime));
  color: #111;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

.check-chip input:checked + span::before { content: "✓"; }
.check-chip input:focus-visible + span { outline: var(--bw) solid var(--ink); outline-offset: 2px; }

.cat-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
}

.row > .cat-form { flex: 1 1 420px; }

.cat-form .input { width: auto; flex: 1 1 160px; min-width: 140px; }
.cat-form .row-meta { flex-basis: auto; }
.cat-new { padding-top: var(--sp-2); border-top: 1px dashed var(--line-soft); }

.swatches { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.swatch { position: relative; cursor: pointer; }

.swatch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.swatch span {
  display: block;
  width: 24px;
  height: 24px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 6px;
  background: var(--sw);
}

.swatch input:checked + span { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.swatch input:focus-visible + span { outline: var(--bw) solid var(--ink); outline-offset: 3px; }

.group-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--card-2);
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
}

.group-card.is-active { box-shadow: var(--shadow-sm); border-width: var(--bw); }

/* ── Share links ───────────────────────────────────────────── */
.fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
  background: var(--card-2);
}

.fieldset legend,
.field-label {
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field-label { padding: 0; }

.option-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}

@media (max-width: 640px) {
  .option-cards { grid-template-columns: 1fr; }
}

.option-card { position: relative; cursor: pointer; }

.option-card input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.option-card span {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: var(--sp-3);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
}

.option-card small { font-size: 0.76rem; font-weight: 500; color: var(--muted); }
.option-card input:checked + span { background: var(--yellow); color: #111; transform: translate(2px, 2px); box-shadow: none; }
.option-card input:checked + span small { color: #111; opacity: 0.75; }
.option-card input:focus-visible + span { outline: var(--bw) solid var(--ink); outline-offset: 3px; }

.tweaks summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
}

.tweaks[open] summary { margin-bottom: var(--sp-3); }

.choice.choice-2 { grid-template-columns: repeat(2, 1fr); }
.choice.choice-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 560px) {
  .choice.choice-4 { grid-template-columns: repeat(2, 1fr); }
  .choice.choice-4 label:nth-child(3) { border-left: 0; }
  .choice.choice-4 label:nth-child(n+3) { border-top: var(--bw) solid var(--ink); }
}

.day-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

.day-picker .input { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.chips .chip { background: var(--cyan); font-family: var(--mono); }
.chips:empty { display: none; }

/* ── Common free time ──────────────────────────────────────── */
.ft-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--sp-3) var(--sp-5);
}

.ft-week { display: flex; align-items: center; gap: var(--sp-2); }
.ft-hours { display: flex; align-items: center; gap: 6px; }
.ft-hours .input { width: 70px; }
.ft-me { align-self: center; }

.ft-legend { display: flex; gap: var(--sp-4); font-size: 0.76rem; font-weight: 600; color: var(--muted); }

.ft-legend i {
  display: inline-block;
  width: 14px;
  height: 10px;
  margin-right: 5px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  vertical-align: -1px;
}

.ft-grid { display: flex; flex-direction: column; gap: var(--sp-3); }

.ft-scale,
.ft-lane {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: var(--sp-2);
}

.ft-ticks { position: relative; height: 16px; }

.ft-ticks i {
  position: absolute;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
}

.ft-day {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: var(--sp-3);
  background: var(--card-2);
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
}

.ft-day.today { border-width: var(--bw); box-shadow: var(--shadow-sm); }
.ft-day.past { opacity: 0.55; }
.ft-day-title { font-size: 0.86rem; font-weight: 700; }

.ft-who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.76rem;
  font-weight: 700;
}

.ft-bar {
  position: relative;
  height: 16px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--card);
  overflow: hidden;
}

.ft-bar i { position: absolute; top: 0; bottom: 0; background: var(--sw); }
.ft-lane:last-of-type .ft-bar { height: 20px; border-width: var(--bw-thin); }

.ft-slots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

@media (max-width: 480px) {
  .ft-scale, .ft-lane { grid-template-columns: 64px 1fr; }
}

/* ── Manage page additions ─────────────────────────────────── */
.invite-banner {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  background: var(--pink);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.cal-nav { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.cal-nav .btn-icon.btn-sm { width: 34px; }
.g-day.is-today { background: var(--yellow); color: #111; }
.g-day.is-today small { color: #111; }

.act.once { border-style: solid; border-width: var(--bw); }

.act.shared {
  background-image: repeating-linear-gradient(45deg, transparent 0 8px, rgba(17, 17, 17, 0.1) 8px 10px);
  border-style: dashed;
  cursor: pointer;
}

.act.st-pending { opacity: 0.7; background-color: var(--card); color: var(--ink); }
.act.locked { cursor: pointer; }
.act-range { margin-left: 4px; }

.busy-ghost {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 0;
  padding: 2px 4px;
  border: 1.5px dashed var(--red);
  border-radius: var(--r-xs);
  background: repeating-linear-gradient(135deg, rgba(255, 107, 107, 0.22) 0 6px, transparent 6px 12px);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--red);
  overflow: hidden;
  pointer-events: none;
}

.legend i.lg-shared { background: repeating-linear-gradient(45deg, var(--card) 0 3px, var(--ink) 3px 4.5px); border-style: dashed; }
.legend i.lg-once { border-width: 2.5px; background: var(--card); }
.legend i.lg-overlay { border: 1.5px dashed var(--red); background: rgba(255, 107, 107, 0.3); }

.modal-wide { max-width: 560px; }

.modal-section {
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
  background: var(--card-2);
}

.modal-section summary {
  padding: var(--sp-3);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal-section[open] {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
}

.modal-section > :not(summary) { margin: 0 var(--sp-3); }
.summary-meta { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 600; }

.vis-exceptions { display: flex; flex-direction: column; gap: var(--sp-2); }

.vis-row {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: var(--sp-2);
  align-items: center;
}

.vis-row .btn { min-width: 38px; padding: 0; }

.inv-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.shared-head { background: var(--pink); }

.shared-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--sp-3);
  background: var(--card-2);
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
}

.shared-name { font-size: 1.1rem; }
.people { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.84rem; font-weight: 600; }
.modal-section .hint { display: block; }

/* ═══════════════════════════════════════════════════════════════
   Public site — home page, legal pages, error pages, footer
   ═══════════════════════════════════════════════════════════════ */

.site-page {
  overflow-x: hidden;
}

.site-shell {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.site-foot {
  margin-top: 0;
  padding-top: var(--sp-4);
}

.auth-shell .site-foot {
  margin-top: var(--sp-2);
}

.btn-lg {
  min-height: 52px;
  padding: 0 var(--sp-6);
  font-size: 1.05rem;
  box-shadow: var(--shadow);
}

/* Hero */
.site-hero {
  display: grid;
  padding: var(--sp-6);
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: center;
  gap: var(--sp-8);
}

.hero-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-4);
}

.hero-title {
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
}

.hero-title mark {
  display: inline-block;
  padding: 0 0.15em;
  background: var(--yellow);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  transform: rotate(-2deg);
}

.hero-lead {
  max-width: 34em;
  font-size: 1.08rem;
  font-weight: 500;
  color: var(--ink-2);
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.hero-text .hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.hero-demo {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.demo-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--lime);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  font-size: 1.1rem;
  font-weight: 500;
}

.demo-dot {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #111;
  box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.2);
}

.demo-day {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  transform: rotate(1deg);
}

.demo-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.demo-block {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-4);
  border: var(--bw) solid #111;
  border-radius: var(--r-sm);
  color: #111;
}

.demo-block span {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.demo-blue { background: var(--blue); }
.demo-purple { background: var(--purple); }
.demo-busy { background: var(--red); }

.demo-free {
  background: transparent;
  border-style: dashed;
  border-color: var(--ink);
  color: var(--ink);
}

/* Sections */
.site-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.site-h2 {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: var(--sp-5);
}

.feature {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5);
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.feature h3 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.feature p {
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--ink-2);
}

.feature-mark {
  align-self: flex-start;
  margin-bottom: var(--sp-1);
  padding: 2px 10px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-xs);
  box-shadow: 2px 2px 0 var(--ink);
  color: #111;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.fm-yellow { background: var(--yellow); }
.fm-lime { background: var(--lime); }
.fm-cyan { background: var(--cyan); }
.fm-pink { background: var(--pink); }
.fm-orange { background: var(--orange); }
.fm-purple { background: var(--purple); }

.steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: var(--sp-5);
}

.steps li {
  counter-increment: step;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5);
  border: var(--bw) dashed var(--ink);
  border-radius: var(--r);
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--ink-2);
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 50%;
  font-family: var(--mono);
  font-weight: 700;
}

.steps b {
  font-size: 1.1rem;
  color: var(--ink);
}

.site-promise {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-6);
  background: var(--cyan);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
}

.site-promise ul {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-left: 1.2em;
  font-weight: 500;
}

.site-promise .btn {
  border-color: #111;
  box-shadow: 3px 3px 0 #111;
}

@media (max-width: 760px) {
  .site-hero {
    grid-template-columns: 1fr;
    gap: var(--sp-6);
    padding: var(--sp-5) var(--sp-4);
  }
  .site-shell { gap: var(--sp-6); }
  .demo-day { transform: none; }
}

/* Legal pages */
.legal-shell {
  max-width: 780px;
  gap: var(--sp-5);
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.legal-nav a {
  padding: 6px 14px;
  border: var(--bw-thin) solid var(--ink);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.legal-nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

.legal {
  padding: var(--sp-6);
  background: var(--card);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink-2);
}

.legal > * + * {
  margin-top: var(--sp-4);
}

.legal-title {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.legal-meta {
  margin-top: var(--sp-2) !important;
  font-size: 0.8rem;
  color: var(--muted);
}

.legal-lead {
  padding: var(--sp-4);
  background: var(--yellow);
  color: #111;
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
}

.legal h2 {
  margin-top: var(--sp-8);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.legal ul {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-left: 1.2em;
}

.legal b {
  color: var(--ink);
}

.legal a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-decoration-color: var(--yellow);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.legal-table {
  overflow-x: auto;
  border: var(--bw-thin) solid var(--ink);
  border-radius: var(--r-sm);
}

.legal-table table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.legal-table th,
.legal-table td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

.legal-table th {
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 560px) {
  .legal { padding: var(--sp-4); }
}

/* Error pages */
.error-code {
  margin-top: var(--sp-2);
  font-size: clamp(3.5rem, 18vw, 5.5rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.error-head-red { background: var(--red); }

/* Danger zone on the account page */
.panel-danger {
  border-color: var(--red);
  box-shadow: 5px 5px 0 var(--red);
}

.panel-card > .btn[download] {
  align-self: flex-start;
}

.forgot-link {
  align-self: flex-end;
  margin-top: calc(-1 * var(--sp-2));
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.forgot-link:hover {
  color: var(--ink);
}
