@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,600&display=swap");

:root {
  --bg-base: #f5f2ed;
  --bg-soft: #efe9e1;
  --bg-card: #ffffff;
  --ink: #1f1c18;
  --ink-soft: #3f3a33;
  --ink-muted: #6f685f;
  --accent: #c46b3e;
  --accent-strong: #a4542d;
  --accent-contrast: #fff7ef;
  --accent-soft: rgba(196, 107, 62, 0.18);
  --line: rgba(31, 28, 24, 0.12);
  --line-strong: rgba(31, 28, 24, 0.2);
  --shadow-soft: 0 8px 20px rgba(20, 15, 10, 0.08);
  --shadow-lg: 0 24px 60px rgba(20, 15, 10, 0.12);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --transition-fast: 150ms ease;
  --transition-base: 220ms ease;
  --font-sans: "Space Grotesk", sans-serif;
  --font-serif: "Fraunces", serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg-base);
  min-height: 100vh;
  line-height: 1.6;
  overflow: hidden;
}

body.has-history-open,
body.has-settings-open {
  overflow: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 800px at 12% -20%, rgba(196, 107, 62, 0.22), transparent 60%),
    radial-gradient(900px 700px at 90% 10%, rgba(70, 115, 95, 0.16), transparent 55%),
    radial-gradient(1000px 700px at 50% 120%, rgba(196, 107, 62, 0.14), transparent 60%),
    var(--bg-base);
}

.backdrop::before,
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.32;
}

.backdrop::before {
  background-image:
    linear-gradient(135deg, rgba(31, 28, 24, 0.05) 0, rgba(31, 28, 24, 0.05) 1px, transparent 1px),
    linear-gradient(45deg, rgba(31, 28, 24, 0.03) 0, rgba(31, 28, 24, 0.03) 1px, transparent 1px);
  background-size: 120px 120px, 160px 160px;
}

.backdrop::after {
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35), transparent 45%);
  animation: floatGlow 18s ease-in-out infinite;
}

@keyframes floatGlow {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(2%, -2%);
  }
}

.app {
  min-height: 100vh;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: rgba(245, 242, 237, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-self: center;
}

.brand__mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f2c9a6 0%, #c46b3e 100%);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-soft);
}

.brand__mark svg {
  width: 26px;
  height: 26px;
  fill: var(--ink);
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand__title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand__subtitle {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  justify-self: end;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition-base);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.icon-btn--ghost {
  background: transparent;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--ink-muted);
  box-shadow: var(--shadow-soft);
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-muted);
}

.status[data-state="loading"] .status__dot {
  background: #d97746;
  animation: pulse 1.5s ease-in-out infinite;
}

.status[data-state="ready"] .status__dot {
  background: #2a8c6f;
  box-shadow: 0 0 10px rgba(42, 140, 111, 0.4);
}

.status[data-state="error"] .status__dot {
  background: #c9362a;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

.main {
  flex: 1;
  padding: 24px;
  display: flex;
  justify-content: center;
  min-height: 0;
  height: 100%;
}

.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: min(360px, 92vw);
  background: var(--bg-base);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  transition: transform var(--transition-base);
  z-index: 40;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-panel.is-open {
  transform: translateX(0);
}

.settings-panel__card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.settings-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}

.settings-panel__subtitle {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-top: 4px;
}

.settings-panel__close {
  display: inline-flex;
  padding: 6px;
}

.chat {
  width: min(960px, 100%);
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 16px;
  min-width: 0;
  height: 100%;
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 16px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: none;
}

.thread::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.thread__inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}


.title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 2vw + 1rem, 2.3rem);
  line-height: 1.2;
}

.subtitle {
  color: var(--ink-muted);
  max-width: 520px;
}

.eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-muted);
}

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.welcome {
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.welcome__icon {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  background: var(--bg-soft);
}

.welcome__icon svg {
  width: 36px;
  height: 36px;
  stroke: var(--accent);
}

.welcome__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
}

.welcome__description {
  color: var(--ink-muted);
  max-width: 420px;
}

