:root {
  color-scheme: light dark;
  --paper: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #edf2ef;
  --ink: #142023;
  --muted: #647176;
  --hairline: #d9e1de;
  --blue: #145de8;
  --blue-soft: #e7efff;
  --memory: #0c9078;
  --memory-soft: #ddf3ed;
  --warning: #b86714;
  --danger: #c23f4d;
  --shadow: 0 20px 55px rgb(22 38 35 / 14%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  overscroll-behavior-y: none;
}

body.sheet-open {
  overflow: hidden;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  min-height: 44px;
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.shell {
  min-height: 100dvh;
}

.login-view {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: center;
  padding: max(34px, env(safe-area-inset-top)) 28px
    max(34px, env(safe-area-inset-bottom));
}

.login-icon {
  width: 72px;
  height: 72px;
  margin-bottom: 28px;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 7vw, 34px);
  font-weight: 780;
  letter-spacing: -0.04em;
}

.login-copy {
  max-width: 26em;
  margin: 12px 0 32px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 430px;
}

.login-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-form input {
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  border-radius: 15px;
  outline: none;
  background: var(--surface);
  font-size: 17px;
}

.login-form input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgb(20 93 232 / 13%);
}

.primary-button,
.send-button {
  border: 0;
  background: var(--blue);
  color: #fff;
  font-weight: 720;
}

.primary-button {
  min-height: 50px;
  margin-top: 6px;
  border-radius: 15px;
}

.form-error {
  min-height: 22px;
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.chat-view {
  display: grid;
  min-height: 100dvh;
  grid-template-rows: auto auto auto 1fr auto auto auto;
}

.topbar {
  grid-row: 1;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: max(15px, env(safe-area-inset-top)) 16px 11px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-button,
.icon-preview {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 24px rgb(16 83 201 / 18%);
}

.avatar-button {
  width: 44px;
  padding: 0;
}

.theme-pulse {
  background:
    radial-gradient(circle at 50% 50%, #fff 0 10%, transparent 12%),
    conic-gradient(from 30deg, #36d2b6, #145de8, #6a45d8, #36d2b6);
}

.theme-zy {
  background: linear-gradient(145deg, #16252e, #145de8);
}

.theme-voice {
  background: linear-gradient(145deg, #0b8e77, #143f9e);
}

.quiet-button,
.close-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.continuity {
  grid-row: 2;
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 0 18px 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.continuity span {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.continuity b {
  height: 1px;
  background: var(--hairline);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9da8b0;
  box-shadow: 0 0 0 3px color-mix(in srgb, #9da8b0 15%, transparent);
}

.status-dot.online {
  background: var(--blue);
}

.status-dot.memory {
  background: var(--memory);
}

.connection-banner {
  grid-row: 3;
  margin: 0 16px 8px;
  padding: 9px 11px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  color: var(--warning);
  font-size: 13px;
}

.messages {
  grid-row: 4;
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 16px 18px 155px;
  scroll-behavior: smooth;
}

.message {
  max-width: min(90%, 680px);
  font-size: 16px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  padding: 12px 15px 9px;
  border-radius: 18px 18px 5px;
  background: var(--blue);
  color: #fff;
}

.message.assistant {
  align-self: flex-start;
  padding-left: 14px;
  border-left: 2px solid var(--memory);
}

.message.system {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
}

.message-meta {
  display: block;
  margin-top: 7px;
  opacity: 0.72;
  font-size: 9px;
  line-height: 1.35;
}

.approval-card {
  align-self: stretch;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--hairline));
  border-radius: 15px;
  background: var(--surface);
}

.approval-card h2 {
  margin-bottom: 6px;
  font-size: 16px;
}

.approval-card p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.approval-actions,
.voice-actions {
  display: flex;
  gap: 8px;
}

.approval-actions button,
.secondary-button,
.danger-button {
  flex: 1;
  border: 1px solid var(--hairline);
  border-radius: 11px;
  background: var(--paper);
  font-weight: 680;
}

.approval-actions .approve {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.danger-button {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--hairline));
  color: var(--danger);
}

.thinking-bar {
  grid-row: 5;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 19px;
  color: var(--muted);
  font-size: 13px;
}

.thinking-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--memory);
  animation: breathe 1.4s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    opacity: 0.25;
    transform: scale(0.78);
  }
}

.voice-panel {
  grid-row: 6;
  margin: 0 12px 8px;
  padding: 13px;
  border: 1px solid var(--hairline);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.voice-panel[data-state="recording"] {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--hairline));
}

.voice-panel[data-state="success"] {
  border-color: color-mix(in srgb, var(--memory) 55%, var(--hairline));
}

.voice-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.voice-head strong {
  font-size: 14px;
}

.voice-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.voice-head time {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.voice-waveform {
  width: 100%;
  height: 56px;
  margin: 8px 0;
  border-radius: 10px;
  background: var(--surface-soft);
}

.voice-panel progress {
  width: 100%;
  height: 7px;
  margin: 10px 0;
  accent-color: var(--memory);
}

.composer {
  grid-row: 7;
  position: sticky;
  bottom: 0;
  margin: 0 9px;
  padding: 8px 8px calc(9px + env(safe-area-inset-bottom));
  border: 1px solid var(--hairline);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 -12px 40px rgb(28 46 61 / 9%);
  backdrop-filter: blur(18px);
}

.composer-toolbar {
  display: grid;
  gap: 6px;
  padding: 0 2px 6px;
}

.mode-summary {
  min-height: 32px;
  overflow: hidden;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-chips {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.task-chips::-webkit-scrollbar {
  display: none;
}

.task-chips button {
  min-height: 29px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.task-chips button.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.composer-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}

.composer textarea {
  width: 100%;
  max-height: 156px;
  min-height: 44px;
  resize: none;
  padding: 10px 8px;
  border: 0;
  border-radius: 10px;
  outline: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.4;
}

.composer-actions {
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.round-button,
.send-button {
  border: 0;
  border-radius: 14px;
}

.round-button {
  width: 44px;
  padding: 0;
  background: var(--blue-soft);
  color: var(--blue);
}

.voice-button[data-state="recording"] {
  background: color-mix(in srgb, var(--danger) 16%, var(--surface));
  color: var(--danger);
  animation: breathe 1.1s ease-in-out infinite;
}

.stop-button {
  color: var(--danger);
}

.send-button {
  min-width: 60px;
  padding: 0 14px;
}

.sheet-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: rgb(5 15 18 / 42%);
  backdrop-filter: blur(2px);
}

.settings-sheet {
  position: fixed;
  z-index: 21;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  max-height: min(92dvh, 920px);
  grid-template-rows: auto 1fr auto;
  border-radius: 25px 25px 0 0;
  background: var(--surface);
  box-shadow: 0 -22px 70px rgb(8 23 27 / 25%);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 13px;
  border-bottom: 1px solid var(--hairline);
}

.sheet-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.035em;
}

.close-button {
  width: 44px;
  padding: 0;
  font-size: 27px;
}

.sheet-content {
  overflow-y: auto;
  padding: 3px 16px 24px;
}

.settings-section {
  padding: 21px 0;
  border-bottom: 1px solid var(--hairline);
}

.settings-section:last-child {
  border-bottom: 0;
}

.section-heading h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.section-heading p {
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.choice-grid,
.preset-grid {
  display: grid;
  gap: 8px;
}

.choice-grid.compact,
.preset-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-card,
.preset-grid button {
  display: flex;
  min-width: 0;
  min-height: 78px;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--paper);
  text-align: left;
}

.choice-card strong,
.preset-grid strong {
  font-size: 14px;
}

.choice-card span,
.preset-grid span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.42;
}

.choice-card small,
.preset-grid small {
  margin-top: 7px;
  color: var(--memory);
  font-size: 9px;
  line-height: 1.4;
}

.choice-card.selected,
.preset-grid button.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 11%, transparent);
}

.choice-card details {
  width: 100%;
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
}

.choice-card details p {
  margin: 5px 0 0;
  line-height: 1.5;
}

.segmented-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented-options button {
  min-height: 39px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--paper);
  font-size: 12px;
}

