:root {
  --bg: #ece9e2;
  --surface: #f7f4ee;
  --surface-strong: #fffdf9;
  --surface-soft: #f2ede5;
  --ink: #181816;
  --muted: #66645d;
  --line: #ddd5c8;
  --line-strong: #cfc4b4;
  --accent: #c96442;
  --accent-strong: #b24f30;
  --accent-soft: #f3dfd5;
  --sidebar: rgba(247, 244, 238, 0.98);
  --sidebar-line: rgba(207, 196, 180, 0.82);
  --sidebar-ink: #4f4a42;
  --radius: 28px;
  --shadow: 0 18px 40px rgba(24, 24, 22, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Inter", system-ui, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.86), transparent 28%),
    linear-gradient(180deg, #f2efe9 0%, var(--bg) 42%, #e8e4dc 100%);
  color: var(--ink);
}

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

button {
  border: none;
  border-radius: 18px;
  padding: 14px 22px;
  background: var(--accent);
  color: #faf9f5;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  box-shadow: 0 10px 24px rgba(201, 100, 66, 0.22);
}

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

button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

input,
select,
textarea {
  width: 100%;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #3898ec;
  box-shadow: 0 0 0 3px rgba(56, 152, 236, 0.14);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input[readonly],
textarea[readonly] {
  background: #f2eee6;
  color: var(--muted);
}

textarea[readonly] {
  resize: none;
}

h1,
h2 {
  margin: 0;
  font-family: "Noto Serif SC", Georgia, serif;
  font-weight: 500;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.8rem, 2.3vw, 2.4rem);
}

h2 {
  font-size: clamp(1.25rem, 1.7vw, 1.55rem);
}

label,
.muted,
.hint {
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

.hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.section-head {
  margin-bottom: 16px;
}

.app-shell {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
}

.left-rail {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-line);
}

.rail-spacer {
  flex: 1;
}

.rail-button {
  width: 34px;
  height: 34px;
  margin-top: auto;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.92);
  border: 1px solid rgba(207, 196, 180, 0.9);
  color: var(--sidebar-ink);
  box-shadow: 0 8px 18px rgba(24, 24, 22, 0.08);
  font-size: 17px;
  line-height: 1;
}

.rail-button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chat-shell {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px 28px 20px;
  overflow: hidden;
}

.chat-scroll-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.conversation-list {
  width: min(920px, 100%);
  height: 100%;
  margin: 0 auto;
  padding: 14px 0 24px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 18px;
  scroll-behavior: smooth;
}

.empty-conversation {
  width: min(100%, 560px);
  min-height: 160px;
  display: grid;
  place-items: center;
  justify-self: start;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 28px 28px 28px 12px;
  background: rgba(255, 253, 249, 0.92);
  color: var(--muted);
  box-shadow: var(--shadow);
  text-align: left;
}

.message-row {
  display: flex;
}

.message-row.role-assistant {
  justify-content: flex-start;
}

.message-row.role-user {
  justify-content: flex-end;
}

.message-bubble {
  width: min(100%, 720px);
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 253, 249, 0.96);
  box-shadow: var(--shadow);
}

.role-assistant .message-bubble {
  border-radius: 26px 26px 26px 12px;
}

.role-user .message-bubble {
  width: min(100%, 680px);
  gap: 8px;
  padding: 12px 16px;
  border-color: rgba(196, 93, 58, 0.26);
  border-radius: 26px 26px 12px 26px;
  background: linear-gradient(180deg, #eadfce 0%, #e6d7c5 100%);
}

.role-user .message-role {
  display: none;
}

.message-role,
.audio-status {
  font-size: 12px;
}

.message-role {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.72;
}

.message-actions {
  display: flex;
  justify-content: flex-start;
}

.message-audio {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(221, 213, 200, 0.9);
}

.user-audio {
  gap: 6px;
  padding-top: 0;
  border-top: none;
}

.message-audio audio {
  width: 100%;
}

.audio-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.audio-status {
  color: var(--muted);
}

.mini-button {
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: none;
}

.mini-button-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(201, 100, 66, 0.28);
}

.mini-button-secondary:not(:disabled):hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.mini-button:not(:disabled):hover {
  background: var(--accent-strong);
}

