:root {
  --ui-scale: 0.7;
  --bg: #f6f1ea;
  --bg-accent: #d4ebe3;
  --panel: rgba(255, 252, 247, 0.82);
  --panel-strong: rgba(255, 252, 247, 0.95);
  --line: rgba(35, 48, 58, 0.12);
  --line-strong: rgba(35, 48, 58, 0.2);
  --text: #1d2a33;
  --muted: #62727a;
  --accent: #0c7a69;
  --accent-soft: rgba(12, 122, 105, 0.12);
  --accent-strong: #0b6658;
  --user-bubble: #0c7a69;
  --assistant-bubble: rgba(255, 255, 255, 0.94);
  --thread-bg: rgba(244, 250, 248, 0.88);
  --thread-border: rgba(12, 122, 105, 0.22);
  --debate-accent: #8f2f54;
  --debate-accent-soft: rgba(143, 47, 84, 0.12);
  --debate-thread-bg: rgba(255, 245, 249, 0.92);
  --debate-thread-border: rgba(143, 47, 84, 0.22);
  --shadow: 0 18px 60px rgba(20, 30, 36, 0.12);
  --shadow-soft: 0 10px 32px rgba(20, 30, 36, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --motion-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-size: calc(16px * var(--ui-scale));
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 32%),
    radial-gradient(circle at top right, rgba(174, 223, 211, 0.9), transparent 28%),
    linear-gradient(155deg, var(--bg) 0%, #efe6db 50%, #e9f2ef 100%);
  overflow: hidden;
}

body.settings-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.motion-enter {
  --enter-delay: 0ms;
  animation-duration: 720ms;
  animation-delay: var(--enter-delay);
  animation-fill-mode: both;
  animation-timing-function: var(--motion-ease);
  will-change: opacity, transform, filter;
}

.motion-enter--hero {
  animation-name: motionHeroIn;
}

.motion-enter--panel {
  animation-name: motionPanelIn;
}

.motion-enter--rise {
  animation-name: motionRiseIn;
}

.motion-enter--soft {
  animation-name: motionSoftIn;
}

.motion-enter--pop {
  animation-name: motionPopIn;
}

.motion-exit {
  opacity: 0 !important;
  transform: translateY(-10px) scale(0.98);
  filter: blur(6px);
  pointer-events: none;
  transition:
    opacity 240ms ease,
    transform 280ms var(--motion-ease),
    filter 240ms ease;
}

.landing-page {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  padding: 24px;
  display: grid;
  overflow: hidden;
}

.landing-stage {
  min-height: 0;
  display: grid;
  align-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
}

.landing-enter-button {
  min-height: 52px;
  padding: 0 24px;
  font-size: 0.96rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  height: 100vh;
  padding: 20px;
  overflow: hidden;
  transition: grid-template-columns 220ms ease, gap 220ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
}

.sidebar,
.workspace {
  min-height: 0;
  height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(26px);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 20px 20px;
  transition:
    opacity 180ms ease,
    transform 220ms ease,
    padding 220ms ease;
}

.app-shell.sidebar-collapsed .sidebar {
  opacity: 0;
  transform: translateX(-18px);
  pointer-events: none;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  box-shadow: none;
}

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

.sidebar-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.eyebrow {
  margin: 2px 0 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sidebar h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.7rem;
  line-height: 1.08;
  font-weight: 600;
}

.brand-logo {
  display: block;
  width: min(100%, 230px);
  height: auto;
  object-fit: contain;
}

.sidebar-action,
.primary-button,
.ghost-button,
.thread-toggle,
.conversation-card {
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

.sidebar-action,
.primary-button {
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #163b52, #0c7a69);
  color: #f6fffc;
  box-shadow: 0 16px 30px rgba(12, 122, 105, 0.18);
}

.sidebar-action {
  padding: 14px 16px;
  font-weight: 700;
}

.sidebar-action:hover,
.primary-button:hover {
  box-shadow: 0 18px 34px rgba(12, 122, 105, 0.24);
}

.sidebar-action,
.primary-button {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.sidebar-action::before,
.primary-button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, #21516a 0%, #0f8a73 55%, #1aa285 100%);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: -1;
}

.sidebar-action:hover::before,
.primary-button:hover::before {
  transform: scaleX(1);
}

.ghost-button:hover,
.thread-toggle:hover {
  border-color: rgba(12, 122, 105, 0.26);
  background: rgba(236, 248, 244, 0.92);
  box-shadow: inset 0 0 0 1px rgba(12, 122, 105, 0.08);
}

.conversation-card:hover {
  border-color: rgba(12, 122, 105, 0.18);
  background: rgba(244, 250, 248, 0.9);
  box-shadow: inset 0 0 0 1px rgba(12, 122, 105, 0.05);
}

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

.conversation-card {
  position: relative;
  width: 100%;
  padding: 15px 52px 15px 16px;
  border: 1px solid transparent;
  border-radius: 18px;
  text-align: left;
  background: rgba(255, 255, 255, 0.55);
}

.conversation-card.active {
  border-color: rgba(12, 122, 105, 0.3);
  background: rgba(230, 247, 242, 0.96);
}

.conversation-delete {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(202, 56, 56, 0.1);
  color: #b63f3f;
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

.conversation-delete:hover {
  background: rgba(202, 56, 56, 0.16);
  color: #962f2f;
  box-shadow: inset 0 0 0 1px rgba(182, 63, 63, 0.08);
}

.conversation-delete-icon {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0;
  object-fit: contain;
  object-position: center;
  filter: invert(22%) sepia(50%) saturate(2267%) hue-rotate(336deg) brightness(91%) contrast(92%);
}

.conversation-title {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--text);
}

.conversation-preview {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  padding: 16px;
  position: relative;
}

.workspace-bar {
  display: none;
}

.workspace-eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.workspace-settings-button {
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  line-height: 0;
}

.sidebar-toggle-button {
  position: absolute;
  flex: 0 0 auto;
  right: 16px;
  top: 16px;
}

.sidebar-fab {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  box-shadow: var(--shadow-soft);
}

.button-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-icon-image {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  object-position: center;
  margin: 0;
  filter: invert(32%) sepia(68%) saturate(873%) hue-rotate(134deg) brightness(88%) contrast(93%);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-strong);
}

.control-group label,
.composer-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.secret-field {
  display: flex;
  gap: 10px;
}

.secret-field input,
.control-group select,
.composer textarea,
.thread-composer textarea,
.analysis-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  outline: none;
}

