/* ---------- Tokens ---------- */
:root {
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f0f4f9;
  --surface-3: #e9eef6;
  --text: #1f1f1f;
  --muted: #444746;
  --subtle: #747775;
  --outline: #c4c7c5;
  --outline-variant: #e1e3e1;
  --primary: #0b57d0;
  --primary-strong: #0842a0;
  --on-primary: #ffffff;
  --primary-container: #d3e3fd;
  --on-primary-container: #041e49;
  --best: #ffefc9;
  --best-strong: #f9ab00;
  --on-best: #3d2f00;
  --yes: #188038;
  --maybe: #e37400;
  --no: #d93025;
  --sun: #d93025;
  --sat: #0b57d0;
  --danger: #b3261e;
  --now: #ea4335;
  --shadow-1: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --shadow-2: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
  --radius: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314;
    --surface: #1e1f20;
    --surface-2: #282a2c;
    --surface-3: #333537;
    --text: #e3e3e3;
    --muted: #c4c7c5;
    --subtle: #8e918f;
    --outline: #5c5f5e;
    --outline-variant: #3c4043;
    --primary: #a8c7fa;
    --primary-strong: #7cacf8;
    --on-primary: #062e6f;
    --primary-container: #0842a0;
    --on-primary-container: #d3e3fd;
    --best: #4a3b00;
    --best-strong: #fdd663;
    --on-best: #ffefc9;
    --yes: #6dd58c;
    --maybe: #ffb870;
    --no: #f2b8b5;
    --sun: #f2b8b5;
    --sat: #a8c7fa;
    --danger: #f2b8b5;
    --now: #f28b82;
    --shadow-1: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-2: 0 2px 6px 2px rgba(0, 0, 0, .45);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1 { font-size: 1.6rem; font-weight: 500; margin: 0 0 .5rem; line-height: 1.3; overflow-wrap: anywhere; letter-spacing: .01em; }
h2 { font-size: 1.1rem; font-weight: 500; margin: 0 0 .75rem; }
h3 { font-size: 1rem; font-weight: 500; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.page { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.page.is-wide { max-width: 1440px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 16px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.lead { color: var(--muted); margin-bottom: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* ---------- App bar ---------- */
.appbar { background: var(--surface); border-bottom: 1px solid var(--outline-variant); margin-bottom: 20px; position: sticky; top: 0; z-index: 20; }
.appbar-inner { max-width: 1040px; margin: 0 auto; padding: 0 16px; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.appbar-inner.is-wide { max-width: 1440px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 1.35rem; font-weight: 400; }
.brand-icon { display: inline-flex; }
.bi-body { fill: var(--primary); }
.bi-top { fill: var(--primary-strong); }
@media (prefers-color-scheme: dark) { .bi-body { fill: #4c8df6; } .bi-top { fill: #3b78e7; } }
.create-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 20px 0 14px; border-radius: 16px;
  background: var(--surface); color: var(--text); text-decoration: none; font-weight: 500;
  box-shadow: var(--shadow-1); transition: box-shadow .15s, background .15s;
}
.create-btn:hover { box-shadow: var(--shadow-2); background: var(--surface-2); }
.create-btn svg { color: var(--primary); }

.site-footer { color: var(--subtle); font-size: .8rem; padding: 32px 0; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.tz-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.tz-form select { width: auto; max-width: 100%; min-width: 0; height: 32px; padding: 0 8px; font-size: .8rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.page-head { margin: 4px 4px 16px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field > label, .field-label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 6px; color: var(--muted); }
input[type=text], input[type=password], textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--outline); border-radius: 8px; padding: 11px 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.field-error { color: var(--danger); font-size: .85rem; margin: 6px 0 0; }
.has-error input[type=text], .has-error textarea { border-color: var(--danger); }
.hint { color: var(--subtle); font-size: .82rem; margin: 6px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; font-size: .9rem; line-height: 1.2; letter-spacing: .01em;
  padding: 0 20px; height: 40px; border-radius: 20px;
  border: none; background: var(--surface-2); color: var(--primary);
  text-decoration: none; cursor: pointer; transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); box-shadow: var(--shadow-1); }
.btn-tonal { background: var(--primary-container); color: var(--on-primary-container); }
.btn-tonal:hover { background: var(--primary-container); box-shadow: var(--shadow-1); }
.btn-tonal.is-done { background: var(--yes); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--outline); color: var(--primary); }
.btn-outline:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.btn-danger { background: transparent; border: 1px solid var(--outline); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-small { height: 32px; padding: 0 14px; font-size: .82rem; border-radius: 16px; }
.btn-lg { height: 48px; padding: 0 28px; font-size: 1rem; border-radius: 24px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--primary); padding: 4px 8px; font: inherit; cursor: pointer; border-radius: 8px; }
.btn-link:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 1.2rem; line-height: 1; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }

.flash {
  background: var(--primary-container); color: var(--on-primary-container);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-weight: 500;
}

.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; background: var(--surface-2); border-color: transparent; }

/* ---------- Date chip & when ---------- */
.dchip { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 44px; flex: none; line-height: 1.1; }
.dchip-wd { font-size: .7rem; color: var(--muted); font-weight: 500; }
.dchip-d { font-size: 1.45rem; font-weight: 400; color: var(--text); }
.dchip.wd0 .dchip-wd, .dchip.wd0 .dchip-d { color: var(--sun); }
.dchip.wd6 .dchip-wd, .dchip.wd6 .dchip-d { color: var(--sat); }
.dchip-sm { width: 36px; }
.dchip-sm .dchip-d { font-size: 1.15rem; }
.when { display: inline-flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.when-date { font-weight: 500; font-size: .92rem; }
.when-time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.cand-cell { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }

.badge { display: inline-block; font-size: .7rem; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.badge-best { background: var(--best-strong); color: #3d2f00; }
.badge-confirmed { background: var(--primary); color: var(--on-primary); }

/* ---------- Create page ---------- */
.create-layout {
  display: grid; gap: 16px 24px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "main" "side";
}
@media (min-width: 960px) {
  .create-layout {
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-areas: "head main" "side main";
    grid-template-rows: auto 1fr;
    align-items: start;
  }
  .create-side { position: sticky; top: 84px; }
}
.create-head { grid-area: head; }
.create-main { grid-area: main; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--outline-variant); padding: 12px 16px 16px; min-width: 0; }
.create-side { grid-area: side; }
.title-input[type=text] {
  font-size: 1.5rem; padding: 8px 2px; border: none; border-bottom: 1px solid var(--outline);
  border-radius: 0; background: transparent;
}
.title-input[type=text]:focus { box-shadow: none; border-bottom: 2px solid var(--primary); padding-bottom: 7px; }
.desc-input { background: var(--surface-2); border-color: transparent; min-height: 64px; }

.picker-help { color: var(--muted); font-size: .85rem; margin: 4px 4px 10px; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline; } }
.fallback { margin-top: 12px; color: var(--muted); font-size: .9rem; }
.fallback summary { cursor: pointer; padding: 4px 0; color: var(--primary); }
.fallback textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }

.sel-panel { background: var(--surface); border: 1px solid var(--outline-variant); border-radius: var(--radius); padding: 12px 8px 8px; margin-bottom: 16px; }
.sel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 8px 6px; font-weight: 500; }
.sel-head .btn-link { color: var(--danger); font-weight: 400; padding: 2px 8px; }
.sel-head .btn-link:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.sel-count { color: var(--muted); font-size: .82rem; font-weight: 400; }
.sel-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.sel-list li { display: flex; align-items: center; gap: 6px; padding: 4px 4px; border-radius: 12px; }
.sel-list li:hover { background: var(--surface-2); }
.sel-list .sel-text { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; background: none; border: none; padding: 0; color: inherit; font: inherit; cursor: pointer; line-height: 1.35; }
.sel-empty { color: var(--subtle); font-size: .85rem; padding: 8px !important; }

/* ---------- FullCalendar theme ---------- */
.fc-host { min-height: 300px; }
.fc {
  --fc-border-color: var(--outline-variant);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface-2);
  --fc-today-bg-color: transparent;
  --fc-now-indicator-color: var(--now);
  --fc-event-bg-color: var(--primary);
  --fc-event-border-color: transparent;
  --fc-event-text-color: var(--on-primary);
  --fc-highlight-color: color-mix(in srgb, var(--primary) 18%, transparent);
  --fc-non-business-color: transparent;
  --fc-small-font-size: .78rem;
  --fc-list-event-hover-bg-color: var(--surface-2);
  font-size: .85rem;
}
.fc .fc-toolbar { gap: 8px; flex-wrap: wrap; }
.fc .fc-toolbar.fc-header-toolbar { margin-bottom: 12px; }
.fc .fc-toolbar.fc-footer-toolbar { margin-top: 10px; }
.fc .fc-toolbar-title { font-size: 1.35rem; font-weight: 400; color: var(--text); margin-left: 8px; display: inline-block; vertical-align: middle; }
.fc .fc-toolbar-chunk { display: flex; align-items: center; gap: 4px; }
.fc .fc-button {
  background: transparent; border: 1px solid var(--outline); color: var(--text);
  border-radius: 18px; height: 36px; padding: 0 14px; font-weight: 500; font-size: .85rem; box-shadow: none !important; text-transform: none;
}
.fc .fc-button:hover { background: var(--surface-2); color: var(--text); border-color: var(--outline); }
.fc .fc-button:disabled { opacity: .45; background: transparent; color: var(--text); border-color: var(--outline); }
.fc .fc-prev-button, .fc .fc-next-button { border: none; width: 36px; padding: 0; border-radius: 50%; }
.fc .fc-button-group > .fc-button { border-radius: 0; }
.fc .fc-button-group > .fc-button:first-child { border-radius: 18px 0 0 18px; }
.fc .fc-button-group > .fc-button:last-child { border-radius: 0 18px 18px 0; }
.fc .fc-button-group > .fc-prev-button, .fc .fc-button-group > .fc-next-button { border-radius: 50% !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--primary-container); color: var(--on-primary-container); border-color: var(--outline); }
.fc .fc-scrollgrid { border-radius: 8px; overflow: hidden; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--outline-variant); }
.fc .fc-col-header-cell { border-bottom: none; }
.fc .fc-col-header-cell-cushion { padding: 6px 2px; color: var(--muted); text-decoration: none; font-weight: 500; }
.fc .dh { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fc .dh-wd { font-size: .72rem; color: var(--muted); }
.fc .dh-d { font-size: 1.5rem; font-weight: 400; width: 44px; height: 44px; line-height: 44px; border-radius: 50%; color: var(--text); }
.fc .dh.wd0 .dh-wd, .fc .dh.wd0 .dh-d { color: var(--sun); }
.fc .dh.wd6 .dh-wd, .fc .dh.wd6 .dh-d { color: var(--sat); }
.fc .dh.is-today .dh-wd { color: var(--primary); }
.fc .dh.is-today .dh-d { background: var(--primary); color: var(--on-primary); }
.fc .fc-timegrid-slot { height: 24px; border-bottom: none; }
.fc .fc-timegrid-slot-minor { border-top-style: none; }
.fc .fc-timegrid-slot-label-cushion { font-size: .72rem; color: var(--subtle); }
.fc .fc-timegrid-axis-cushion { font-size: .72rem; color: var(--subtle); }
.fc .fc-daygrid-day-number { font-size: .8rem; color: var(--text); text-decoration: none; padding: 6px 8px; }
.fc .fc-day-today .fc-daygrid-day-number { background: var(--primary); color: var(--on-primary); border-radius: 50%; width: 26px; height: 26px; padding: 0; line-height: 26px; text-align: center; margin: 4px; }
.fc .fc-day-sun .fc-daygrid-day-number, .fc .fc-day-sun .fc-col-header-cell-cushion { color: var(--sun); }
.fc .fc-day-sat .fc-daygrid-day-number, .fc .fc-day-sat .fc-col-header-cell-cushion { color: var(--sat); }
.fc .fc-day-today.fc-day-sun .fc-daygrid-day-number, .fc .fc-day-today.fc-day-sat .fc-daygrid-day-number { color: var(--on-primary); }
.fc .fc-day-disabled { background: var(--surface-2); }
.fc .fc-highlight { border-radius: 6px; }
.fc .fc-timegrid-now-indicator-line { border-width: 2px 0 0; }
.fc .fc-timegrid-now-indicator-arrow { border-color: var(--now); border-width: 6px 0 6px 6px; border-top-color: transparent; border-bottom-color: transparent; }

.fc .fc-event { border-radius: 6px; border: none; cursor: pointer; box-shadow: 0 0 0 1px var(--surface); }
.fc .fc-timegrid-event .fc-event-main { padding: 2px 6px; }
.fc .fc-daygrid-event { padding: 1px 6px; }
.fc .ev { overflow: hidden; line-height: 1.3; }
.fc .ev-time { font-weight: 600; font-size: .78rem; white-space: nowrap; }
.fc .ev-sub { font-size: .76rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc .cand-new { background: var(--primary); color: var(--on-primary); }
.fc .cand-new .fc-event-main { color: var(--on-primary); }
.fc .cand-existing { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--outline); cursor: default; }
.fc .cand-existing .fc-event-main { color: var(--muted); }
.fc .fc-event-mirror { opacity: .85; }
.fc .cand { background: var(--primary-container); }
.fc .cand .fc-event-main { color: var(--on-primary-container); }
.fc .cand-best { background: var(--best-strong); }
.fc .cand-best .fc-event-main { color: #3d2f00; }
.fc .cand-confirmed { background: var(--primary); }
.fc .cand-confirmed .fc-event-main { color: var(--on-primary); }
.fc-readonly .fc-event { cursor: pointer; }
.fc .fc-list-event:hover td { background: var(--surface-2); }

@media (max-width: 720px) {
  .fc .fc-toolbar-title { font-size: 1.05rem; margin: 0; }
  .fc .dh-d { font-size: 1.2rem; width: 36px; height: 36px; line-height: 36px; }
  .create-main { padding: 8px 8px 12px; margin: 0 -8px; border-radius: 12px; }
}

/* Popover & toast */
.popover {
  position: absolute; z-index: 50; background: var(--surface); color: var(--text);
  border-radius: 12px; box-shadow: var(--shadow-2); padding: 14px 16px; min-width: 200px;
}
.popover-title { font-weight: 500; }
.popover-time { color: var(--muted); font-size: .88rem; margin-bottom: 10px; }
.popover-allday { display: flex; align-items: center; gap: 6px; margin: 10px 0 8px; font-size: .9rem; }
.popover-times { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.popover-times select { width: auto; height: 36px; padding: 0 6px; font-size: .9rem; }
.popover-times[aria-disabled=true] { opacity: .45; }
.popover-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: #303030; color: #f2f2f2; padding: 12px 20px; border-radius: 8px; z-index: 60;
  transition: opacity .2s, transform .2s; pointer-events: none; font-size: .9rem; box-shadow: var(--shadow-2);
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Event page ---------- */
.banner {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  background: var(--primary-container); color: var(--on-primary-container);
  border-radius: var(--radius); padding: 14px 20px; margin-bottom: 16px;
}
.banner .dchip-wd, .banner .dchip-d { color: var(--on-primary-container) !important; }
.banner-label { font-size: .78rem; font-weight: 600; letter-spacing: .02em; }
.banner-when { font-size: 1.15rem; font-weight: 500; }
.banner-body { flex: 1 1 auto; min-width: 0; }
.banner-action { background: var(--surface); color: var(--primary); gap: 6px; text-decoration: none; }
.banner-action:hover { box-shadow: var(--shadow-1); }
.event-head h1 { margin-bottom: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.meta-item { background: var(--surface-2); color: var(--muted); border-radius: 8px; padding: 2px 10px; font-size: .82rem; text-decoration: none; }
.meta-link { color: var(--primary); }
.meta-link:hover { background: var(--primary-container); }
.desc { margin: 10px 0 0; color: var(--text); }

.segmented { display: inline-flex; border: 1px solid var(--outline); border-radius: 20px; overflow: hidden; }
.segmented button {
  font: inherit; font-size: .85rem; font-weight: 500; border: none; background: transparent; color: var(--text);
  height: 34px; padding: 0 16px; cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--outline); }
.segmented button[aria-selected="true"] { background: var(--primary-container); color: var(--on-primary-container); }

.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--outline-variant); text-align: center; white-space: nowrap; }
.tbl thead th { font-size: .8rem; color: var(--muted); font-weight: 500; background: var(--surface); border-bottom-color: var(--outline); }
.tbl tbody tr:last-child th, .tbl tbody tr:last-child td { border-bottom: none; }
.tbl .col-cand { text-align: left; position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 12em; font-weight: 400; }
.tbl .col-name { max-width: 7em; overflow: hidden; text-overflow: ellipsis; }
.tbl .col-count { font-variant-numeric: tabular-nums; color: var(--muted); }
.tbl tbody tr:hover td, .tbl tbody tr:hover .col-cand { background: var(--surface-2); }
.tbl tr.is-best td, .tbl tr.is-best .col-cand { background: var(--best); }
.tbl tr.is-best .col-cand { box-shadow: inset 4px 0 0 var(--best-strong); }
.tbl tr.is-confirmed td, .tbl tr.is-confirmed .col-cand { background: var(--primary-container); }
.tbl tr.is-confirmed .col-cand { box-shadow: inset 4px 0 0 var(--primary); }
.tbl th.is-me, .tbl td.is-me { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.tbl .cand-cell .badge { margin-left: 2px; }
.v { font-weight: 700; font-size: 1.05rem; }
.v2 { color: var(--yes); }
.v1 { color: var(--maybe); }
.v0 { color: var(--no); }
.v-none { color: var(--outline); }

.comments { list-style: none; padding: 0; margin: 0; }
.comments li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-container); color: var(--on-primary-container); font-weight: 600; font-size: .85rem;
}
.comments .who { display: block; font-weight: 500; font-size: .85rem; color: var(--muted); }