.composer-wrap {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

.composer-box {
  width: min(920px, 100%);
  display: grid;
  gap: 10px;
  padding: 14px 16px 12px;
  border: 1px solid rgba(217, 205, 188, 0.95);
  border-radius: 24px;
  background: rgba(252, 250, 246, 0.96);
  box-shadow: 0 18px 44px rgba(24, 24, 22, 0.08);
}

.composer-field {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
}

.composer-status {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.composer-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.composer-copy strong {
  font-size: 0.98rem;
  white-space: nowrap;
}

.composer-placeholder {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  padding-left: 2px;
}

.composer-meta {
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
}

.composer-range {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: nowrap;
  margin-left: auto;
}

.send-inline {
  white-space: nowrap;
}

.secondary-button {
  background: #efe7db;
  border: 1px solid #ddd2c1;
  color: var(--ink);
  box-shadow: none;
}

.secondary-button:hover {
  background: #e7dccd;
}

.mic-visual {
  position: relative;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  flex: 0 0 52px;
}

.mic-core {
  position: relative;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #d87a58, #bb5536);
  color: #fff7f2;
  box-shadow: 0 10px 24px rgba(201, 100, 66, 0.28);
  font-size: 20px;
}

.mic-pulse {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid rgba(201, 100, 66, 0.24);
  animation: pulseRing 2.2s ease-out infinite;
}

.pulse-b {
  animation-delay: 1.1s;
}

.settings-backdrop {
  position: fixed;
  inset: 0 0 0 42px;
  z-index: 18;
  background: rgba(12, 13, 12, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.settings-panel {
  position: fixed;
  inset: 0 auto 0 42px;
  z-index: 20;
  width: min(430px, calc(100vw - 42px));
  background: rgba(247, 244, 238, 0.98);
  border-right: 1px solid var(--line-strong);
  box-shadow: 18px 0 40px rgba(18, 18, 16, 0.12);
  transform: translateX(calc(-100% - 42px));
  transition: transform 0.22s ease;
  backdrop-filter: blur(12px);
}

.settings-panel-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.settings-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 24px 18px;
  border-bottom: 1px solid rgba(221, 213, 200, 0.85);
}

.settings-panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px 24px;
  display: grid;
  gap: 16px;
}

.settings-card {
  padding: 20px;
  border-radius: 24px;
  background: rgba(255, 253, 249, 0.9);
  border: 1px solid rgba(221, 213, 200, 0.9);
  box-shadow: 0 10px 30px rgba(24, 24, 22, 0.04);
}

.settings-copy .muted {
  margin: 0;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  flex: 0 0 auto;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  font-weight: 500;
}

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

.prompt-template-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.prompt-template-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.prompt-template-actions button:disabled {
  cursor: not-allowed;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  cursor: pointer;
}

.switch-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.switch-row input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: relative;
  width: 52px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  background: #e7e1d6;
  border: 1px solid #ddd4c6;
  box-shadow: inset 0 1px 2px rgba(20, 20, 19, 0.08);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.switch-track::after {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fffdf8;
  box-shadow: 0 4px 10px rgba(20, 20, 19, 0.14);
  transition: transform 0.2s ease;
}

.switch-row input:checked + .switch-track {
  background: linear-gradient(180deg, #d87a58, #bb5536);
  border-color: #b95635;
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.12);
}

.switch-row input:checked + .switch-track::after {
  transform: translateX(22px);
}

.switch-row input:focus-visible + .switch-track {
  box-shadow: 0 0 0 4px rgba(56, 152, 236, 0.16);
}

.switch-row input:disabled + .switch-track {
  opacity: 0.55;
  cursor: not-allowed;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

body[data-settings-open="true"] .settings-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body[data-settings-open="true"] .settings-panel {
  transform: translateX(0);
}

body[data-send-state="sending"] .composer-box {
  border-color: rgba(201, 100, 66, 0.55);
  box-shadow: 0 18px 44px rgba(201, 100, 66, 0.12);
}

body[data-send-state="sending"] .mic-core {
  background: linear-gradient(180deg, #d98b44, #c96a25);
}

@keyframes pulseRing {
  0% {
    transform: scale(0.82);
    opacity: 0.72;
  }

  70% {
    transform: scale(1.28);
    opacity: 0;
  }

  100% {
    transform: scale(1.28);
    opacity: 0;
  }
}

@media (max-width: 920px) {
  .chat-shell {
    padding: 18px 18px 16px;
  }

  .message-bubble,
  .role-user .message-bubble,
  .conversation-list,
  .composer-box {
    width: 100%;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .left-rail {
    padding: 10px 0 12px;
  }

  .settings-backdrop,
  .settings-panel {
    inset-inline-start: 40px;
  }

  .settings-panel {
    width: min(420px, calc(100vw - 40px));
  }

  .chat-shell {
    padding: 14px 12px 12px;
  }

  .composer-box {
    padding: 14px;
    border-radius: 20px;
  }

  .composer-field {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .composer-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-left: 0;
  }

  .composer-actions .send-inline {
    flex: 1 1 100%;
  }

  .composer-status {
    width: 100%;
  }

  .composer-copy {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .mic-visual {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .mic-core {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .conversation-list {
    padding-top: 8px;
  }
}