.secret-field input,
.control-group select {
  min-height: 48px;
  padding: 12px 20px 12px 14px;
}

.secret-field input:focus,
.control-group select:focus,
.composer textarea:focus,
.thread-composer textarea:focus,
.analysis-input:focus {
  border-color: rgba(12, 122, 105, 0.36);
  box-shadow: 0 0 0 4px rgba(12, 122, 105, 0.1);
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  padding: 0 16px;
}

.settings-page {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 24px;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 28, 34, 0.36);
  backdrop-filter: blur(10px);
}

.settings-panel {
  position: relative;
  z-index: 1;
  width: min(820px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  padding: 26px;
  border: 1px solid rgba(22, 59, 82, 0.12);
  border-radius: 32px;
  background:
    radial-gradient(circle at top right, rgba(12, 122, 105, 0.14), transparent 26%),
    linear-gradient(145deg, rgba(255, 252, 247, 0.98), rgba(246, 250, 248, 0.96));
  box-shadow: var(--shadow);
}

.settings-page:not(.hidden) .settings-backdrop {
  animation: overlayFadeIn 240ms ease both;
}

.settings-page:not(.hidden) .settings-panel {
  animation: modalPanelIn 420ms var(--motion-ease) both;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 22px;
}

.settings-header h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 2rem;
  line-height: 1;
}

.settings-intro,
.settings-note {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.favorites-panel {
  width: min(760px, 100%);
}

.analysis-panel {
  width: min(760px, 100%);
}

.analysis-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.analysis-input {
  min-height: 132px;
  max-height: 240px;
  resize: none;
  padding: 14px 16px;
}

.analysis-selection-preview {
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
  padding: 16px 18px;
  border: 1px solid rgba(154, 53, 53, 0.14);
  border-radius: 18px;
  background: rgba(154, 53, 53, 0.08);
  line-height: 1.65;
  white-space: pre-wrap;
}

.analysis-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.analysis-submit-button {
  min-width: 132px;
}

.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.favorites-empty {
  padding: 20px;
  border: 1px dashed rgba(12, 122, 105, 0.2);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  line-height: 1.6;
}

.favorite-card {
  padding: 18px 18px 16px;
  border: 1px solid rgba(22, 59, 82, 0.08);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.favorite-card-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.favorite-card-title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.15rem;
}

.favorite-card-meta {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.favorite-quote {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(244, 250, 248, 0.92);
  color: var(--text);
  line-height: 1.6;
}

.favorite-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(202, 56, 56, 0.1);
  color: #b63f3f;
}

.favorite-delete:hover,
.favorite-delete:focus-visible {
  background: rgba(202, 56, 56, 0.16);
  box-shadow: inset 0 0 0 1px rgba(182, 63, 63, 0.08);
  outline: none;
}

.favorite-delete-icon {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0;
  object-fit: contain;
  object-position: center;
  filter: invert(22%) sepia(50%) saturate(2267%) hue-rotate(336deg) brightness(91%) contrast(92%);
}

.chat-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  gap: 16px;
}

