/* ── Welcome screen ──────────────────────────────────────── */
.welcome {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.welcome-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--line-strong) 0.8px, transparent 0.8px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, #000 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, #000 0%, transparent 75%);
  opacity: 0.55;
}
.welcome-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 16px 32px;
}
@media (min-width: 640px) {
  .welcome-inner {
    padding: 40px 24px 12vh;
  }
}
.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 28px;
}
@media (min-width: 640px) {
  .welcome-hero {
    margin-bottom: 36px;
  }
}
.welcome-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 24px;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  color: var(--ink);
}
.welcome-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
@media (min-width: 640px) {
  .welcome-title {
    font-size: 50px;
  }
}
.welcome-title em {
  color: var(--ink-2);
}
.welcome-title .dot {
  color: var(--accent);
}
.welcome-sub {
  margin-top: 12px;
  font-size: 15px;
  color: var(--ink-2);
}
.suggestions {
  display: flex;
  gap: 8px;
  margin: 20px -16px 0;
  padding: 0 16px 4px;
  overflow-x: auto;
}
@media (min-width: 640px) {
  .suggestions {
    flex-wrap: wrap;
    justify-content: center;
    margin: 20px 0 0;
    padding: 0;
    overflow: visible;
  }
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  flex-shrink: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow-hairline);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: background-color 0.15s, color 0.15s;
}
.chip svg {
  color: var(--ink-3);
}
.chip:hover {
  background: var(--surface);
  color: var(--ink);
}
.connect-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 10px 10px 14px;
  border-radius: var(--r-lg);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.45;
}
.connect-banner .grow {
  flex: 1;
}

/* ── Thread ──────────────────────────────────────────────── */
.thread {
  position: relative;
  flex: 1;
  min-height: 0;
}
.thread-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.thread-inner {
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
  max-width: var(--thread-w);
  margin: 0 auto;
  padding: 24px 16px 40px;
}
@media (min-width: 640px) {
  .thread-inner {
    padding: 40px 24px 40px;
  }
}
.jump-btn {
  position: absolute;
  left: 50%;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-pop);
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.jump-btn.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
.jump-btn:hover {
  color: var(--ink);
}
.loading-lines {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: var(--thread-w);
  margin: 0 auto;
  padding: 40px 24px;
}
.loading-lines div {
  height: 16px;
  border-radius: 6px;
}

/* ── Messages ────────────────────────────────────────────── */
.msg-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.bubble {
  max-width: min(85%, 640px);
  padding: 10px 16px;
  border-radius: 18px 18px 6px 18px;
  background: var(--raised);
  box-shadow: var(--shadow-hairline);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-meta {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.15s;
}
.msg-meta .time {
  margin: 0 6px;
}
.msg-meta .stopped {
  color: var(--warn);
}
.msg-meta .model {
  margin-left: 4px;
  max-width: 220px;
}
@media (hover: hover) {
  .msg-user .msg-meta,
  .msg-assistant:not(.is-last) .msg-meta {
    opacity: 0;
  }
  .msg-user:hover .msg-meta,
  .msg-assistant:hover .msg-meta,
  .msg-meta:focus-within {
    opacity: 1;
  }
}
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}
.msg-attachments img {
  max-height: 224px;
  max-width: min(100%, 280px);
  border-radius: var(--r-lg);
  object-fit: cover;
  box-shadow: var(--shadow-hairline);
  cursor: zoom-in;
}
.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-hairline);
  text-align: left;
}
.file-chip .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
}
.file-chip .fname {
  display: block;
  font-size: 13px;
  font-weight: 500;
}
.file-chip .fsize {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}
.msg-assistant {
  display: flex;
  gap: 16px;
}
.msg-avatar {
  display: none;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-hairline);
  color: var(--ink);
}
@media (min-width: 768px) {
  .msg-avatar {
    display: inline-flex;
  }
}
.msg-body {
  flex: 1;
  min-width: 0;
}
.phase {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-size: 14px;
  color: var(--ink-2);
}
.phase .globe {
  color: var(--accent);
  animation: mg-pulse 1.4s ease-in-out infinite;
}
.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: mg-pulse-dot 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) {
  animation-delay: 0.16s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.32s;
}
.image-placeholder {
  width: min(100%, 440px);
  aspect-ratio: 1;
  margin-top: 12px;
  border-radius: var(--r-xl);
}
.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.45;
}
.notice svg {
  flex-shrink: 0;
  margin-top: 1px;
}
.error-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 8px;
  padding: 10px 12px 10px 14px;
  border-radius: var(--r-lg);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.45;
}
.error-card .grow {
  flex: 1;
  min-width: 180px;
}
.reasoning {
  margin-bottom: 12px;
}
.reasoning-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
}
.reasoning-toggle:hover {
  color: var(--ink-2);
}
.reasoning-toggle .chev {
  transition: transform 0.2s var(--ease);
}
.reasoning-toggle[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}
.reasoning-text {
  max-height: 288px;
  overflow-y: auto;
  margin-top: 4px;
  padding-left: 14px;
  border-left: 2px solid var(--line);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-3);
  white-space: pre-wrap;
  animation: mg-fade-in 0.3s ease both;
}
.sources {
  margin-top: 16px;
}
.sources h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sources ol {
  list-style: none;
  display: grid;
  gap: 6px;
}
@media (min-width: 640px) {
  .sources ol {
    grid-template-columns: 1fr 1fr;
  }
}
.source {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  height: 100%;
  padding: 8px 10px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-hairline);
  text-decoration: none;
  transition: background-color 0.15s;
}
.source:hover {
  background: var(--hover);
}
.source .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex-shrink: 0;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.source .s-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}
.source .s-host {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}
.memory-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-hairline);
  animation: mg-fade-up 0.5s var(--ease) both;
}
.memory-card .mc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}
.memory-card .mc-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.memory-card .mc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.gen-image {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin-top: 4px;
  animation: mg-fade-up 0.5s var(--ease) both;
}
.gen-image img {
  width: min(100%, 440px);
  border-radius: var(--r-xl);
  background: var(--raised);
  box-shadow: var(--shadow-hairline);
}
.gen-image .dl {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  box-shadow: var(--shadow-float);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
}
@media (hover: hover) {
  .gen-image .dl {
    opacity: 0;
    transition: opacity 0.15s;
  }
  .gen-image:hover .dl {
    opacity: 1;
  }
}

