@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Serif+Display&display=swap");

:root {
  --ink: #1f2824;
  --muted: #6d756f;
  --paper: #fbfaf6;
  --paper-deep: #f1ede4;
  --line: rgba(31, 40, 36, 0.13);
  --moss: #315f50;
  --moss-deep: #24483d;
  --sage: #dce8df;
  --amber: #c78552;
  --danger: #a64d43;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: #e8e4da;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,.82), transparent 31%),
    linear-gradient(135deg, #e8e3d7 0%, #dddcd4 100%);
}

button, select { font: inherit; }
button { color: inherit; }

.page-glow {
  position: fixed;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  opacity: .3;
}
.page-glow-one { top: -260px; left: 24%; background: #fff9e8; }
.page-glow-two { right: -250px; bottom: -280px; background: #9fbdb1; }

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 338px minmax(0, 1fr);
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  max-width: 1560px;
  margin: 16px auto;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.62);
  border-radius: 24px;
  background: rgba(251,250,246,.92);
  box-shadow: 0 24px 80px rgba(37,42,39,.16);
  backdrop-filter: blur(20px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 30px 26px 24px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(244,241,233,.82);
}

.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 34px; }
.brand-mark {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 14px;
  color: #fff; background: var(--moss);
  box-shadow: 0 8px 22px rgba(49,95,80,.22);
}
.brand-mark svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.eyebrow { font-size: 10px; font-weight: 600; letter-spacing: .17em; color: var(--moss); }
.brand-name { margin-top: 2px; font: 22px/1 "DM Serif Display", serif; }

.control-section { padding: 22px 0; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; min-height: 28px; margin-bottom: 14px; }
.section-number { margin-right: 10px; font-size: 10px; font-weight: 600; letter-spacing: .12em; color: var(--amber); }
.section-heading h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.icon-button { margin-left: auto; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--moss); background: var(--sage); }
.icon-button:disabled { opacity: .45; cursor: wait; }
.icon-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented-control label { min-width: 0; cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span {
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-template-rows: auto auto;
  column-gap: 7px;
  min-height: 77px;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.54);
  transition: .18s ease;
}
.segmented-control svg { grid-row: 1 / 3; width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.segmented-control strong { font-size: 12px; font-weight: 600; }
.segmented-control small { margin-top: 4px; font-size: 9px; line-height: 1.35; color: var(--muted); }
.segmented-control input:checked + span { color: var(--moss-deep); border-color: rgba(49,95,80,.45); background: var(--sage); box-shadow: inset 0 0 0 1px rgba(49,95,80,.08); }
.segmented-control input:focus-visible + span { outline: 2px solid var(--moss); outline-offset: 2px; }
.segmented-control input:disabled + span { opacity: .55; cursor: not-allowed; }

.select-field { position: relative; display: block; }
.select-field select {
  width: 100%; height: 48px; padding: 0 42px 0 14px;
  appearance: none;
  border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); background: rgba(255,255,255,.72);
  outline: none; cursor: pointer;
}
.select-field select:focus { border-color: rgba(49,95,80,.65); box-shadow: 0 0 0 3px rgba(49,95,80,.1); }
.select-field select:disabled { color: var(--muted); cursor: not-allowed; }
.select-field > svg { position: absolute; top: 15px; right: 13px; width: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.voice-meta { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 10px; color: var(--muted); }
.meta-pill { padding: 3px 6px; border-radius: 5px; color: var(--moss-deep); background: var(--sage); font-size: 8px; font-weight: 600; letter-spacing: .1em; }

.prompt-card { margin-top: 14px; padding: 17px; border: 1px solid rgba(199,133,82,.22); border-radius: 15px; background: #f6eadc; }
.prompt-label { font-size: 8px; font-weight: 600; letter-spacing: .15em; color: #93603b; }
.prompt-card p { min-height: 58px; margin: 9px 0 11px; font: 16px/1.32 "DM Serif Display", serif; color: #553e2e; }
.prompt-card button { padding: 0; border: 0; color: #93603b; background: transparent; font-size: 10px; font-weight: 600; cursor: pointer; }
.prompt-card button:hover { text-decoration: underline; }

.sidebar-footer { display: flex; gap: 8px; align-items: flex-start; margin-top: auto; padding-top: 20px; font-size: 9px; line-height: 1.45; color: #858b87; }
.privacy-dot { flex: 0 0 auto; width: 7px; height: 7px; margin-top: 3px; border-radius: 50%; background: #7ca18e; box-shadow: 0 0 0 3px rgba(124,161,142,.14); }

.conversation-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); }
.conversation-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; padding: 34px 40px 28px; border-bottom: 1px solid var(--line); }
.conversation-header h1 { margin: 8px 0 5px; font: clamp(30px, 3vw, 45px)/1.04 "DM Serif Display", serif; font-weight: 400; letter-spacing: -.02em; }
.conversation-header p { max-width: 670px; margin: 0; font-size: 13px; color: var(--muted); }
.header-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.status-badge { display: flex; align-items: center; gap: 8px; white-space: nowrap; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 10px; font-weight: 500; color: var(--muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #aeb4b0; }
.status-badge[data-state="active"] .status-dot { background: #4d8b71; box-shadow: 0 0 0 4px rgba(77,139,113,.12); animation: breathe 1.8s ease-in-out infinite; }
.status-badge[data-state="speaking"] .status-dot { background: var(--amber); box-shadow: 0 0 0 4px rgba(199,133,82,.14); animation: breathe .8s ease-in-out infinite; }
.status-badge[data-state="error"] .status-dot { background: var(--danger); }
.text-button { padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 9px; cursor: pointer; }
.text-button:hover { color: var(--ink); text-decoration: underline; }

.transcript { flex: 1; min-height: 0; padding: 30px 40px 150px; overflow-y: auto; scroll-behavior: smooth; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; padding-bottom: 40px; text-align: center; }
.empty-state h2 { margin: 23px 0 7px; font: 26px/1.15 "DM Serif Display", serif; font-weight: 400; }
.empty-state p { max-width: 430px; margin: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.sound-mark { display: flex; align-items: center; gap: 5px; height: 54px; padding: 0 22px; border-radius: 27px; color: var(--moss); background: var(--sage); }
.sound-mark i { display: block; width: 3px; height: 15px; border-radius: 3px; background: currentColor; }
.sound-mark i:nth-child(2), .sound-mark i:nth-child(4) { height: 28px; }
.sound-mark i:nth-child(3) { height: 39px; }

.history-divider { display: flex; align-items: center; gap: 12px; max-width: 800px; margin: 3px auto 24px; color: #8a918d; font-size: 8px; font-weight: 600; letter-spacing: .13em; text-align: center; }
.history-divider::before,
.history-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.history-divider span { flex: 0 0 auto; }
.message.is-history { opacity: .76; }
.message.is-history .message-body { box-shadow: none; }

.message { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 12px; max-width: 800px; margin-bottom: 25px; animation: message-in .24s ease-out; }
.message.user { margin-left: auto; grid-template-columns: minmax(0, 1fr) 36px; }
.message-avatar { grid-row: 1 / 3; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; font: 14px "DM Serif Display", serif; color: var(--moss-deep); background: var(--sage); }
.message.user .message-avatar { grid-column: 2; color: #6f4b30; background: #f1dfce; }
.message-role { margin: 1px 0 6px; font-size: 9px; font-weight: 600; letter-spacing: .11em; color: var(--muted); }
.message.user .message-role { grid-column: 1; text-align: right; }
.message-body { grid-column: 2; justify-self: start; min-width: 0; padding: 13px 16px; border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; background: #fff; box-shadow: 0 7px 20px rgba(31,40,36,.045); font-size: 14px; line-height: 1.58; }
.message.user .message-body { grid-column: 1; justify-self: end; border-radius: 16px 4px 16px 16px; border-color: transparent; color: #fff; background: var(--moss); white-space: pre-wrap; }
.message.assistant .message-body > :first-child { margin-top: 0; }
.message.assistant .message-body > :last-child { margin-bottom: 0; }
.message.assistant .message-body p { margin: 0 0 .75em; }
.message.assistant .message-body h1,
.message.assistant .message-body h2,
.message.assistant .message-body h3,
.message.assistant .message-body h4,
.message.assistant .message-body h5,
.message.assistant .message-body h6 { margin: 1em 0 .45em; color: var(--moss-deep); font-family: "DM Serif Display", serif; font-weight: 400; line-height: 1.18; }
.message.assistant .message-body h1 { font-size: 1.55em; }
.message.assistant .message-body h2 { font-size: 1.38em; }
.message.assistant .message-body h3 { font-size: 1.2em; }
.message.assistant .message-body h4,
.message.assistant .message-body h5,
.message.assistant .message-body h6 { font-size: 1.05em; font-family: inherit; font-weight: 600; }
.message.assistant .message-body ul,
.message.assistant .message-body ol { margin: .55em 0 .8em; padding-left: 1.45em; }
.message.assistant .message-body li { margin: .25em 0; padding-left: .1em; }
.message.assistant .message-body strong { color: var(--moss-deep); font-weight: 600; }
.message.assistant .message-body em { color: #4f5e57; }
.message.assistant .message-body a { color: var(--moss); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.message.assistant .message-body blockquote { margin: .8em 0; padding: .1em 0 .1em 1em; border-left: 3px solid #a9c1b4; color: #55645d; }
.message.assistant .message-body blockquote p { margin: .2em 0; }
.message.assistant .message-body code { padding: .12em .34em; border-radius: 5px; color: #754d35; background: #f4ece4; font: .88em ui-monospace, SFMono-Regular, Menlo, monospace; }
.message.assistant .message-body pre { max-width: 100%; margin: .8em 0; padding: 12px; overflow-x: auto; border-radius: 9px; background: #26312c; color: #f3f5f3; }
.message.assistant .message-body pre code { padding: 0; color: inherit; background: transparent; line-height: 1.5; }
.message.assistant .message-body hr { margin: 1em 0; border: 0; border-top: 1px solid var(--line); }
.message.assistant .message-body table { display: block; max-width: 100%; margin: .8em 0; overflow-x: auto; border-collapse: collapse; font-size: .92em; }
.message.assistant .message-body th,
.message.assistant .message-body td { padding: 7px 9px; border: 1px solid var(--line); text-align: left; }
.message.assistant .message-body th { color: var(--moss-deep); background: var(--sage); font-weight: 600; }
.message.pending .message-body::after { content: ""; display: inline-block; width: 5px; height: 12px; margin-left: 4px; vertical-align: -1px; background: currentColor; opacity: .4; animation: blink .8s steps(2) infinite; }
.message-time { margin-top: 5px; font-size: 8px; color: #969b97; }
.message.user .message-time { grid-column: 1; text-align: right; }
.message.assistant .message-time { grid-column: 2; }

.call-dock { position: absolute; right: 32px; bottom: 26px; left: 370px; display: grid; grid-template-columns: 42px minmax(220px, 330px) 72px; align-items: center; justify-content: center; gap: 13px; padding: 13px 16px; border: 1px solid rgba(31,40,36,.12); border-radius: 21px; background: rgba(255,255,255,.9); box-shadow: 0 18px 48px rgba(31,40,36,.14); backdrop-filter: blur(18px); }
.round-button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: #f7f6f2; cursor: pointer; }
.round-button:disabled { opacity: .38; cursor: not-allowed; }
.round-button:not(:disabled):hover { background: var(--paper-deep); }
.round-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.round-button .mic-off { display: none; }
.round-button.is-muted { color: #fff; border-color: var(--danger); background: var(--danger); }
.round-button.is-muted .mic-on { display: none; }
.round-button.is-muted .mic-off { display: block; }
.call-button { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 16px 8px 8px; border: 0; border-radius: 14px; color: #fff; background: var(--moss); cursor: pointer; box-shadow: 0 8px 22px rgba(49,95,80,.2); transition: transform .16s ease, background .16s ease; }
.call-button:hover { background: var(--moss-deep); transform: translateY(-1px); }
.call-button:disabled { opacity: .65; cursor: wait; transform: none; }
.call-icon { display: grid; place-items: center; flex: 0 0 auto; width: 37px; height: 37px; border-radius: 10px; background: rgba(255,255,255,.14); }
.call-icon svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.call-icon .stop-icon { display: none; }
.call-copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; text-align: left; }
.call-copy strong { font-size: 12px; font-weight: 600; }
.call-copy small { margin-top: 2px; font-size: 8px; color: rgba(255,255,255,.68); }
.call-button.is-active { background: #8b463f; }
.call-button.is-active .start-icon { display: none; }
.call-button.is-active .stop-icon { display: block; fill: currentColor; stroke: none; }
.session-time { display: flex; align-items: center; justify-content: center; gap: 7px; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.timer-dot { width: 6px; height: 6px; border-radius: 50%; background: #c4c7c4; }
.session-time.is-active .timer-dot { background: #d16358; animation: breathe 1.4s ease-in-out infinite; }

.toast { position: fixed; right: 28px; bottom: 28px; z-index: 10; max-width: 360px; padding: 12px 16px; border-radius: 11px; color: #fff; background: #343b37; box-shadow: 0 12px 36px rgba(0,0,0,.2); font-size: 11px; line-height: 1.4; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@keyframes breathe { 50% { opacity: .45; transform: scale(.82); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes message-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 920px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 1fr; width: 100%; height: auto; min-height: 100vh; margin: 0; border: 0; border-radius: 0; }
  .sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; padding: 22px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { grid-column: 1 / 3; margin-bottom: 16px; }
  .control-section[aria-labelledby="conversation-heading"] { grid-column: 1 / 3; }
  .prompt-card, .sidebar-footer { display: none; }
  .control-section { padding: 16px 0 4px; }
  .conversation-panel { min-height: 620px; }
  .conversation-header { padding: 26px 22px 22px; }
  .conversation-header p { display: none; }
  .transcript { padding: 24px 22px 130px; }
  .call-dock { position: fixed; right: 14px; bottom: 14px; left: 14px; z-index: 5; }
}

@media (max-width: 580px) {
  .sidebar { display: block; }
  .brand { margin-bottom: 12px; }
  .control-section { padding-top: 14px; }
  .conversation-header { display: block; }
  .conversation-header h1 { font-size: 31px; }
  .header-actions { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 18px; }
  .call-dock { grid-template-columns: 40px 1fr; }
  .session-time { display: none; }
  .call-copy small { display: none; }
  .message { max-width: 94%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
