:root {
  --bg: #EBEBEB;
  --surface: #F7F7F6;
  --surface-alt: #E0E0DD;
  --border: #D4D4D0;
  --text: #3D3C32;
  --text-secondary: #6E6D62;
  --text-tertiary: #9C9B8F;
  --accent: #3D3C32;
  --accent-contrast: #F7F7F6;
  --success: #16A34A;
  --destructive: #66140E;
  --oneoff: #BDA562;
  --oneoff-contrast: #2A2416;
  --today-bg: rgba(61, 60, 50, 0.08);
  --today-accent: #66140E;
  --repeating-card-bg: #1B2C3B;
  --oneoff-card-bg: #BDA562;
  --repeating-unconfirmed-bg: #8D969D;
  --oneoff-unconfirmed-bg: #D7C9A1;
  --shadow-sm: 0 1px 2px rgba(29, 35, 38, 0.08);
  --shadow-md: 0 8px 24px rgba(29, 35, 38, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1B2C3B;
    --surface: #24374A;
    --surface-alt: #2C4053;
    --border: #3A576D;
    --text: #EBEBEB;
    --text-secondary: #ABAAA0;
    --text-tertiary: #7E7D73;
    --accent: #83827C;
    --accent-contrast: #1B2C3B;
    --success: #4ADE80;
    --destructive: #C08581;
    --oneoff: #BDA562;
    --oneoff-contrast: #2A2416;
    --today-bg: rgba(131, 130, 124, 0.16);
    --today-accent: #C08581;
    --repeating-card-bg: #8D969D;
    --oneoff-card-bg: #BDA562;
    --repeating-unconfirmed-bg: #BBC0C4;
    --oneoff-unconfirmed-bg: #D7C9A1;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: 0.8; }

.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; }

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

.nav-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 8px;
}

/* Sliding-pill background for the Wiederkehrend/Einmalig mode toggle - see
   setupSlidingToggle in shared.js. Sits behind the buttons (z-index 0) and
   animates its position/size/color on activation. */
.toggle-slider {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  z-index: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s cubic-bezier(.4, 0, .2, 1), width 0.25s cubic-bezier(.4, 0, .2, 1), background 0.15s ease;
}

.week-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 4px;
  flex-wrap: wrap;
}

.large-title {
  font-size: 29px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
  display: flex;
  align-items: center;
}

.title-icon {
  font-size: 26px;
  margin-right: 10px;
  line-height: 1;
}

.row-icon {
  display: inline-block;
  font-size: 15px;
  margin-right: 8px;
  line-height: 1;
}

.week-nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-cluster {
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--surface-alt);
  border-radius: 99px;
  padding: 3px;
}

.nav-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icon-btn:hover { background: var(--surface); color: var(--text); }

.today-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: 99px;
  border: none;
  background: var(--today-accent);
  color: var(--accent-contrast);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.today-btn:hover { opacity: 0.85; }