.segmented-options button.selected {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 13px;
  background: var(--paper);
}

.toggle-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--blue);
}

.toggle-row span {
  display: grid;
  gap: 3px;
}

.toggle-row strong {
  font-size: 13px;
}

.toggle-row small {
  color: var(--muted);
  font-size: 10px;
}

.icon-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.icon-options button {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 102px;
  padding: 9px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--paper);
  font-size: 10px;
}

.icon-options button.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.icon-preview {
  width: 54px;
  height: 54px;
  font-style: normal;
}

.sheet-footer {
  padding: 9px 16px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.sheet-footer .primary-button {
  width: 100%;
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (min-width: 760px) {
  .chat-view {
    width: min(760px, 100%);
    margin: 0 auto;
    border-right: 1px solid var(--hairline);
    border-left: 1px solid var(--hairline);
    background: var(--surface);
  }

  .messages {
    padding-right: 34px;
    padding-left: 34px;
  }

  .settings-sheet {
    right: max(16px, calc((100vw - 720px) / 2));
    left: max(16px, calc((100vw - 720px) / 2));
    border-radius: 25px 25px 0 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1517;
    --surface: #142024;
    --surface-soft: #1a292e;
    --ink: #eef4f2;
    --muted: #95a4a5;
    --hairline: #2a3a3d;
    --blue: #72a0ff;
    --blue-soft: #1b3152;
    --memory: #47cbb0;
    --memory-soft: #183f38;
    --warning: #e5a35a;
    --danger: #ff7b89;
    --shadow: 0 20px 55px rgb(0 0 0 / 28%);
  }
}

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