.chat-stage.is-empty {
  grid-template-rows: 1fr auto 1fr;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  padding: 0 8px;
}

.app-shell.sidebar-collapsed .chat-header {
  padding-left: 64px;
}

.chat-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.chat-status-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.chat-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-status-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chat-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid rgba(12, 122, 105, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #1d5047;
  font-size: 0.86rem;
  font-weight: 500;
}

.chat-title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 2rem;
  line-height: 1;
}

.chat-subtitle,
.chat-meta,
.empty-copy,
.message-meta,
.thread-summary,
.composer-note,
.typing-copy,
.landing-explanation {
  color: var(--muted);
}

.chat-view {
  min-height: 0;
  overflow-y: auto;
  padding: 10px 8px 10px 4px;
}

.chat-stage.is-empty .chat-view {
  display: block;
}

.message-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.landing-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  width: min(1080px, 100%);
  justify-self: center;
  padding: 30px;
  border: 1px solid rgba(12, 122, 105, 0.12);
  border-radius: 32px;
  background:
    radial-gradient(circle at top right, rgba(12, 122, 105, 0.14), transparent 28%),
    radial-gradient(circle at bottom left, rgba(22, 59, 82, 0.12), transparent 26%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(246, 250, 248, 0.9));
  box-shadow: var(--shadow-soft);
}

.landing-intro {
  max-width: 900px;
}

.landing-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.landing-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.landing-title-mark {
  flex: 0 0 auto;
  width: 248px;
  height: auto;
  display: block;
  object-fit: contain;
}

.landing-title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2.2rem, 4.5vw, 4.3rem);
  line-height: 0.98;
  max-width: none;
  white-space: nowrap;
}

.landing-definition {
  max-width: 820px;
  margin: 18px 0 10px;
  font-size: 1.04rem;
  line-height: 1.58;
}

.landing-explanation {
  max-width: 760px;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.56;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.landing-cta-panel {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: auto;
  padding: 16px 0 0;
  position: sticky;
  bottom: env(safe-area-inset-bottom, 0px);
  z-index: 1;
}

.landing-cta-panel .landing-enter-button {
  margin-left: auto;
}

.landing-card {
  min-height: 100%;
  padding: 18px;
  border: 1px solid rgba(22, 59, 82, 0.08);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
}

.landing-card-title {
  margin: 0 0 12px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.15rem;
}

.landing-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.5;
}

.landing-list li + li {
  margin-top: 8px;
}

.message {
  --message-bubble-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message.user {
  align-items: flex-end;
}

.message.assistant {
  align-items: flex-start;
}

.message-shell {
  width: min(var(--message-bubble-width), 100%);
  padding: 16px 18px;
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  transition: width 220ms ease;
}

.app-shell.sidebar-collapsed .message.assistant {
  --message-bubble-width: 1120px;
}

.message.user > .message-shell {
  background: var(--user-bubble);
  color: #f3fbff;
  border-top-right-radius: 8px;
}

.message.assistant > .message-shell {
  background: var(--assistant-bubble);
  border: 1px solid rgba(22, 59, 82, 0.08);
  border-top-left-radius: 8px;
}

.message-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.82rem;
  flex-wrap: wrap;
}

.message.user .message-meta {
  color: #f3fbff;
}