.answers { list-style: none; padding: 0; margin: 0 0 18px; }
.answers li {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px;
  padding: 10px 8px; border-bottom: 1px solid var(--outline-variant); border-radius: 8px;
}
.answers li:last-child { border-bottom: none; }
.answers li.is-pulse { animation: pulse 1.6s ease-out; }
@keyframes pulse { 0%, 30% { background: var(--primary-container); } 100% { background: transparent; } }
.vote-group { display: inline-flex; border: 1px solid var(--outline); border-radius: 20px; overflow: hidden; }
.vote-group input { position: absolute; opacity: 0; pointer-events: none; }
.vote-group label {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 54px; height: 40px; padding: 0 12px;
  font-weight: 700; font-size: 1.1rem; cursor: pointer; color: var(--subtle);
  border-left: 1px solid var(--outline); user-select: none; transition: background .12s, color .12s;
}
.vote-group label:first-of-type { border-left: none; }
.vote-group label:hover { background: var(--surface-2); }
.vote-group input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: -2px; }
.vote-group input[value="2"]:checked + label { background: var(--yes); color: #fff; }
.vote-group input[value="1"]:checked + label { background: var(--maybe); color: #fff; }
.vote-group input[value="0"]:checked + label { background: var(--no); color: #fff; }
@media (prefers-color-scheme: dark) {
  .vote-group input:checked + label { color: #131314 !important; }
}
.forget { margin-top: 8px; text-align: center; }

/* ---------- Created page ---------- */
.created-hero { text-align: center; padding: 32px 24px; }
.created-hero .check {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px;
  background: color-mix(in srgb, var(--yes) 18%, transparent); color: var(--yes);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Admin ---------- */
.admin-cands { list-style: none; padding: 0; margin: 0; }
.admin-cands li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 8px; border-bottom: 1px solid var(--outline-variant); border-radius: 8px; }
.admin-cands li:last-child { border-bottom: none; }
.admin-cands li.is-best { background: var(--best); }
.admin-actions { display: inline-flex; align-items: center; gap: 12px; }
.admin-actions .counts { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

/* ---------- Errors ---------- */
.error-card { text-align: center; padding: 48px 20px; }
.error-code { font-size: 3.5rem; font-weight: 300; color: var(--subtle); margin: 0; line-height: 1; }

@media (max-width: 480px) {
  .card { padding: 16px; border-radius: 12px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .vote-group label { min-width: 46px; }
  .brand { font-size: 1.15rem; }
  .create-btn { height: 40px; padding: 0 14px 0 10px; }
}

/* ---------- Site admin ---------- */
.alert {
  background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger);
  border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; font-size: .9rem;
}
.flash-site { background: var(--best); color: var(--on-best); }
.auth-card { max-width: 420px; margin: 24px auto; padding: 32px 28px; }
.auth-card h1 { text-align: center; }
.auth-card > p.muted { text-align: center; }
.auth-wide { max-width: 520px; }
.auth-icon {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center;
  background: var(--primary-container); color: var(--on-primary-container);
}
.otp { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.6rem !important; letter-spacing: .3em; text-align: center; }
.steps { padding-left: 1.4em; margin: 16px 0 0; }
.steps > li { margin-bottom: 18px; }
.steps > li > strong { display: block; margin-bottom: 4px; }
.steps > li::marker { color: var(--primary); font-weight: 600; }
.qr { background: #fff; display: inline-block; padding: 10px; border-radius: 12px; margin: 8px 0; border: 1px solid var(--outline-variant); }
.qr img { display: block; image-rendering: pixelated; }
.secret, .cmd {
  display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem;
  background: var(--surface-2); color: var(--text); padding: 10px 14px; border-radius: 8px; letter-spacing: .08em; word-break: break-all;
}
.cmd { font-size: .85rem; letter-spacing: 0; }
.site-nav { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 4px 4px 16px; }
.site-nav h1 { margin-bottom: 0; }
.site-nav p { margin: 0; }
.site-nav form { display: inline; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--outline-variant); border-radius: var(--radius); padding: 16px 20px; display: flex; flex-direction: column; }
.stat-n { font-size: 1.9rem; font-weight: 400; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: .82rem; }
.search { display: flex; gap: 8px; flex: 1; max-width: 420px; }
.search input { height: 40px; padding: 0 14px; border-radius: 20px; }
.tbl-list th, .tbl-list td { text-align: left; }
.tbl-list .col-title { font-weight: 500; max-width: 22em; overflow: hidden; text-overflow: ellipsis; }
.tbl-list .col-title a { color: var(--text); text-decoration: none; }
.tbl-list .col-title a:hover { color: var(--primary); text-decoration: underline; }
.tbl-list .col-count { text-align: right; }
.col-actions { display: flex; gap: 6px; justify-content: flex-end; }
.col-actions form { display: inline; }
.badge-open { background: var(--surface-3); color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.narrow-form { max-width: 420px; }

/* ---------- FullCalendar list (schedule) view ---------- */
.fc .fc-list { border-radius: 8px; overflow: hidden; border-color: var(--outline-variant); }
.fc .fc-list-day-cushion { background: var(--surface-2); padding: 8px 14px; text-align: left; }
.fc .fc-list-empty { min-height: 160px; }
.fc .fc-list-day-text { color: var(--text); text-decoration: none; font-weight: 500; }
.fc .fc-list-day.fc-day-sun .fc-list-day-text { color: var(--sun); }
.fc .fc-list-day.fc-day-sat .fc-list-day-text { color: var(--sat); }
.fc .fc-list-day.fc-day-today .fc-list-day-text { color: var(--primary); }
.fc .fc-list-event td { padding: 10px 14px; border-color: var(--outline-variant); }
.fc .fc-list-event-time { color: var(--muted); font-variant-numeric: tabular-nums; width: 9em; }
/* List rows are table rows: keep them neutral and show the candidate's color in the dot. */
.fc .fc-list-event, .fc .fc-list-event.cand-new, .fc .fc-list-event.cand-existing, .fc .fc-list-event.cand,
.fc .fc-list-event.cand-best, .fc .fc-list-event.cand-confirmed { background: transparent; box-shadow: none; color: var(--text); }
.fc .fc-list-event .ev { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fc .fc-list-event .ev-time, .fc .fc-list-event .ev-sub { font-size: .88rem; font-weight: 400; opacity: 1; overflow: visible; }
.fc .fc-list-event-dot { border-width: 6px; border-color: var(--primary); }
.fc .cand-existing .fc-list-event-dot { border-color: var(--outline); }
.fc .cand .fc-list-event-dot { border-color: var(--primary-container); }
.fc .cand-best .fc-list-event-dot { border-color: var(--best-strong); }
.fc .cand-confirmed .fc-list-event-dot { border-color: var(--primary); }
.fc .cand-existing .ev-time { color: var(--muted); }
.fc .fc-list-empty { background: var(--surface); color: var(--muted); }
