:root {
  --forest-900: #15271d;
  --forest-800: #1d3829;
  --forest-700: #234734;
  --forest-600: #2d5c45;
  --forest-500: #3c7257;
  --sage-100: #edf3ee;
  --ink-900: #1e241f;
  --ink-700: #4e5a51;
  --ink-500: #718076;
  --white: #ffffff;
  --shadow-lg: 0 24px 60px rgba(21, 39, 29, 0.16);
  --shadow-md: 0 16px 34px rgba(21, 39, 29, 0.1);
  --shadow-sm: 0 8px 18px rgba(21, 39, 29, 0.08);
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body.assistant-body {
  font-family: var(--font-body);
  color: var(--ink-900);
  background:
    radial-gradient(circle at top left, rgba(213, 140, 69, 0.22), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(45, 92, 69, 0.18), transparent 30rem),
    linear-gradient(180deg, #f5f1e7 0%, #edf3ee 52%, #e9f0ea 100%);
}

button,
textarea,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.assistant-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.assistant-sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 20px;
  background: linear-gradient(180deg, rgba(22, 39, 29, 0.98), rgba(29, 56, 41, 0.98));
  color: rgba(255, 255, 255, 0.92);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.sidebar-logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand-label {
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.sidebar-brand-subtitle {
  margin-top: 4px;
  font-size: 1.1rem;
  font-weight: 700;
}

.sidebar-close {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  font-size: 1.5rem;
  line-height: 1;
}

.sidebar-primary,
.topbar-button,
.composer-send {
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.sidebar-primary {
  width: 100%;
  background: linear-gradient(135deg, #f2e2bf, #d89951);
  color: var(--forest-900);
  box-shadow: 0 10px 20px rgba(213, 140, 69, 0.22);
}

.sidebar-primary:hover,
.topbar-button:hover,
.composer-send:hover {
  transform: translateY(-1px);
}

.sidebar-section {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-section-label,
.sidebar-footer-label {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.52);
}

.session-list {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.session-item {
  width: 100%;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  text-align: left;
}

.session-item.active {
  background: rgba(245, 241, 231, 0.16);
  border-color: rgba(240, 228, 211, 0.34);
}

.session-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.session-preview {
  margin-top: 6px;
  font-size: 0.84rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.62);
}

.sidebar-footer {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user-meta {
  margin-top: 8px;
  font-size: 0.84rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.78);
}

.assistant-main {
  position: relative;
  min-width: 0;
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px;
  overflow: hidden;
}

.assistant-topbar,
.assistant-banner,
.composer-panel,
.conversation-stage {
  position: relative;
  z-index: 1;
}

.assistant-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 28px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.topbar-intro {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

.eyebrow,
.banner-kicker,
.empty-kicker,
.favorites-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--forest-500);
}

.assistant-title {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 0.96;
  color: var(--forest-900);
}

.assistant-subtitle {
  margin: 12px 0 0;
  max-width: 760px;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-700);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-link {
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(45, 92, 69, 0.08);
  color: var(--forest-700);
  font-weight: 600;
}

.topbar-button {
  background: var(--forest-700);
  color: var(--white);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(45, 92, 69, 0.08);
  font-weight: 700;
}

.menu-toggle {
  display: none;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: rgba(45, 92, 69, 0.08);
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  border-radius: 999px;
  background: var(--forest-700);
}

.assistant-banner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(245, 241, 231, 0.95), rgba(226, 236, 228, 0.9));
  border: 1px solid rgba(39, 69, 53, 0.1);
  box-shadow: var(--shadow-sm);
}

.assistant-banner h2 {
  margin: 10px 0 0;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  line-height: 1.35;
}

.banner-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.banner-point,
.starter-chip,
.suggestion-chip,
.score-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.9rem;
}

.banner-point {
  padding: 10px 14px;
  background: rgba(45, 92, 69, 0.08);
  color: var(--forest-700);
  font-weight: 700;
}

.conversation-stage {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 12px;
}

.empty-card {
  width: min(840px, 100%);
  padding: clamp(24px, 4vw, 44px);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(29, 56, 41, 0.97), rgba(44, 88, 66, 0.94));
  color: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-md);
}

.empty-card h2 {
  margin: 10px 0 0;
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  line-height: 1.28;
}

.empty-card p {
  margin: 14px 0 0;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.68);
}

.starter-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.starter-chip {
  width: 100%;
  padding: 16px 18px;
  justify-content: flex-start;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-list {
  min-height: 0;
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 6px 6px 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.message-list-bottom {
  width: 100%;
  min-height: 1px;
  flex: 0 0 1px;
}

.message-card {
  width: min(900px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-card.user {
  align-self: flex-end;
}

.message-card.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 18px 20px;
  border-radius: 22px;
  line-height: 1.75;
  box-shadow: var(--shadow-sm);
}

.message-bubble.streaming {
  position: relative;
}

.message-card.user .message-bubble {
  background: linear-gradient(135deg, #20422f, #36644b);
  color: var(--white);
  border-top-right-radius: 10px;
}

.message-card.assistant .message-bubble {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-900);
  border: 1px solid rgba(21, 39, 29, 0.08);
  border-top-left-radius: 10px;
}

.reasoning-panel {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(45, 92, 69, 0.08);
  border: 1px solid rgba(45, 92, 69, 0.12);
  box-shadow: var(--shadow-sm);
}

.reasoning-panel.streaming {
  border-style: dashed;
}

.reasoning-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reasoning-label {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--forest-700);
  font-weight: 800;
}

.reasoning-status {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--forest-600);
}

.reasoning-body {
  margin-top: 10px;
  color: var(--ink-700);
  line-height: 1.75;
  font-size: 0.94rem;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.route-card {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(247, 242, 232, 0.98), rgba(255, 255, 255, 0.96));
  border: 1px solid rgba(45, 92, 69, 0.1);
  box-shadow: var(--shadow-sm);
}

.route-title {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--forest-900);
}