.message-role {
  font-weight: 700;
  color: inherit;
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.markdown-content {
  display: block;
}

.md-block {
  display: inline-block;
  width: 100%;
  vertical-align: top;
}

.md-heading {
  font-family: "Fraunces", Georgia, serif;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.md-heading-1 {
  font-size: 1.9rem;
}

.md-heading-2 {
  font-size: 1.6rem;
}

.md-heading-3 {
  font-size: 1.34rem;
}

.md-heading-4 {
  font-size: 1.14rem;
}

.md-heading-5,
.md-heading-6 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.md-paragraph {
  font-size: 1rem;
}

.md-list-item {
  position: relative;
  display: inline-block;
  width: 100%;
  padding-left: 1.35rem;
}

.md-list-item::before {
  content: attr(data-marker);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-weight: 700;
}

.md-list-item.is-compact-only {
  padding-left: 0;
}

.md-list-item.is-compact-only::before {
  content: none;
}

.md-list-item.is-compact-collapsed {
  display: none;
}

.md-blockquote {
  padding: 0.15rem 0 0.15rem 1rem;
  border-left: 3px solid rgba(12, 122, 105, 0.24);
  color: var(--muted);
}

.md-blockquote.is-compact-only {
  padding-left: 0;
  border-left: 0;
  color: inherit;
}

.md-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: rgba(35, 48, 58, 0.12);
}

.md-inline-code,
.md-code-block code {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.md-inline-code {
  padding: 0.12em 0.38em;
  border-radius: 0.45em;
  background: rgba(12, 122, 105, 0.1);
  color: #0b6658;
  font-size: 0.94em;
}

.md-code-block {
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(22, 59, 82, 0.08);
  background: rgba(240, 247, 245, 0.96);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.md-code-block code {
  display: block;
  white-space: pre-wrap;
  line-height: 1.55;
  color: #1d2a33;
}

.message-text a {
  color: var(--accent-strong);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

.message.user .message-text a {
  color: inherit;
}

.anchor-inline {
  display: inline;
}

.compact-inline-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.3rem;
  height: 1.45rem;
  margin: 0 0.2rem;
  padding: 0 0.55rem 0.08rem;
  border: 1px solid rgba(22, 59, 82, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 10px 22px rgba(20, 30, 36, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.18em;
  vertical-align: text-top;
}

.compact-inline-button:hover,
.compact-inline-button:focus-visible {
  border-color: rgba(12, 122, 105, 0.2);
  background: rgba(239, 247, 244, 0.96);
  color: var(--accent);
  box-shadow:
    0 12px 24px rgba(12, 122, 105, 0.12),
    inset 0 0 0 1px rgba(12, 122, 105, 0.08);
  outline: none;
}

.favorite-inline-anchor {
  background: rgba(140, 106, 55, 0.12);
  border-radius: 0.35em;
  box-decoration-break: clone;
}

.favorite-inline-indicator {
  display: inline-block;
  width: 0.82rem;
  height: 0.82rem;
  margin-left: 0.22rem;
  vertical-align: text-top;
  background: #8c6a37;
  opacity: 0.95;
  -webkit-mask-image: url("assets/bookmark.svg");
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-image: url("assets/bookmark.svg");
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.analysis-highlight {
  position: relative;
  padding: 0.06em 0.18em;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0)) padding-box,
    var(--analysis-fill, rgba(220, 42, 42, calc(0.08 + (var(--analysis-strength, 0.4) * 0.2))));
  box-shadow:
    inset 0 -0.08em 0 var(--analysis-edge, rgba(154, 32, 32, calc(0.12 + (var(--analysis-strength, 0.4) * 0.18)))),
    0 0 0 1px var(--analysis-outline, rgba(172, 36, 36, calc(0.18 + (var(--analysis-strength, 0.4) * 0.24)))),
    0 0.24em 0.68em var(--analysis-glow, rgba(172, 36, 36, calc(0.06 + (var(--analysis-strength, 0.4) * 0.16))));
  border-radius: 0.52em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.analysis-highlight--positive {
  --analysis-fill: rgba(220, 42, 42, calc(0.08 + (var(--analysis-strength, 0.4) * 0.2)));
  --analysis-edge: rgba(154, 32, 32, calc(0.12 + (var(--analysis-strength, 0.4) * 0.18)));
  --analysis-outline: rgba(172, 36, 36, calc(0.18 + (var(--analysis-strength, 0.4) * 0.24)));
  --analysis-glow: rgba(172, 36, 36, calc(0.06 + (var(--analysis-strength, 0.4) * 0.16)));
}

.analysis-highlight--negative {
  --analysis-fill: rgba(41, 168, 103, calc(0.08 + (var(--analysis-strength, 0.4) * 0.2)));
  --analysis-edge: rgba(30, 120, 75, calc(0.12 + (var(--analysis-strength, 0.4) * 0.18)));
  --analysis-outline: rgba(35, 142, 88, calc(0.18 + (var(--analysis-strength, 0.4) * 0.24)));
  --analysis-glow: rgba(35, 142, 88, calc(0.06 + (var(--analysis-strength, 0.4) * 0.16)));
}

.analysis-highlight--pending {
  background:
    linear-gradient(120deg, rgba(255, 254, 240, 0.9), rgba(255, 244, 186, 0.72)) padding-box,
    rgba(255, 239, 148, 0.96);
  box-shadow:
    inset 0 0 0 1px rgba(194, 157, 33, 0.34),
    0 0 0 1px rgba(214, 182, 52, 0.28),
    0 0.2em 0.72em rgba(214, 182, 52, 0.22);
  animation: analysisPendingPulse 1.8s ease-in-out infinite;
}

.analysis-inline-action,
.analysis-inline-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.65rem;
  margin-left: 0.38em;
  padding: 0 0.58em;
  border-radius: 999px;
  vertical-align: middle;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}

.analysis-inline-action {
  border: 1px solid rgba(196, 65, 65, 0.2);
  background: rgba(255, 244, 242, 0.98);
  color: #9a3535;
  box-shadow: 0 10px 20px rgba(196, 65, 65, 0.12);
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.analysis-inline-action:hover,
.analysis-inline-action:focus-visible {
  background: rgba(255, 236, 232, 1);
  border-color: rgba(196, 65, 65, 0.3);
  box-shadow: 0 12px 24px rgba(196, 65, 65, 0.18);
  transform: translateY(-1px);
  outline: none;
}

.analysis-inline-status {
  border: 1px solid rgba(194, 157, 33, 0.2);
  background: rgba(255, 251, 226, 0.96);
  color: #8b6a10;
  box-shadow: 0 10px 18px rgba(214, 182, 52, 0.14);
}

@keyframes analysisPendingPulse {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 1px rgba(194, 157, 33, 0.24),
      0 0 0 1px rgba(214, 182, 52, 0.22),
      0 0.2em 0.72em rgba(214, 182, 52, 0.16);
  }

  50% {
    box-shadow:
      inset 0 0 0 1px rgba(194, 157, 33, 0.38),
      0 0 0 2px rgba(214, 182, 52, 0.22),
      0 0.28em 0.96em rgba(214, 182, 52, 0.3);
  }
}

.anchor-highlight {
  padding: 0.08em 0.22em;
  border-radius: 0.45em;
  background: rgba(12, 122, 105, 0.16);
  color: inherit;
  box-decoration-break: clone;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    box-shadow 150ms ease;
}

.anchor-highlight:hover,
.anchor-highlight.is-open {
  background: rgba(12, 122, 105, 0.24);
}

.anchor-highlight--debate {
  background: rgba(143, 47, 84, 0.14);
}

.anchor-highlight--debate:hover,
.anchor-highlight--debate.is-open {
  background: rgba(143, 47, 84, 0.22);
}

.thread-inline-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  margin: 0 0.08em 0 0.35em;
  padding: 0;
  border: 1px solid rgba(12, 122, 105, 0.22);
  border-radius: 999px;
  vertical-align: text-top;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 22px rgba(12, 122, 105, 0.12);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.thread-inline-toggle--debate {
  border-color: rgba(143, 47, 84, 0.24);
  box-shadow: 0 10px 22px rgba(143, 47, 84, 0.12);
  color: var(--debate-accent);
}

.thread-card {
  border: 1px solid var(--thread-border);
  border-radius: 22px;
  background: var(--thread-bg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.thread-card--debate {
  border-color: var(--debate-thread-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 42%),
    var(--debate-thread-bg);
}

.inline-thread {
  display: block;
  margin: 16px 0 18px;
  transform-origin: top left;
}

.thread-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 16px 18px 0;
}

.thread-context {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thread-label {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.thread-label--debate {
  color: var(--debate-accent);
}

.thread-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.thread-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(202, 56, 56, 0.1);
  color: #b63f3f;
  box-shadow: none;
}

.thread-delete:hover,
.thread-delete:focus-visible {
  background: rgba(202, 56, 56, 0.16);
  box-shadow: inset 0 0 0 1px rgba(182, 63, 63, 0.08);
  outline: none;
}

.thread-delete-icon {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0;
  object-fit: contain;
  object-position: center;
  filter: invert(22%) sepia(50%) saturate(2267%) hue-rotate(336deg) brightness(91%) contrast(92%);
}

.thread-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 18px 18px;
  max-height: min(56vh, 760px);
  overflow-y: auto;
}

.thread-empty {
  padding: 18px;
  border: 1px dashed rgba(12, 122, 105, 0.2);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}

.thread-empty--debate {
  border-color: rgba(143, 47, 84, 0.22);
  background: rgba(255, 255, 255, 0.62);
}

.composer,
.thread-composer {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel-strong);
  box-shadow: var(--shadow-soft);
}

.composer,
.thread-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.composer {
  padding: 18px;
}

.composer-centered {
  width: min(860px, 100%);
  justify-self: center;
  align-self: center;
  margin-bottom: 10vh;
}

.thread-composer {
  padding: 14px;
}

.composer textarea,
.thread-composer textarea {
  min-height: 60px;
  max-height: 240px;
  resize: none;
  padding: 14px 16px;
}

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

.composer > .composer-actions {
  margin-top: 0;
  align-self: stretch;
}

.composer > .composer-actions .primary-button,
.thread-composer > .composer-actions .primary-button {
  min-height: 60px;
}

.thread-composer > .composer-actions {
  margin-top: 0;
  align-self: stretch;
}

@keyframes inlineThreadReveal {
  from {
    opacity: 0;
    transform: translateY(-10px) scaleY(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scaleY(1);
  }
}

@keyframes motionHeroIn {
  from {
    opacity: 0;
    transform: translateY(34px) scale(0.96);
    filter: blur(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes motionPanelIn {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.985);
    filter: blur(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes motionRiseIn {
  from {
    opacity: 0;
    transform: translateY(18px);
    filter: blur(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes motionSoftIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes motionPopIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.94);
    filter: blur(8px);
  }

  68% {
    opacity: 1;
    transform: translateY(-2px) scale(1.015);
    filter: blur(0);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modalPanelIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
    filter: blur(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.composer-note {
  margin: 0;
  line-height: 1.45;
}

.primary-button {
  padding: 12px 20px;
  font-weight: 700;
}

.primary-button:disabled,
.ghost-button:disabled,
.thread-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.cost-rate {
  font-weight: 700;
  line-height: 1.35;
}

.cost-detail {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(22, 59, 82, 0.08);
}

.typing-dots {
  display: inline-flex;
  gap: 6px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 1.1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.12s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.24s;
}

.selection-menu {
  position: fixed;
  z-index: 30;
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 6px 7px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 18px 48px rgba(20, 30, 36, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.76);
  transition:
    background-color 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.selection-action-button {
  --selection-accent: #4e6270;
  --selection-accent-soft: rgba(78, 98, 112, 0.12);
  --selection-accent-ring: rgba(78, 98, 112, 0.14);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--selection-accent);
  box-shadow: none;
  transition:
    background-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.selection-action-button:hover,
.selection-action-button:focus-visible {
  background: var(--selection-accent-soft);
  color: var(--selection-accent);
  box-shadow:
    0 8px 18px rgba(20, 30, 36, 0.08),
    inset 0 0 0 1px var(--selection-accent-ring);
  outline: none;
}

.selection-action-button--compact {
  --selection-accent: #b76334;
  --selection-accent-soft: rgba(183, 99, 52, 0.12);
  --selection-accent-ring: rgba(183, 99, 52, 0.16);
}

.selection-action-button--branch {
  --selection-accent: #0c7a69;
  --selection-accent-soft: rgba(12, 122, 105, 0.12);
  --selection-accent-ring: rgba(12, 122, 105, 0.16);
}

.selection-action-button--debate {
  --selection-accent: var(--debate-accent);
  --selection-accent-soft: rgba(143, 47, 84, 0.12);
  --selection-accent-ring: rgba(143, 47, 84, 0.16);
}

.selection-action-button--analyse {
  --selection-accent: #9a3535;
  --selection-accent-soft: rgba(154, 53, 53, 0.12);
  --selection-accent-ring: rgba(154, 53, 53, 0.16);
}

.selection-action-button--bookmark {
  --selection-accent: #8c6a37;
  --selection-accent-soft: rgba(140, 106, 55, 0.12);
  --selection-accent-ring: rgba(140, 106, 55, 0.16);
}

.selection-action-glyph {
  width: 13px;
  height: 13px;
  display: block;
  background: currentColor;
  opacity: 0.96;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.selection-action-glyph--compact {
  -webkit-mask-image: url("assets/compact.svg");
  mask-image: url("assets/compact.svg");
}

.selection-action-glyph--branch {
  -webkit-mask-image: url("assets/branch.svg");
  mask-image: url("assets/branch.svg");
}

.selection-action-glyph--debate {
  -webkit-mask-image: url("assets/debate.svg");
  mask-image: url("assets/debate.svg");
}

.selection-action-glyph--analyse {
  -webkit-mask-image: url("assets/analyse.svg");
  mask-image: url("assets/analyse.svg");
}

.selection-action-glyph--bookmark {
  -webkit-mask-image: url("assets/bookmark.svg");
  mask-image: url("assets/bookmark.svg");
}

.button-tooltip {
  position: fixed;
  z-index: 60;
  left: 0;
  top: 0;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 999px;
  background: rgba(27, 39, 47, 0.92);
  color: #f4fbff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 14px 28px rgba(20, 30, 36, 0.18);
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 14px 16px;
  border: 1px solid rgba(22, 59, 82, 0.12);
  border-radius: 18px;
  background: rgba(27, 39, 47, 0.94);
  color: #f4fbff;
  line-height: 1.45;
  box-shadow: var(--shadow-soft);
}

@keyframes pulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 30vh) minmax(0, 1fr);
  }

  .app-shell.sidebar-collapsed {
    grid-template-rows: minmax(0, 1fr);
  }

  .sidebar,
  .workspace {
    height: 100%;
  }

  .app-shell.sidebar-collapsed .chat-header {
    padding-left: 64px;
  }

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

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

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
    gap: 12px;
  }

  .landing-page {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .landing-stage {
    align-items: start;
  }

  .sidebar,
  .workspace {
    border-radius: 24px;
  }

  .sidebar {
    padding: 18px 16px;
  }

  .workspace {
    padding: 12px;
  }

  .sidebar-fab {
    top: 12px;
    left: 12px;
  }

  .workspace-bar,
  .settings-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-shell.sidebar-collapsed .chat-header {
    padding-left: 58px;
  }

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

  .settings-page {
    padding: 14px;
  }

  .settings-panel {
    padding: 20px;
    border-radius: 24px;
  }

  .landing-hero {
    padding: 22px;
    border-radius: 24px;
    width: 100%;
  }

  .landing-title {
    font-size: 2.4rem;
    white-space: normal;
    text-align: center;
  }

  .landing-title-row {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }

  .landing-title-mark {
    width: 224px;
    height: auto;
    margin: 0 auto;
  }

  .landing-cta-panel {
    justify-content: stretch;
    padding-top: 18px;
    padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
  }

  .landing-cta-panel .landing-enter-button {
    width: 100%;
    margin-left: 0;
  }

  .chat-header,
  .composer-actions {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .thread-composer {
    grid-template-columns: 1fr;
  }

  .composer > .composer-actions {
    width: 100%;
  }

  .thread-composer > .composer-actions {
    width: 100%;
  }

  .analysis-actions {
    flex-direction: column-reverse;
    width: 100%;
  }

  .composer > .composer-actions .primary-button,
  .thread-composer > .composer-actions .primary-button,
  .analysis-actions .ghost-button,
  .analysis-actions .primary-button {
    width: 100%;
  }

  .chat-status-top,
  .chat-status,
  .chat-status-chips {
    align-items: flex-start;
    justify-content: flex-start;
  }


  .chat-title {
    font-size: 1.6rem;
  }

  .thread-header {
    align-items: flex-start;
  }

  .thread-meta {
    justify-content: flex-start;
  }

  .selection-menu {
    max-width: calc(100vw - 24px);
    flex-wrap: wrap;
  }
}

@media (max-height: 810px) {
  .landing-hero {
    padding: 28px;
  }

  .landing-definition {
    margin-bottom: 0;
    line-height: 1.55;
  }

  .landing-explanation {
    display: none;
  }

  .landing-grid {
    margin-top: 20px;
  }

  .landing-cta-panel {
    padding-top: 16px;
  }
}

@media (max-height: 684px) {
  .landing-page {
    padding: 20px;
  }

  .landing-stage {
    align-items: stretch;
  }

  .landing-hero {
    padding: 24px;
  }

  .landing-grid {
    display: none;
  }

  .landing-definition {
    font-size: 1rem;
    line-height: 1.45;
  }
}