.legend-row {
  display: flex;
  gap: 16px;
  margin: 12px 0 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.legend-dot.repeating { background: var(--repeating-card-bg); }
.legend-dot.oneoff { background: var(--oneoff); }

.mode-toggle {
  position: relative;
  display: inline-flex;
  height: 38px;
  box-sizing: border-box;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.mode-option {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.mode-option.active[data-mode="repeating"] { color: var(--accent-contrast); }
.mode-option.active[data-mode="oneoff"] { color: var(--oneoff-contrast); }

.mode-option:disabled { cursor: not-allowed; opacity: 0.75; }
.mode-option:disabled:not(.active) { opacity: 0.45; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin: 0 0 10px 2px;
}

.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.row:last-child { border-bottom: none; }

.row.tappable { cursor: pointer; transition: background 0.12s ease; }
.row.tappable:hover { background: var(--surface-alt); }

.row-leading {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.row-trailing {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.chevron {
  color: var(--text-tertiary);
  font-size: 15px;
  font-weight: 600;
}

.value-muted { color: var(--text-secondary); }

.room-code {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.hint-text {
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* Matches .room-input's font-size, so the ICS feed URLs read at the same
   size as the settings field values (e.g. the Notify endpoint text). */
.hint-text.ics-path {
  font-size: 14.5px;
}

.accent-text { color: var(--accent); font-weight: 600; }

/* Documentation view */

.docs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.docs-card h2 {
  font-size: 15px;
  font-weight: 800;
  margin: 30px 0 8px;
  color: var(--text);
}
.docs-card h2:first-child { margin-top: 0; }

.docs-card p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.docs-card ul {
  margin: 4px 0 10px 20px;
  padding: 0;
}
.docs-card li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.docs-card strong { color: var(--text); font-weight: 700; }

.docs-card code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--text);
}

/* Week calendar grid */

.calendar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.calendar-header-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.calendar-time-gutter {
  width: 46px;
  flex-shrink: 0;
}

.calendar-day-header {
  flex: 1;
  padding: 10px 4px 8px;
  text-align: center;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.calendar-day-header.weekend-col { background: var(--surface-alt); }
.calendar-day-header.today-col { background: var(--today-bg); }
.calendar-day-header.past-col { background: var(--surface-alt); opacity: 0.55; }

.calendar-day-header .day-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.calendar-day-header .day-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-day-header .day-date.today-badge {
  background: var(--today-accent);
  color: var(--accent-contrast);
}

.calendar-scroll-area {
  max-height: var(--visible-h);
  overflow: hidden;
}

.calendar-body {
  display: flex;
  position: relative;
}

.calendar-scroll-buttons {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-scroll-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.calendar-scroll-btn:hover { background: var(--surface-alt); color: var(--text); }

.calendar-hour-label {
  height: var(--row-h);
  position: relative;
  border-top: 1px solid var(--border);
}

.calendar-hour-label span {
  position: absolute;
  top: -6px;
  right: 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  color: var(--text-tertiary);
  background: var(--surface);
  padding-left: 3px;
}

.calendar-day-column.weekend-col { background-color: var(--surface-alt); }
.calendar-day-column.today-col { background-color: var(--today-bg); }
.calendar-day-column.past-col { background-color: var(--surface-alt); opacity: 0.55; }

.calendar-day-column {
  flex: 1;
  position: relative;
  border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--row-h) - 1px),
    var(--border) calc(var(--row-h) - 1px),
    var(--border) var(--row-h)
  );
}

.calendar-block {
  position: absolute;
  left: 3px;
  right: 3px;
  background: var(--repeating-card-bg);
  color: var(--accent-contrast);
  border: none;
  border-radius: 10px;
  padding: 7px 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.calendar-block:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.calendar-block.oneoff { background: var(--oneoff-card-bg); color: var(--oneoff-contrast); }
.calendar-block.unconfirmed { background: var(--repeating-unconfirmed-bg); color: var(--accent-contrast); }
.calendar-block.oneoff.unconfirmed { background: var(--oneoff-unconfirmed-bg); color: var(--oneoff-contrast); }
.calendar-block.past { cursor: default; }
.calendar-block.past:hover { transform: none; box-shadow: none; }
/* A still-extending booking (see the hour-by-hour claim chain) is rendered
   as two stacked pieces sharing one visual card - solid for the hours
   actually secured, pale for the hours still to come - so the fill
   visibly grows as each extension step succeeds. */
.calendar-block.split-top { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.calendar-block.split-bottom {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  padding-top: 4px;
  border-top: 1px dashed rgba(0, 0, 0, 0.12);
}
.calendar-block.ghost {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
  box-shadow: none;
}
/* Muted text for ghost/unconfirmed/past: dims relative to each block's own
   (dark-on-light or light-on-dark) text color via opacity, rather than a
   fixed gray - a fixed color reads fine on the dark navy repeating blocks
   but disappears against the lighter gold one-time / unconfirmed fills. */
.calendar-block.ghost .room-code,
.calendar-block.unconfirmed .room-code,
.calendar-block.past .room-code {
  opacity: 0.55;
}
.calendar-block.ghost .time-range,
.calendar-block.unconfirmed .time-range,
.calendar-block.past .time-range {
  opacity: 0.55;
}

.calendar-block .room-code { font-size: 12.5px; line-height: 1.15; color: inherit; font-weight: 700; }
.calendar-block .time-range { font-size: 10px; color: inherit; opacity: 0.8; margin-top: 2px; font-weight: 600; }
.calendar-block .backups-hint { font-size: 9.5px; color: inherit; opacity: 0.65; margin-top: 3px; }

.calendar-day-column.droppable { cursor: crosshair; }

.calendar-drag-selection {
  position: absolute;
  left: 3px;
  right: 3px;
  /* Diagonal hatch instead of a flat fill - a flat var(--surface-alt) fill
     is literally invisible when dragging over a weekend column, which uses
     that same color as its background. */
  background: repeating-linear-gradient(
    45deg,
    var(--border),
    var(--border) 4px,
    var(--surface) 4px,
    var(--surface) 9px
  );
  border: none;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 35, 38, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.visible { opacity: 1; pointer-events: auto; }

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.modal-backdrop.visible .modal { transform: translateY(0) scale(1); opacity: 1; }

/* Docs is long-form text, not a form - wider than the default modal. */
.docs-modal { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
  background: var(--surface-alt);
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  overflow-y: auto;
  padding: 18px;
  flex: 1;
}

.modal-footer {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.time-input, .room-input {
  border: none;
  background: none;
  font-size: 14.5px;
  color: var(--text);
  text-align: right;
  font-family: inherit;
  width: 100%;
  padding: 0;
}
.time-input { width: auto; }
.room-input::placeholder { color: var(--text-tertiary); }

.primary-button {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 14.5px;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
}
.primary-button:hover { opacity: 0.9; }

.secondary-button {
  background: var(--surface-alt);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px;
  font-size: 13.5px;
  font-weight: 600;
  width: 100%;
  margin: 4px 0 20px;
  cursor: pointer;
}
.secondary-button:hover { background: var(--border); }

#open-docs-btn {
  width: auto;
  display: block;
  margin: 4px 0 20px auto;
  padding: 9px 16px;
}

.destructive-button {
  background: var(--destructive);
  color: #FFFFFF;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 14.5px;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
}
.destructive-button:hover { opacity: 0.9; }

/* In-design confirm/alert dialogs (replace window.confirm/alert) */

.dialog-modal { max-width: 360px; }

.dialog-body { padding: 26px 22px 6px; text-align: center; }

.dialog-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.dialog-message {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.dialog-footer {
  display: flex;
  flex-direction: row;
  gap: 10px;
  padding: 18px 22px 22px;
}

.dialog-footer .primary-button,
.dialog-footer .secondary-button,
.dialog-footer .destructive-button {
  width: auto;
  flex: 1;
  margin: 0;
}

#confirmed-ics-path, #planned-ics-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 200px;
}

.copy-button {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.copy-button:hover { color: var(--text); }
.copy-button.copied { color: var(--success); }

.destructive-text-button {
  background: none;
  border: none;
  color: var(--destructive);
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px;
  cursor: pointer;
}

/* Top-of-page loading bar (see shared.js _requestStarted/_requestFinished) -
   grows slowly while a request is in flight (an indeterminate creep, since
   the actual duration isn't known - a real booking action can take several
   real seconds), then snaps to full width and fades out once it resolves. */
#loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--repeating-card-bg);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
}
#loading-bar.active {
  opacity: 1;
  width: 75%;
  transition: width 4s cubic-bezier(0.1, 0.6, 0.2, 1), opacity 0.15s ease;
}
#loading-bar.active.done {
  width: 100%;
  transition: width 0.15s ease, opacity 0.25s ease 0.15s;
  opacity: 0;
}

/* Login gate: a modal popup (reusing .modal-backdrop/.modal) over the main
   page, which stays visible-but-blurred behind it while signed out (see
   app.js's auth bootstrap) rather than being swapped out for a separate
   screen. Reuses .group/.row/.primary-button so it reads as the same app. */
.auth-backdrop {
  z-index: 20; /* above the block-editor sheet's backdrop (z-index 10) - the
                  two never show at once in practice, but if they did, the
                  login gate should win. */
}

.auth-modal {
  width: 100%;
  max-width: 420px;
  padding: 28px 24px;
}

/* Blurred + inert while signed out - clearing the fields on logout (see
   resetMainPageContent in app.js) means this is only ever a blurred glimpse
   of empty UI chrome, never a lingering trace of someone else's data. */
.page.blurred {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

.auth-error {
  color: var(--destructive);
  margin: -6px 2px 14px;
}

.nav-account {
  display: flex;
  align-items: center;
  gap: 8px;
}
