:root {
  color-scheme: light;
  --bg: #e9eef2;
  --ink: #202124;
  --muted: #687385;
  --line: #dfe4ec;
  --panel: #ffffff;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --accent: #0f9f6e;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 14px 35px rgba(33, 45, 70, 0.1);
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 17px;
}

.status-pill,
.metric {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef4ff;
  color: var(--primary-strong);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
}

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

.control-panel,
.result-panel,
.booking-panel,
.live-panel,
.agenda-panel {
  padding: 18px;
}

.control-panel {
  align-self: start;
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 560px;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  padding: 0;
}

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

.panel-kicker {
  margin: 0 0 3px;
  color: #d9f99d;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 11px;
  background: #075e54;
  color: #ffffff;
  padding: 14px 16px;
}

.chat-header h2 {
  font-size: 16px;
}

.chat-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
  background: #dcfce7;
  color: #075e54;
  font-size: 13px;
  font-weight: 900;
}

.chat-presence {
  display: block;
  margin-top: 2px;
  color: #ccfbf1;
  font-size: 12px;
  font-weight: 700;
}

.content-stack {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

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

.booking-grid .secondary-button {
  grid-column: 1 / -1;
}

button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button,
.secondary-button,
.secondary-outline-button {
  width: 100%;
  padding: 12px 14px;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

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

.secondary-button {
  background: #111827;
  color: #fff;
}

.secondary-outline-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #111827;
}

.chat-box {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(rgba(236, 229, 221, 0.92), rgba(236, 229, 221, 0.92)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.35) 0 2px, transparent 2px 12px);
  padding: 14px;
  margin: 0;
}

.chat-box::-webkit-scrollbar {
  width: 8px;
}

.chat-box::-webkit-scrollbar-track {
  background: rgba(7, 94, 84, 0.08);
}

.chat-box::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(7, 94, 84, 0.32);
}

.chat-message {
  width: fit-content;
  max-width: 84%;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.12);
  white-space: pre-line;
}

.chat-message.assistant {
  align-self: flex-start;
  border: 0;
  background: #ffffff;
  color: #172554;
  border-top-left-radius: 2px;
}

.chat-message.user {
  align-self: flex-end;
  background: #dcf8c6;
  color: #102a1f;
  border-top-right-radius: 2px;
}

.chat-message.system {
  align-self: flex-start;
  border: 0;
  background: #e8f5ff;
  color: #075985;
}

.chat-message.typing {
  color: #475569;
}

.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  background: #f0f2f5;
  border-top: 1px solid #d1d7de;
  padding: 10px;
  margin: 0;
}

.chat-composer textarea {
  min-height: 54px;
  max-height: 132px;
  border-color: transparent;
  border-radius: 18px;
  font-size: 15px;
  resize: none;
}

.send-button {
  align-self: stretch;
  min-width: 82px;
  border-radius: 18px;
  background: #128c7e;
  color: #fff;
  padding: 0 14px;
  touch-action: none;
  user-select: none;
}

.send-button:hover {
  background: #075e54;
}

.send-button.recording {
  background: #b91c1c;
}

.send-button.recording:hover {
  background: #991b1b;
}

.hidden-chat-settings,
.hidden-booking-form,
.response-box {
  display: none;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary);
  font-size: 17px;
}

.ai-message {
  margin: 0 0 14px;
  color: #334155;
  font-size: 15px;
  line-height: 1.55;
}

.recommended-slot {
  border-left: 4px solid var(--accent);
  background: #eefdf6;
  border-radius: 6px;
  color: #14543e;
  padding: 12px;
  font-weight: 700;
}

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

.live-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.appointments-list {
  display: grid;
  gap: 10px;
  max-height: 330px;
  overflow: auto;
}

.appointment-item {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #ffffff;
  padding: 11px;
}

.appointment-time {
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 900;
}

.appointment-title {
  color: #111827;
  font-size: 14px;
  font-weight: 900;
}

.appointment-meta,
.empty-state {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.event-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.event-links a {
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.calendar-nav strong {
  min-width: 170px;
  color: #111827;
  font-size: 14px;
  text-align: center;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday-grid {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  display: grid;
  min-height: 92px;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px;
  text-align: left;
}

.calendar-day.outside {
  background: #f8fafc;
  color: #a0a8b7;
}

.calendar-day.free {
  background: #f3fbf7;
  border-color: #b7e4c7;
}

.calendar-day.busy {
  background: #fff7ed;
  border-color: #fed7aa;
}

.calendar-day.empty {
  background: #f9fafb;
}

.day-number {
  font-size: 14px;
  font-weight: 900;
}

.day-count {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 900;
}

.event-preview-list {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.event-preview {
  overflow: hidden;
  border-radius: 5px;
  background: #eef2ff;
  color: #3730a3;
  padding: 4px 5px;
  font-size: 10px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day.busy .day-count {
  background: #ffedd5;
  color: #9a3412;
}

.day-agenda {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
  color: #334155;
  font-size: 14px;
  line-height: 1.5;
}

.agenda-slot-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.agenda-slot-list span {
  display: block;
  border: 1px solid #b7e4c7;
  border-radius: 7px;
  background: #ffffff;
  color: #166534;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 800;
}

.agenda-busy-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.agenda-busy-list li {
  border: 1px solid #fed7aa;
  border-radius: 7px;
  background: #fff7ed;
  color: #9a3412;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 800;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.day-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

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

.day-date {
  font-weight: 900;
}

.day-state {
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
}

.day-state.free {
  background: #dcfce7;
  color: #166534;
}

.day-state.busy {
  background: #fee2e2;
  color: var(--danger);
}

.slot-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.slot-item {
  border: 1px solid #cfe7d9;
  border-radius: 6px;
  background: #f7fdf9;
  color: #166534;
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
}

.busy-note {
  color: var(--warning);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    height: calc(100vh - 32px);
  }

  .chat-panel {
    min-height: 540px;
    max-height: calc(100vh - 32px);
  }

  .chat-box {
    min-height: 0;
  }

  .field-grid,
  .booking-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 72px;
    padding: 7px;
  }

  .day-count {
    max-width: 100%;
    font-size: 10px;
  }

  .appointment-item {
    grid-template-columns: 1fr;
  }
}
