:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #657084;
  --line: #dfe4ec;
  --panel: #ffffff;
  --surface: #f5f7fb;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  background: #e7edf7;
  color: #1f2a44;
}

.secondary:hover {
  background: #dbe5f3;
}

.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #ffd0cc;
}

.danger:hover {
  background: #ffe4e1;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px 1fr;
}

.sidebar {
  background: #fbfcff;
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 0 8px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(145deg, #0f766e, #2563eb);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand h1,
.toolbar h2,
.share-view h2 {
  margin: 0;
  line-height: 1.1;
}

.brand h1 {
  font-size: 20px;
}

.brand p,
.toolbar p,
.share-view p,
.hint {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  margin-bottom: 12px;
}

.status-pill {
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.connected {
  color: var(--accent-strong);
  background: #e3f7f4;
  border-color: #9ddbd2;
}

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

.field span,
.check span {
  color: #3b4658;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
  outline: none;
}

.field textarea {
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.compact {
  margin-top: 12px;
}

.auth-panel button {
  width: 100%;
  margin-bottom: 8px;
}

.google-oidc-button {
  min-height: 42px;
  margin-bottom: 10px;
}

.google-oidc-button:empty {
  display: none;
}

.advanced-auth {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.advanced-auth summary {
  cursor: pointer;
  color: #344154;
  font-size: 13px;
  font-weight: 800;
}

.preset-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  margin-bottom: 14px;
}

.preset-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.preset-actions button {
  min-width: 0;
  padding-inline: 8px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.toolbar h2 {
  font-size: clamp(24px, 3vw, 34px);
}

.confirmation-panel,
.ongoing-panel {
  margin-bottom: 16px;
}

.confirmation-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 0.8fr);
  gap: 12px;
  align-items: end;
}

.confirmation-grid h3 {
  margin: 0;
  font-size: 18px;
}

.confirmation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ongoing-list {
  display: grid;
  gap: 8px;
}

.ongoing-list.empty {
  color: var(--muted);
}

.ongoing-item {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: #fbfdff;
  color: var(--ink);
  text-align: left;
}

.ongoing-item:hover {
  background: #f4fbfa;
}

.ongoing-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.controls-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.step-actions,
.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.step-actions button,
.output-actions button {
  min-width: 150px;
}

.selection-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(420px, 1.22fr);
  gap: 16px;
  margin-bottom: 16px;
}

.calendar-panel {
  min-width: 0;
}

.calendar-view-controls {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.calendar-view-controls .field {
  margin-bottom: 0;
  min-width: 220px;
}

.calendar-grid-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed #cfd7e3;
  border-radius: 8px;
  color: var(--muted);
  background: #fbfdff;
  text-align: center;
  padding: 18px;
}

.calendar-grid {
  --calendar-columns: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: 520px;
}

.calendar-header-row,
.calendar-row {
  display: grid;
  grid-template-columns: 140px repeat(var(--calendar-columns), minmax(150px, 1fr));
  min-width: calc(140px + (150px * var(--calendar-columns)));
}

.calendar-header-row {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef3f9;
  border-bottom: 1px solid var(--line);
}

.calendar-time-head,
.calendar-calendar-head {
  padding: 10px;
  font-size: 13px;
  font-weight: 800;
  color: #344154;
  border-right: 1px solid var(--line);
}

.calendar-calendar-head {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-row {
  width: 100%;
  min-height: 44px;
  padding: 0;
  border-radius: 0;
  border-bottom: 1px solid #edf1f6;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 600;
}

.calendar-row:hover {
  background: #f4fbfa;
}

.calendar-row.calendar-selected {
  background: #e6f8f5;
  box-shadow: inset 4px 0 0 var(--accent);
}

.calendar-time-cell,
.calendar-cell {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border-right: 1px solid #edf1f6;
  font-size: 13px;
}

.calendar-time-cell {
  color: #344154;
  background: #fbfcff;
  font-weight: 800;
}

.calendar-cell {
  justify-content: center;
}

.calendar-cell.free {
  color: #0f766e;
  background: #f1fbf9;
}

.calendar-cell.busy {
  color: #8a3a24;
  background: #fff4ed;
}

.slot-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.slot-list.empty {
  color: var(--muted);
}

.slot {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.slot.selected {
  border-color: #7bc7bd;
  background: #f0fbfa;
}

.slot input {
  margin-top: 5px;
}

.slot-time {
  font-weight: 800;
  line-height: 1.35;
}

.slot-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.token {
  border: 1px solid #cfd7e3;
  border-radius: 999px;
  padding: 3px 8px;
  color: #344154;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.output-panel,
.results-panel {
  min-height: 360px;
}

.hold-box {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.hold-box button {
  width: 100%;
}

.grow textarea {
  min-height: 260px;
}

.message {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.message.error {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.share-view {
  max-width: 880px;
  margin: 0 auto;
  padding: 36px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.share-topline {
  color: var(--accent-strong);
  font-weight: 800;
  margin-bottom: 10px;
}

.share-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.share-slot {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
}

.share-slot button {
  width: 100%;
  margin-top: 10px;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .controls-grid,
  .selection-layout {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
  }

  .confirmation-grid {
    grid-template-columns: 1fr;
  }

  .calendar-view-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar-view-controls .field,
  .calendar-view-controls button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .toolbar-actions button {
    width: 100%;
  }
}

/* --- UX brushup additions --- */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 50;
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 10px;
  background: #10241f;
  color: #eafaf6;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast.error {
  background: #5b1411;
  color: #ffe7e3;
}

.auth-status {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.auth-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.auth-status-label {
  font-size: 13px;
  font-weight: 700;
  color: #3b4658;
}

.auth-step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 10px;
}

.auth-step-num {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.auth-step-body {
  min-width: 0;
}

.auth-step-body .hint {
  margin-top: 6px;
}

.auth-panel .auth-step-body button {
  margin-bottom: 0;
}

.ghost {
  background: transparent;
  border: 1px solid #cfd7e3;
  color: #344154;
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.ghost:hover {
  background: #eef3f9;
}

.slot-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.slot-controls-buttons {
  display: flex;
  gap: 8px;
}

.notice {
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fcd9b6;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.45;
}

.slot-date-head {
  position: sticky;
  top: 0;
  background: #eef3f9;
  color: #344154;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 6px;
  margin: 4px 0 2px;
  z-index: 1;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.token.token-free {
  color: #0f766e;
  border-color: #9ddbd2;
  background: #f1fbf9;
}

.token.token-busy {
  color: #8a3a24;
  border-color: #f3c3ad;
  background: #fff4ed;
}

.confirmation-hint {
  margin-top: 10px;
}

.confirmation-hint.error {
  color: var(--danger);
}

/* --- Wizard --- */
.view-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.view-head h2 {
  margin: 0;
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.15;
}

.view-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.view-head button {
  flex: none;
}

.wizard {
  display: flex;
  flex-direction: column;
}

.wizard-head {
  margin-bottom: 16px;
}

.stepper {
  display: flex;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.stepper-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  min-height: 44px;
  border-radius: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.stepper-item:hover {
  background: #f1f5fb;
}

.stepper-num {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e7edf7;
  color: #5b6678;
  font-size: 13px;
  font-weight: 800;
  flex: none;
}

.stepper-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.stepper-item.active {
  color: var(--ink);
  background: #eef6f5;
}

.stepper-item.active .stepper-num {
  background: var(--accent);
  color: #fff;
}

.stepper-item.done {
  color: var(--accent-strong);
}

.stepper-item.done .stepper-num {
  background: #cdeae5;
  color: var(--accent-strong);
}

.wizard-foot {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

#wizardNext {
  margin-left: auto;
}

.wizard-foot .primary,
.wizard-foot .secondary {
  min-width: 160px;
}

.hint code {
  background: #eef3f9;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

@media (max-width: 560px) {
  .stepper-label {
    display: none;
  }

  .wizard-foot .primary,
  .wizard-foot .secondary {
    min-width: 120px;
  }
}
