:root {
  color-scheme: light;
  --page: #edf0f3;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --line: #c9ced5;
  --line-strong: #adb5bf;
  --text: #27313b;
  --muted: #707b86;
  --cyan: #276b80;
  --green: #267342;
  --blue: #285b91;
  --yellow: #946d00;
  --red: #a13c45;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, 100%);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px;
  position: relative;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(35, 45, 55, .05);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 17px;
  color: var(--text);
  overflow: hidden;
}
.header-left { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-tools { display: flex; align-items: center; gap: 12px; margin-left: 12px; }
.header span, #elapsed, .timestamp, .connection { color: var(--muted); }
.memory-indicator {
  display: inline-block;
  width: 24px;
  text-align: center;
  font-size: 17px;
}
.memory-indicator[hidden], .timer-indicator[hidden] { display: none; }
.memory-indicator.blinking { animation: memory-blink .55s ease-in-out 3; }
.timer-indicator {
  min-width: 34px;
  height: 32px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--cyan);
  cursor: pointer;
  font: 16px/1 ui-sans-serif, system-ui, sans-serif;
  white-space: nowrap;
}
.timer-indicator:hover {
  background: var(--cyan);
  border-color: var(--cyan);
  color: white;
}
@keyframes memory-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .25; transform: scale(1.18); }
}
.thinking { color: var(--yellow) !important; font-weight: 600; }
#elapsed { white-space: nowrap; margin-left: 12px; }

.chat {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 24px;
  background: #fcfcfd;
  scrollbar-color: var(--line-strong) transparent;
}
.empty { color: var(--muted); padding: 4px 2px; }
.message {
  max-width: 1000px;
  margin: 0 0 18px;
  overflow-wrap: anywhere;
}
.message-head { margin-bottom: 4px; }
.message.user .role { color: var(--green); }
.message.assistant .role { color: var(--blue); }
.message.system .role { color: var(--muted); }
.role { font-weight: 700; }
.timestamp { margin-left: 9px; font-size: .88em; }
.message-body {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: normal;
}
.message-body .important, .message-body .highlight { color: var(--red); font-weight: 700; }
.message-body .tip { color: var(--green); font-weight: 700; }
.message-body .note { color: var(--blue); font-weight: 700; }
.message-body .warning { color: var(--yellow); font-weight: 700; }
.message-body .inline-code, .code-block code { color: #7b5700; }
.code-block {
  border: 1px solid var(--line);
  border-radius: 5px;
  margin: 9px 0;
  padding: 8px 11px;
  overflow-x: auto;
  background: #f1f3f5;
}
.code-title { color: var(--muted); margin-bottom: 4px; font-family: inherit; }
.code-block code { white-space: pre; }
.generated-image {
  width: fit-content;
  max-width: min(100%, 900px);
  margin: 12px 0 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}
.generated-image img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  border-radius: 3px;
}
.generated-image figcaption {
  margin-top: 5px;
  color: var(--muted);
  font: 11px/1.3 ui-sans-serif, system-ui, sans-serif;
}

.composer {
  position: relative;
  padding: 28px 98px 11px 13px;
  background: var(--panel-soft);
}
.composer label {
  position: absolute;
  left: 12px;
  top: 0;
  transform: translateY(-50%);
  background: var(--panel-soft);
  padding: 0 7px;
  color: var(--cyan);
  font-weight: 600;
}
#input {
  display: block;
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 130px;
  resize: none;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transition: border-color .15s, box-shadow .15s;
}
#input::placeholder { color: #9aa3ac; }
#input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(39, 107, 128, .13);
}
.notification-toggle, .voice-toggle, .voice-button, .send {
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--cyan);
  cursor: pointer;
}
.notification-toggle, .voice-toggle {
  width: 34px;
  height: 32px;
  padding: 0;
  font: 18px/1 ui-sans-serif, system-ui, sans-serif;
  white-space: nowrap;
}
.notification-toggle[aria-pressed="true"], .voice-toggle[aria-pressed="true"] {
  background: #e1edf1;
  border-color: var(--cyan);
  color: #1f596b;
}
.notification-toggle:disabled, .voice-toggle:disabled, .voice-button:disabled { cursor: not-allowed; opacity: .5; }
.voice-button, .send {
  position: absolute;
  bottom: 14px;
  width: 32px;
  height: 32px;
  font: 17px/1 ui-sans-serif, system-ui, sans-serif;
}
.voice-button { right: 54px; }
.voice-button.listening {
  background: #f8e5e7;
  border-color: var(--red);
  color: var(--red);
}
.send {
  right: 14px;
  bottom: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--cyan);
  font: 18px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}
.notification-toggle:hover, .voice-button:hover, .send:hover, .voice-toggle:hover {
  background: var(--cyan);
  border-color: var(--cyan);
  color: white;
}
.voice-status {
  position: absolute;
  left: 15px;
  bottom: 5px;
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
}
.voice-status.error { color: var(--red); }
.memory-toast {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 20;
  transform: translateX(-50%);
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  box-shadow: 0 4px 14px rgba(35, 45, 55, .16);
  color: var(--muted);
  font-size: 12px;
}
.memory-toast[hidden] { display: none; }
.connection { position: fixed; right: 18px; bottom: 5px; font-size: 11px; }
.connection.connected { color: var(--green); }
.connection.error { color: var(--red); }

.palette {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 160px;
  z-index: 5;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(35, 45, 55, .14);
  padding: 5px;
}
.palette button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.palette button.selected, .palette button:hover { background: #e1edf1; color: #1f596b; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  /* Keep chat and other page content private while a modal is open. */
  background: var(--page);
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(520px, 100%);
  max-height: min(560px, 90vh);
  overflow: auto;
  padding: 22px;
  border-color: var(--line-strong);
  box-shadow: 0 14px 40px rgba(35, 45, 55, .2);
}
.modal h2 { margin: 0 0 15px; font-size: 16px; color: var(--text); font-weight: 650; }
.modal p { color: var(--muted); margin: 0 0 12px; }
.timer-list { display: grid; gap: 9px; }
.timer-item {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-soft);
}
.timer-item-time { color: var(--cyan); font-size: .9em; font-weight: 650; }
.timer-item-prompt {
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.timer-item-id { margin-top: 4px; color: var(--muted); font-size: .78em; }
.modal button, .modal input {
  display: block;
  width: 100%;
  padding: 9px;
  margin: 7px 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
.modal button { cursor: pointer; text-align: left; }
.modal button:hover, .modal button.active { border-color: var(--cyan); color: var(--cyan); background: #f1f7f8; }
.modal .actions { display: flex; gap: 8px; margin-top: 14px; }
.modal .actions button { text-align: center; }
.passkey-actions { margin-top: 16px; padding-top: 9px; border-top: 1px solid var(--line); }
.passkey-actions button { text-align: center; }
.passkey-actions button:first-child { color: var(--cyan); font-weight: 650; }
.modal button:disabled { cursor: wait; opacity: .6; }
.modal .error { color: var(--red); min-height: 1.4em; }

@media (max-width: 600px) {
  .shell {
    height: 100vh;
    height: 100dvh;
    padding: 8px;
    gap: 8px;
    grid-template-rows: 54px minmax(0, 1fr) auto;
  }
  .chat { padding: 13px 12px 18px; }
  .header-tools { gap: 7px; }
  .voice-toggle { padding: 5px 7px; }
  .memory-toast { top: 10px; max-width: calc(100vw - 24px); }
  .composer { padding: 28px 98px 10px 11px; }
  .palette { left: 8px; right: 8px; }
}
