:root {
  --bg: #f4f1ec;
  --card: #ffffff;
  --ink: #26241f;
  --muted: #7a7568;
  --accent: #b3552f;
  --accent-soft: #f0dccb;
  --user-bubble: #e9e4da;
  --assistant-bubble: #fbf3ea;
  --border: #e5ded2;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.layout {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
  max-width: 1180px;
  flex-wrap: wrap;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(38, 36, 31, 0.08);
  display: flex;
  flex-direction: column;
  height: min(760px, 90vh);
  overflow: hidden;
}

.sidebar {
  width: 100%;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: min(760px, 90vh);
  overflow-y: auto;
}

.side-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(38, 36, 31, 0.06);
}

.side-panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.side-panel__header h2 {
  margin: 0;
  font-size: 15px;
}

.hint-small {
  font-size: 11px;
  color: var(--muted);
}

.calendar-view {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.cal-grid {
  display: grid;
  min-width: 480px;
}

.cal-cell {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 4px;
  min-height: 34px;
  box-sizing: border-box;
}

.cal-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 3;
  background: var(--card);
  border-top: none;
  border-left: none;
}

.cal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
  text-align: center;
  padding: 6px 4px;
  border-top: none;
}

.cal-head__weekday {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cal-head__date {
  font-size: 13px;
  font-weight: 700;
}

.cal-head.today {
  background: var(--accent-soft);
}

.cal-time {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--card);
  border-left: none;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  padding: 4px 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cal-slot {
  cursor: default;
}

.cal-slot.free {
  background: #fbfaf7;
}

.cal-slot.past {
  background: repeating-linear-gradient(
    135deg,
    var(--bg),
    var(--bg) 6px,
    #ece7dd 6px,
    #ece7dd 12px
  );
}

.cal-slot.booked {
  background: transparent;
}

.cal-event {
  height: 100%;
  background: var(--accent);
  color: white;
  border-radius: 5px;
  padding: 3px 5px;
  font-size: 10.5px;
  line-height: 1.25;
  overflow: hidden;
}

.cal-event__name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-event__service {
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-legend {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.cal-legend__swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -1px;
}

.cal-legend__swatch.free { background: #fbfaf7; border: 1px solid var(--border); }
.cal-legend__swatch.booked { background: var(--accent); }
.cal-legend__swatch.past { background: #ece7dd; }

.debug-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
}

.debug-turn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}

.debug-turn__total {
  font-weight: 700;
  margin-bottom: 4px;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.debug-row span:last-child {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.debug-tool {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
}

.app__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  transition: box-shadow 0.2s ease;
}

.avatar.speaking {
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.app__header h1 {
  margin: 0;
  font-size: 18px;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.admin-link {
  margin-left: auto;
  background: var(--ink);
  color: white;
  text-decoration: none;
  font-size: 13px;
  border: none;
  padding: 7px 14px;
  border-radius: 999px;
  flex-shrink: 0;
}

.admin-link:hover {
  filter: brightness(1.2);
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.45;
}

.bubble.user {
  align-self: flex-end;
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble.system {
  align-self: center;
  color: var(--muted);
  font-size: 12.5px;
  background: transparent;
}

.controls {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.mic-btn {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.2s ease;
}

.mic-btn:hover { transform: scale(1.04); }

.mic-btn.listening {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.mic-btn.recording {
  background: #c0392b;
  animation: pulse 1.4s infinite;
}

.mic-icon {
  width: 22px;
  height: 22px;
  color: white;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(192, 57, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
}

.text-form {
  flex: 1;
  display: flex;
  gap: 8px;
}

.text-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  background: #fbfaf7;
}

.text-form input:focus {
  border-color: var(--accent);
}

.text-form button {
  border: none;
  background: var(--ink);
  color: white;
  padding: 0 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}

.primary-btn {
  border: none;
  background: var(--accent);
  color: white;
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}

.primary-btn:hover {
  filter: brightness(1.05);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