.welcome__hints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.dock {
  padding: 12px 0 16px;
  background: rgba(245, 242, 237, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.dock__controls {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.dock__settings,
.dock__hints {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.dock__header {
  padding: 18px 20px 0;
}

.dock__subtitle {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-top: 4px;
}

.setting-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px 20px 20px;
}

.setting {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.setting__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.setting__label {
  font-size: 0.85rem;
}

.setting__value {
  font-weight: 600;
  color: var(--accent-strong);
}

.setting__slider {
  width: 100%;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: rgba(31, 28, 24, 0.12);
  border: 1px solid rgba(31, 28, 24, 0.08);
}

.setting__slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-card);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.setting__slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-card);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.setting__hint {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 20px 20px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-base);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

.composer {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer__count {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__input-wrapper {
  position: relative;
}

.field__label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.field__input {
  width: 100%;
  min-height: 72px;
  resize: none;
  padding: 10px 132px 44px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink);
  transition: border var(--transition-fast), box-shadow var(--transition-fast);
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer__actions {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.composer__meta {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-base);
  font-family: var(--font-sans);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.btn--icon svg {
  width: 18px;
  height: 18px;
}

.btn--circle {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

.btn--circle svg {
  width: 18px;
  height: 18px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: transparent;
  box-shadow: var(--shadow-soft);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.message {
  max-width: 78%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-soft);
  animation: fadeUp 0.35s ease;
}

.message--user {
  align-self: flex-end;
  background: var(--accent);
  border-color: rgba(196, 107, 62, 0.5);
  color: var(--accent-contrast);
}

.message--assistant {
  align-self: flex-start;
  width: min(78%, 560px);
}

.message__role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-muted);
}

.message--user .message__role {
  color: rgba(255, 247, 239, 0.8);
}

.message__text {
  font-size: 0.95rem;
  color: inherit;
  white-space: pre-wrap;
}

.message__status {
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message--user .message__status {
  color: rgba(255, 247, 239, 0.85);
}

.message__progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(31, 28, 24, 0.08);
  overflow: hidden;
}

.message__progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e4b08b, #c46b3e);
  transition: width 0.3s ease;
}

.message__meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  white-space: pre-wrap;
}

.message--user .message__meta {
  color: rgba(255, 247, 239, 0.8);
  text-align: right;
}

.audio-player {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-card);
  overflow: hidden;
}

.audio-player__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}

.audio-player__title {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.audio-player__download {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-card);
  transition: all var(--transition-fast);
}

.audio-player__download svg {
  width: 16px;
  height: 16px;
}

.audio-player__download:hover {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.audio-player__download:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.audio-player__controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.audio-player__play {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.audio-player__play:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.audio-player__play svg {
  width: 18px;
  height: 18px;
  fill: var(--ink);
}

.audio-player__play .icon-pause {
  display: none;
}

.audio-player__play.is-playing .icon-play {
  display: none;
}

.audio-player__play.is-playing .icon-pause {
  display: block;
}

.audio-player__waveform {
  flex: 1;
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.audio-player__bar {
  flex: 1;
  min-width: 1px;
  max-width: 5px;
  background: rgba(31, 28, 24, 0.14);
  border-radius: 2px;
  transition: background var(--transition-fast);
}

.audio-player__bar.is-played {
  background: var(--accent);
}

.audio-player__time {
  min-width: 40px;
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-align: right;
}

.audio-player audio {
  display: none;
}

.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 92vw);
  height: 100vh;
  background: var(--bg-base);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform var(--transition-base);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 20px 24px;
  z-index: 30;
  overflow-y: auto;
}

.history-panel.is-open {
  transform: translateX(0);
}

.history-panel__header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.history-panel__close {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-panel__close svg {
  width: 18px;
  height: 18px;
}
.history-panel__title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  margin-top: 6px;
}

.history-panel__subtitle {
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.history-panel__actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
}

.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 8, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  z-index: 20;
}

.history-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 8, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  z-index: 35;
  display: block;
}

.settings-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.history__list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.history__empty {
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-muted);
}

.history-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-soft);
  animation: fadeUp 0.35s ease;
}

.history-card__prompt {
  font-size: 0.95rem;
  color: var(--ink);
  white-space: pre-wrap;
}

.history-card__settings {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.history-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.history-card__title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .site-header {
    grid-template-columns: auto 1fr auto;
    padding: 14px 16px;
    gap: 12px;
  }

  .brand__subtitle {
    display: none;
  }

  .header__actions {
    gap: 10px;
  }

  .main {
    padding: 20px 16px;
  }

  .dock {
    padding: 10px 0 16px;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 12px 14px;
  }

  .brand__mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  .brand__title {
    font-size: 1.05rem;
  }

  .icon-btn {
    padding: 8px 10px;
  }

  .icon-btn span {
    display: none;
  }

  .status {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .status__text {
    display: inline-block;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .message {
    max-width: 100%;
  }

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

  .field__input {
    padding: 10px 110px 42px 12px;
  }

  .composer__actions {
    right: 10px;
    bottom: 8px;
  }

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

  .composer__actions {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