/* ── Composer ────────────────────────────────────────────── */
.composer {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-composer);
  transition: box-shadow 0.2s;
}
.composer.is-hero {
  border-radius: var(--r-2xl);
}
.composer:focus-within {
  box-shadow: 0 0 0 1px var(--line-strong), 0 12px 32px -16px rgb(0 0 0 / 0.2);
}
.composer.is-dragging {
  box-shadow: 0 0 0 2px var(--accent);
}
.drop-hint {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
}
.composer.is-dragging .drop-hint {
  display: flex;
}
.composer-atts {
  display: flex;
  gap: 8px;
  padding: 12px 12px 0;
  overflow-x: auto;
}
.composer-atts:empty {
  display: none;
}
.att {
  position: relative;
  flex-shrink: 0;
}
.att img {
  width: 64px;
  height: 64px;
  border-radius: var(--r-lg);
  object-fit: cover;
  box-shadow: var(--shadow-hairline);
}
.att .att-file {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 176px;
  height: 64px;
  padding: 0 12px;
  border-radius: var(--r-lg);
  background: var(--canvas);
  box-shadow: var(--shadow-hairline);
  font-size: 12.5px;
  font-weight: 500;
}
.att .att-file .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
}
.att .att-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--canvas);
  box-shadow: var(--shadow-float);
}
.att .att-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--ink-2);
}
.composer-input {
  display: block;
  width: 100%;
  min-height: 52px;
  max-height: 220px;
  padding: 14px 16px 0;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 16px; /* 16px prevents iOS zoom on focus */
  line-height: 1.55;
  color: var(--ink);
  overflow-y: hidden;
}
@media (min-width: 640px) {
  .composer-input {
    font-size: 15.5px;
  }
}
.composer.is-hero .composer-input {
  min-height: 64px;
  max-height: 260px;
  padding-top: 16px;
  font-size: 16px;
}
.composer-input::placeholder {
  color: var(--ink-3);
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 8px;
}
.composer-bar .right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 6px 0 8px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.mode-btn:hover,
.mode-btn[aria-expanded="true"] {
  background: var(--hover);
  color: var(--ink);
}
.mode-btn .chev {
  color: var(--ink-3);
  transition: transform 0.2s;
}
.mode-btn[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}
.image-mode-label {
  margin-left: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
}
.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-3);
  transition: background-color 0.15s, color 0.15s, opacity 0.15s;
}
.send-btn.is-ready {
  background: var(--accent);
  color: var(--accent-ink);
}
.send-btn.is-ready:hover {
  background: var(--accent-hover);
}
.send-btn.is-stop {
  background: var(--ink);
  color: var(--canvas);
}
.send-btn.is-stop:hover {
  opacity: 0.85;
}
.composer-note {
  margin-top: 8px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
}
@media (max-width: 639.98px) {
  .composer-note {
    display: none;
  }
}

/* ── Lightbox ────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(0 0 0 / 0.8);
  cursor: zoom-out;
  animation: mg-fade-in 0.2s ease both;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-lg);
}