.route-meta {
  margin-top: 8px;
  font-size: 0.86rem;
  color: var(--ink-500);
}

.route-highlight {
  margin-top: 10px;
  min-height: 3.5em;
  font-size: 0.94rem;
  line-height: 1.7;
  color: var(--ink-700);
}

.route-score {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.score-chip {
  padding: 8px 12px;
  background: rgba(45, 92, 69, 0.08);
  color: var(--forest-700);
  font-size: 0.8rem;
  font-weight: 700;
}

.route-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.route-action {
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--forest-700);
  color: var(--white);
  font-size: 0.88rem;
  font-weight: 700;
}

.route-action.secondary {
  background: rgba(45, 92, 69, 0.08);
  color: var(--forest-700);
}

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.suggestion-chip {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--forest-700);
  border: 1px solid rgba(45, 92, 69, 0.08);
  box-shadow: var(--shadow-sm);
}

.composer-panel {
  position: sticky;
  bottom: 0;
  z-index: 6;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(233, 240, 234, 0) 0%, rgba(233, 240, 234, 0.82) 18%, rgba(233, 240, 234, 0.96) 100%);
}

.composer-shell {
  padding: 14px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
}

.composer-input {
  width: 100%;
  min-height: 58px;
  max-height: 180px;
  padding: 12px 6px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-900);
  line-height: 1.7;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.composer-hint {
  font-size: 0.88rem;
  color: var(--ink-500);
}

.thinking-toggle {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(45, 92, 69, 0.08);
  color: var(--forest-700);
  font-size: 0.88rem;
  font-weight: 800;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.thinking-toggle.active {
  background: linear-gradient(135deg, rgba(29, 56, 41, 0.98), rgba(44, 88, 66, 0.94));
  color: var(--white);
}

.thinking-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.composer-send {
  background: linear-gradient(135deg, #214130, #37654c);
  color: var(--white);
}

.composer-send:disabled,
.sidebar-primary:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

.favorites-panel {
  position: fixed;
  top: 26px;
  right: 26px;
  bottom: 26px;
  width: min(380px, calc(100vw - 32px));
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.favorites-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.favorites-head h2 {
  margin: 6px 0 0;
  font-size: 1.5rem;
}

.favorites-close {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(45, 92, 69, 0.08);
  color: var(--forest-700);
  font-size: 1.5rem;
  line-height: 1;
}

.favorites-desc {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--ink-700);
}

.favorites-list {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.favorite-item {
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(45, 92, 69, 0.08);
  background: linear-gradient(180deg, rgba(247, 242, 232, 0.92), rgba(255, 255, 255, 0.94));
  text-align: left;
}

.favorite-item-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.favorite-title {
  font-weight: 800;
  color: var(--forest-900);
}

.favorite-meta {
  margin-top: 6px;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink-500);
}

.favorite-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.favorite-action {
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(45, 92, 69, 0.08);
  color: var(--forest-700);
  font-size: 0.84rem;
  font-weight: 800;
}

.favorite-action.danger,
.route-action.danger {
  background: rgba(168, 52, 52, 0.1);
  color: #9d2f2f;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(21, 39, 29, 0.92);
  color: var(--white);
  box-shadow: var(--shadow-md);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 960px) {
  .assistant-shell {
    grid-template-columns: 1fr;
  }

  .assistant-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }

  .assistant-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close,
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(18, 32, 24, 0.36);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .assistant-topbar,
  .assistant-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .assistant-banner {
    display: none;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .favorites-panel {
    top: 16px;
    right: 16px;
    left: 16px;
    bottom: 16px;
    width: auto;
  }
}

@media (max-width: 640px) {
  .assistant-main {
    padding: 12px;
    gap: 12px;
  }

  .assistant-topbar,
  .conversation-stage,
  .composer-shell {
    padding: 16px;
  }

  .assistant-topbar {
    gap: 12px;
  }

  .assistant-banner {
    display: none;
  }

  .composer-panel {
    margin: 0 -12px;
    padding: 8px 12px calc(max(8px, env(safe-area-inset-bottom, 0px)) + 4px);
  }

  .assistant-title {
    margin-top: 0;
    font-size: 1.12rem;
    line-height: 1.2;
  }

  .eyebrow,
  .assistant-subtitle,
  .topbar-link,
  .composer-hint {
    display: none;
  }

  .topbar-intro {
    align-items: center;
  }

  .topbar-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-button,
  .topbar-link,
  .status-pill {
    padding: 8px 10px;
    font-size: 0.88rem;
  }

  .conversation-stage {
    min-height: 260px;
    gap: 12px;
    padding-bottom: 8px;
  }

  .message-list {
    padding: 0 2px 8px;
  }

  .empty-card {
    padding: 20px 18px;
  }

  .empty-card h2 {
    font-size: 1.2rem;
  }

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

  .suggestion-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 2px 2px;
    -webkit-overflow-scrolling: touch;
  }

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

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-tools {
    align-items: stretch;
  }

  .composer-send {
    width: 100%;
  }

  .favorite-actions {
    flex-direction: column;
  }
}
