@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

@font-face {
  font-family: "Intuitize Serif";
  src: url("./intuitize-serif.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f4f1e9;
  --surface: #fffdf7;
  --surface-subtle: #ebe7dc;
  --text: #17241e;
  --muted: #6d746c;
  --line: #ded8ca;
  --line-strong: #c9c1b0;
  --accent: #244f3e;
  --accent-soft: #e2eae4;
  --gold: #9d7b3d;
  --gold-soft: #eee4cf;
  --danger: #963d37;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 72% 18%, rgba(190, 158, 91, .1), transparent 30%),
    radial-gradient(circle at 28% 82%, rgba(36, 79, 62, .07), transparent 34%),
    var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#top-controls {
  position: fixed;
  inset: 0 0 auto;
  z-index: 120;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(244, 241, 233, .88);
  backdrop-filter: blur(18px) saturate(125%);
  border-bottom: 1px solid transparent;
  transition: opacity 160ms ease, transform 160ms ease;
}

.brand {
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.035em;
  color: #153729;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .7);
}

#top-controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.icon-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 140;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 7px;
  background: #292927;
  box-shadow: 0 4px 12px rgba(20, 20, 18, .18);
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity 110ms ease, transform 110ms ease, visibility 0s linear 110ms;
  visibility: hidden;
  white-space: nowrap;
}

.icon-btn:hover::after,
.icon-btn:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 450ms;
  visibility: visible;
}

.icon-btn:focus-visible::after { transition-delay: 100ms; }

.icon-btn img {
  width: 19px;
  height: 19px;
  display: block;
  opacity: .58;
  filter: grayscale(1);
  pointer-events: none;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
  display: block;
  opacity: .58;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.nav-label { display: none; }

.icon-btn:hover { background: var(--surface-subtle); }
.icon-btn.active {
  background: var(--accent-soft);
  border-color: #c8ded2;
}

body.overlay-open #top-controls {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

@media (min-width: 901px) {
  body { padding-left: 260px; }

  #top-controls {
    inset: 0 auto 0 0;
    width: 260px;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 18px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    background: linear-gradient(180deg, #eae5d9 0%, #e5e0d4 100%);
    box-shadow: inset -1px 0 rgba(255, 255, 255, .62);
  }

  .brand {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0 12px 8px;
  }

  #top-controls-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
  }

  .icon-btn {
    width: 100%;
    height: 44px;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 12px;
    border-radius: 11px;
  }

  .icon-btn::after { display: none; }
  .icon-btn img { flex: 0 0 auto; }
  #account-btn img { filter: invert(1) grayscale(1); opacity: .72; }
  .nav-label { display: inline; font-size: 14px; }

  body.overlay-open #top-controls {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

}

#app {
  width: min(768px, calc(100% - 32px));
  min-height: 0;
  height: 100%;
  margin: 0 auto;
  padding: 84px 0 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.eco-mission {
  width: min(768px, calc(100% - 32px));
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin: 0 auto 18px;
  padding: 16px 0;
  border-top: 1px solid var(--line-strong);
  color: inherit;
  text-decoration: none;
  transition: border-color 160ms ease, color 160ms ease;
}

.eco-mission > span {
  color: var(--accent);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.eco-mission p { max-width: 660px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.eco-mission i { color: var(--accent); font-size: 20px; font-style: normal; transition: transform 160ms ease; }
.eco-mission:hover { border-color: var(--accent); }
.eco-mission:hover p { color: var(--text); }
.eco-mission:hover i { transform: translateX(4px); }
body.overlay-open .eco-mission { visibility: hidden; }

.release-banner {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 149;
  width: min(620px, calc(100% - 32px));
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 16px 14px 20px;
  border: 1px solid rgba(157, 123, 61, .38);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 253, 247, .97), rgba(239, 233, 217, .95));
  box-shadow: 0 20px 55px rgba(28, 42, 34, .17), inset 0 1px rgba(255, 255, 255, .88);
  backdrop-filter: blur(18px) saturate(125%);
  transform: translateX(-50%);
  transition: opacity 180ms ease, transform 180ms ease;
}

.release-banner[hidden] { display: none; }
.release-banner-copy { display: grid; gap: 4px; min-width: 0; }
.release-banner-copy strong { color: #173b2d; font-family: "Intuitize Serif", Georgia, serif; font-size: 21px; font-weight: 400; letter-spacing: -.025em; }
.release-banner-copy span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.release-banner-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.release-banner-actions a,
.release-banner-actions button {
  min-width: 58px;
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: 500 12px/1 "DM Sans", system-ui, sans-serif;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, filter 140ms ease;
}
.release-banner-actions a { border-color: #234c3b; background: linear-gradient(180deg, #315f4d, #234c3b); color: #fffdf7; box-shadow: inset 0 1px rgba(255, 255, 255, .16), 0 4px 12px rgba(36, 79, 62, .18); }
.release-banner-actions a:hover { filter: brightness(.94); }
.release-banner-actions button:hover { background: var(--surface-subtle); }
body.overlay-open .release-banner { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }

.hero-copy { text-align: center; }

#main-model-picker {
  position: fixed;
  top: 72px;
  left: 20px;
  z-index: 110;
  transition: opacity 140ms ease, transform 140ms ease;
}

#main-model-picker label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#model-select {
  height: 40px;
  padding: 0 32px 0 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background-color: transparent;
  color: var(--text);
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: background 140ms ease, border-color 140ms ease;
}

#model-select:hover { background-color: var(--surface-subtle); }
#model-select:focus-visible { border-color: var(--line-strong); background-color: var(--surface); }

/* Firefox's native select renderer distorts some custom-font glyphs. */
@-moz-document url-prefix() {
  #model-select {
    appearance: none;
    -moz-appearance: none;
    line-height: 1;
    background-image:
      linear-gradient(45deg, transparent 50%, currentColor 50%),
      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position:
      calc(100% - 14px) 18px,
      calc(100% - 10px) 18px;
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
  }
}

body.overlay-open #main-model-picker {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.hero-copy h1 {
  margin: 14px 0 0;
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 400;
  color: #183a2d;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .75);
}

#model-badge {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}

#composer,
#overlay-composer {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

#input,
#overlay-input {
  width: 100%;
  height: 64px;
  min-height: 64px;
  max-height: 180px;
  padding: 18px 64px 17px 64px;
  border: 1px solid var(--line-strong);
  border-radius: 32px;
  background: rgba(255, 253, 247, .94);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  outline: none;
  overflow-y: hidden;
  resize: none;
  box-shadow: 0 12px 34px rgba(27, 43, 34, .09), inset 0 1px rgba(255, 255, 255, .9);
  backdrop-filter: blur(12px);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

#input::placeholder,
#overlay-input::placeholder { color: #888e87; }

#input:focus,
#overlay-input:focus {
  border-color: #789888;
  box-shadow: 0 0 0 3px rgba(36, 79, 62, .1), 0 16px 42px rgba(27, 43, 34, .12);
}

.send-btn {
  position: absolute;
  right: 10px;
  bottom: 11px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #315c4b;
  border-radius: 50%;
  background: linear-gradient(180deg, #3a6755, #28513f);
  color: #fffdf8;
  box-shadow: inset 0 1px rgba(255, 255, 255, .18), 0 4px 12px rgba(36, 79, 62, .18);
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.send-btn:hover { background: linear-gradient(180deg, #315f4d, #204735); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { opacity: .45; cursor: default; transform: none; }
.send-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.attach-btn {
  position: absolute;
  left: 10px;
  bottom: 11px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #d4cbb9;
  border-radius: 50%;
  background: linear-gradient(180deg, #f5f1e7, #e9e3d5);
  color: #365346;
  box-shadow: inset 0 1px rgba(255, 255, 255, .75);
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.attach-btn:hover { background: var(--gold-soft); border-color: #c6af7f; }
.attach-btn:active { transform: scale(.96); }
.attach-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

#overlay-composer .attach-btn { width: 36px; height: 36px; left: 9px; bottom: 9px; }
#overlay-composer .attach-btn svg { width: 19px; height: 19px; }
#overlay-input { padding-left: 54px; }
#overlay-input:focus { padding-left: 54px; }

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 8px;
}

.attachments[hidden] { display: none; }

#overlay-footer .attachments { margin: 8px 0 6px; }

.attach-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  max-width: 100%;
}

.attach-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 9px;
  flex: 0 0 auto;
}

.attach-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.attach-name {
  max-width: 180px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-status {
  font-size: 11.5px;
  color: var(--muted);
}

.attach-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.attach-detail,
.attach-remove {
  border: 1px solid #d8ded8;
  background: #e9ede8;
  color: #35483e;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  transition: background 140ms ease, transform 140ms ease;
}

.attach-detail { padding: 5px 10px; }
.attach-remove {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}
.attach-detail:hover,
.attach-remove:hover { background: #dde5de; }
.attach-detail:active,
.attach-remove:active { transform: scale(.96); }

#gen-status,
#pending {
  min-height: 20px;
  color: var(--muted) !important;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 12px !important;
  opacity: 0;
  transition: opacity 160ms ease;
}

#gen-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

#gen-status.visible { opacity: 1; }
#gen-status .gen-text { opacity: 0; transition: opacity 180ms ease; }
#gen-status .gen-text.visible { opacity: 1; }

.generation-face {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 50%;
  background: linear-gradient(145deg, #74bdff 0%, #1683f7 52%, #075dcc 100%) !important;
  box-shadow: 0 3px 12px rgba(7, 93, 204, .32), inset 0 1px rgba(255, 255, 255, .38);
}

.generation-eye {
  width: 4px;
  height: 6px;
  border-radius: 999px;
  background: #fff;
  transform-origin: center;
  animation: generation-blink 4.8s ease-in-out infinite;
}

.generation-eye:last-child { animation-delay: 35ms; }

@keyframes generation-blink {
  0%, 88%, 92%, 96%, 100% { transform: scaleY(1); }
  90%, 94% { transform: scaleY(.08); }
}

@media (prefers-reduced-motion: reduce) {
  .generation-eye { animation: none; }
}

/* Conversation */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at 78% 14%, rgba(190, 158, 91, .08), transparent 30%),
    var(--bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 0s linear 180ms;
}

#overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

#overlay-panel {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
}

#overlay-header {
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid transparent;
  border-bottom: 1px solid transparent;
  background: rgba(244, 241, 233, .82);
  backdrop-filter: blur(16px);
}

#close-overlay,
#close-history,
#close-sources,
#close-personalize {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

#close-overlay:hover,
#close-history:hover,
#close-sources:hover,
#close-personalize:hover { background: var(--surface-subtle); color: var(--text); }

#overlay-content {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0 auto;
  padding: 20px max(20px, calc((100% - 840px) / 2)) 10px;
  overflow: hidden;
  outline: none;
}

.messages {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 0 0 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.bubble.user {
  align-self: flex-end;
  max-width: min(72%, 620px);
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 16px 16px 5px 16px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.user .meta { display: none; }

.assistant-plain {
  align-self: flex-start;
  width: 100%;
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.assistant-plain .meta { display: none; }
.assistant-plain.is-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 13px;
}

.assistant-plain:not(.is-loading) > .generation-face { display: none; }
.assistant-content > :first-child { margin-top: 0; }
.assistant-content > :last-child { margin-bottom: 0; }
.assistant-content.plain-fallback { white-space: pre-wrap; }
.assistant-content p { margin: 0 0 1em; }
.assistant-content h1,
.assistant-content h2,
.assistant-content h3 { margin: 1.5em 0 .65em; line-height: 1.25; letter-spacing: -.02em; }
.assistant-content h1 { font-size: 24px; }
.assistant-content h2 { font-size: 20px; }
.assistant-content h3 { font-size: 17px; }
.assistant-content ul,
.assistant-content ol { margin: .75em 0 1em; padding-left: 1.4em; }
.assistant-content li { margin: .35em 0; }
.assistant-content a { color: var(--accent); text-underline-offset: 3px; }
.assistant-content blockquote { margin: 1em 0; padding-left: 16px; border-left: 2px solid var(--line-strong); color: var(--muted); }

.assistant-actions {
  display: flex;
  align-items: center;
  margin-top: 14px;
}

.sources-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease, color 130ms ease;
}

.sources-button:hover,
.sources-button:focus-visible {
  border-color: #c8d0c9;
  background: var(--surface-subtle);
  color: var(--text);
}

#overlay-footer {
  flex: 0 0 auto;
  padding: 10px max(20px, calc((100% - 840px) / 2)) max(12px, env(safe-area-inset-bottom));
  border-top: 0;
  background: linear-gradient(to bottom, rgba(247, 246, 242, 0), var(--bg) 18px);
}

#overlay-composer { max-width: 840px; margin: 0 auto; }
#overlay-attachments { max-width: 840px; margin: 0 auto; }
#overlay-input { height: 56px; min-height: 56px; padding-block: 15px 14px; border-radius: 28px; }
#overlay-composer .send-btn { width: 36px; height: 36px; right: 9px; bottom: 9px; }

#overlay-disclaimer {
  margin-top: 9px !important;
  padding: 0 !important;
  color: var(--muted) !important;
  font-size: 11px !important;
}

/* Code and generated content */
pre,
pre.code-block {
  position: relative;
  max-width: 100%;
  overflow: auto;
  margin: 1em 0;
  padding: 18px;
  border: 1px solid #2d3430;
  border-radius: 12px;
  background: #1e2421;
  color: #edf1ee;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
}

code,
code.inline-code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #e9ece7;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .88em;
}

pre code { padding: 0; background: transparent; }

.code-block .copy-btn {
  position: absolute;
  top: 9px;
  right: 9px;
  padding: 6px 8px;
  border: 1px solid #46504b;
  border-radius: 7px;
  background: #29302c;
  color: #d9dfdb;
  font-size: 11px;
  cursor: pointer;
}

.copy-flash {
  position: absolute;
  top: 10px;
  right: 70px;
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 11px;
  opacity: 0;
  transition: opacity 140ms ease;
}
.copy-flash.visible { opacity: 1; }

/* Intuitize Canvas */
.intuitize-canvas {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(27, 43, 34, .08), inset 0 1px rgba(255, 255, 255, .8);
}

.canvas-header {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 11px 9px 17px;
  border-bottom: 1px solid var(--line);
}

.canvas-title {
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: 17px;
  letter-spacing: -.015em;
}

.canvas-actions { display: flex; align-items: center; gap: 3px; }

.canvas-action,
.canvas-change-submit {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.canvas-action:hover { background: var(--surface-subtle); color: var(--text); }

.canvas-change-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
}

.canvas-change-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.canvas-body { padding: 18px; }
.canvas-body > :first-child { margin-top: 0; }
.canvas-body > :last-child { margin-bottom: 0; }

.intuitize-canvas pre,
.intuitize-canvas pre.code-block {
  margin: 0;
  border-color: var(--line);
  background: #f2f1ec;
  color: #30322d;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

.intuitize-canvas.canvas-code pre,
.intuitize-canvas.canvas-code pre.code-block { font-family: "DM Mono", ui-monospace, monospace; font-size: 13px; line-height: 1.6; }

.canvas-editor {
  width: calc(100% - 28px);
  min-height: 320px;
  display: block;
  margin: 14px;
  padding: 16px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #f8f7f3;
  color: var(--text);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  outline: none;
}

.canvas-editor:focus { border-color: #9eaea4; box-shadow: 0 0 0 3px rgba(73, 107, 89, .08); }

.canvas-change-form {
  display: flex;
  gap: 8px;
  padding: 11px;
  border-top: 1px solid var(--line);
  background: #faf9f5;
}

.canvas-change-form[hidden] { display: none; }

.canvas-change-input {
  min-width: 0;
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.canvas-change-input:focus { border-color: #9eaea4; }
.canvas-change-submit { min-height: 40px; border-color: var(--line-strong); background: var(--surface-subtle); color: var(--text); }
.canvas-change-submit:disabled { opacity: .55; cursor: wait; }

.intuitize-canvas > .copy-flash { top: 12px; right: 250px; }

/* Sources */
#sources-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 22, 19, .32);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 0s linear 160ms;
}

#sources-modal.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

#sources-panel {
  width: min(620px, 100%);
  max-height: min(720px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(22, 37, 29, .23), inset 0 1px rgba(255, 255, 255, .85);
  transform: translateY(10px) scale(.985);
  transition: transform 180ms ease;
}

#sources-modal.visible #sources-panel { transform: translateY(0) scale(1); }

#sources-header {
  flex: 0 0 auto;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.sources-heading h2 {
  margin: 0;
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: 25px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -.025em;
}

.sources-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

#sources-content {
  min-height: 120px;
  padding: 4px 22px 12px;
  overflow: auto;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.source-item {
  padding: 18px 2px 19px;
  border-bottom: 1px solid var(--line);
}

.source-item:last-child { border-bottom: 0; }
.source-name { color: #858b85; font-size: 11px; line-height: 1.3; }
.source-item h3 { margin: 5px 0 7px; color: var(--text); font-size: 15px; font-weight: 500; line-height: 1.4; }
.source-item p { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.source-link {
  display: block;
  overflow: hidden;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.4;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Personalization */
#personalize-modal {
  position: fixed;
  inset: 0;
  z-index: 410;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 22, 19, .32);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 0s linear 160ms;
}

#skills-modal {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 22, 19, .32);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 0s linear 160ms;
}

#skills-modal.visible { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }

#skills-panel {
  width: min(620px, 100%);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(22, 37, 29, .23), inset 0 1px rgba(255, 255, 255, .85);
  transform: translateY(10px) scale(.985);
  transition: transform 180ms ease;
}

#skills-modal.visible #skills-panel { transform: translateY(0) scale(1); }

#skills-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.skills-heading h2 { margin: 0; font-family: "Intuitize Serif", Georgia, serif; font-size: 25px; font-weight: 400; line-height: 1.05; letter-spacing: -.025em; }
.skills-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
#close-skills { padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
#close-skills:hover { background: var(--surface-subtle); color: var(--text); }

#skills-form { padding: 18px 22px 0; }
#skills-list { display: flex; flex-direction: column; gap: 12px; }
.skill-card { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.skill-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.skill-card-top input[type="text"] { flex: 1; min-width: 0; height: 40px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 14px; outline: none; }
.skill-enabled { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 400; }
.skill-remove { padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--danger); font-size: 12px; cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
.skill-fields { display: grid; gap: 11px; }
.skill-fields label { display: grid; gap: 6px; color: var(--text); font-size: 11px; font-weight: 500; }
.skill-fields input,
.skill-fields textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 400; line-height: 1.45; outline: none; resize: vertical; }
.skill-fields textarea { min-height: 92px; }
.skill-card input:focus,
.skill-card textarea:focus { border-color: #8daa9b; box-shadow: 0 0 0 3px rgba(23, 107, 77, .09); }
#add-skill { width: 100%; min-height: 40px; margin-top: 12px; border: 1px dashed var(--line-strong); border-radius: 10px; background: transparent; color: var(--accent); font-size: 13px; cursor: pointer; transition: background-color 140ms ease, border-color 140ms ease; }
#add-skill:hover { background: var(--accent-soft); }
#skills-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px -22px 0; padding: 15px 22px; border-top: 1px solid var(--line); }
#skills-footer span { color: var(--muted); font-size: 11px; }
#skills-footer button { min-height: 38px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: white; font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color 140ms ease, border-color 140ms ease, filter 140ms ease; }

#personalize-modal.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

#personalize-panel {
  width: min(480px, 100%);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(22, 37, 29, .23), inset 0 1px rgba(255, 255, 255, .85);
  transform: translateY(10px) scale(.985);
  transition: transform 180ms ease;
}

#personalize-modal.visible #personalize-panel { transform: translateY(0) scale(1); }

#personalize-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.personalize-heading h2 {
  margin: 0;
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: 25px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -.025em;
}

.personalize-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

#personalize-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 22px 0;
}

.personalize-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.personalize-field input,
.personalize-field select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  outline: none;
}

.personalize-field input:focus,
.personalize-field select:focus {
  border-color: #8daa9b;
  box-shadow: 0 0 0 3px rgba(23, 107, 77, .09);
}

.personalize-interests,
.onboarding-interests {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.personalize-interests legend,
.onboarding-interests legend { padding: 0; font-size: 12px; font-weight: 500; }
.personalize-interests > p { margin: 6px 0 12px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.interest-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.interest-options label { position: relative; cursor: pointer; }
.interest-options input { position: absolute; opacity: 0; pointer-events: none; }
.interest-options span {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.interest-options input:checked + span { border-color: #a7bdae; background: var(--accent-soft); color: var(--accent); }
.interest-options input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

#personalize-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 4px -22px 0;
  padding: 15px 22px;
  border-top: 1px solid var(--line);
}

#personalize-footer span { color: var(--muted); font-size: 11px; font-weight: 400; }
#personalize-footer button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
#personalize-footer button { transition: background-color 140ms ease, border-color 140ms ease, filter 140ms ease; }
#personalize-footer button:hover { filter: brightness(.96); }

/* First run */
#welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 22, 19, .48);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 0s linear 180ms;
}
#welcome-modal.visible { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
#welcome-panel {
  width: min(520px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 34px 110px rgba(20, 35, 27, .3), inset 0 1px rgba(255, 255, 255, .88);
  transform: translateY(12px) scale(.985);
  transition: transform 200ms ease;
}
#welcome-modal.visible #welcome-panel { transform: translateY(0) scale(1); }
.welcome-step { padding: 38px; }
.privacy-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 32px;
  border-radius: 14px;
  border: 1px solid rgba(157, 123, 61, .32);
  background: linear-gradient(145deg, #f3ead8, #e5d6b9);
  color: #765822;
  box-shadow: inset 0 1px rgba(255, 255, 255, .75), 0 8px 20px rgba(125, 94, 42, .1);
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: 23px;
}
.welcome-eyebrow { margin: 0 0 9px !important; color: var(--accent) !important; font-size: 11px !important; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.welcome-step h2 { margin: 0; font-family: "Intuitize Serif", Georgia, serif; font-size: clamp(30px, 7vw, 42px); font-weight: 400; line-height: 1.06; letter-spacing: -.035em; }
.welcome-step > p:not(.welcome-eyebrow) { max-width: 430px; margin: 14px 0 28px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.welcome-primary { min-height: 44px; padding: 0 19px; border: 1px solid #234c3b; border-radius: 11px; background: linear-gradient(180deg, #315f4d, #234c3b); color: #fffdf7; box-shadow: inset 0 1px rgba(255, 255, 255, .16), 0 5px 14px rgba(36, 79, 62, .16); font-weight: 500; cursor: pointer; transition: filter 140ms ease, opacity 140ms ease; }
#privacy-continue { width: 100%; }
#onboarding-form { display: flex; flex-direction: column; gap: 22px; }
.welcome-name { display: flex; flex-direction: column; gap: 7px; font-size: 12px; font-weight: 500; }
.welcome-name input,
#onboarding-gender,
#onboarding-other { width: 100%; height: 48px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); color: var(--text); outline: none; }
.welcome-name input:focus,
#onboarding-gender:focus,
#onboarding-other:focus { border-color: #8daa9b; box-shadow: 0 0 0 3px rgba(23, 107, 77, .09); }
.welcome-name small { color: var(--muted); font-size: 11px; font-weight: 400; }
.interest-options-large { display: grid; grid-template-columns: 1fr 1fr; margin: 11px 0 10px; }
.interest-options-large span { min-height: 46px; justify-content: center; border-radius: 12px; font-size: 13px; }
.welcome-local-note { margin: -4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.welcome-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; }
#onboarding-skip { min-height: 42px; padding: 0 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }

/* Account prompts */
.account-modal {
  position: fixed;
  inset: 0;
  z-index: 510;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 22, 19, .42);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 0s linear 160ms;
}
.account-modal.visible { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.account-panel {
  position: relative;
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(22, 37, 29, .23), inset 0 1px rgba(255, 255, 255, .85);
  transform: translateY(10px) scale(.985);
  transition: transform 180ms ease;
}
.account-modal.visible .account-panel { transform: translateY(0) scale(1); }
.account-panel h2 { max-width: 330px; margin: 10px 0 13px; font-family: "Intuitize Serif", Georgia, serif; font-size: clamp(30px, 7vw, 42px); font-weight: 400; line-height: 1.06; letter-spacing: -.035em; }
.account-copy { max-width: 340px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.account-close { position: absolute; top: 18px; right: 18px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
.account-close:hover { background: var(--surface-subtle); color: var(--text); }
.account-actions { display: flex; align-items: center; gap: 10px; margin-top: 28px; }
.account-secondary { min-height: 44px; padding: 0 17px; border: 1px solid var(--line-strong); border-radius: 11px; background: transparent; color: var(--text); font-weight: 500; cursor: pointer; transition: background-color 140ms ease, border-color 140ms ease; }
.account-secondary:hover { border-color: #9caf9f; background: var(--surface-subtle); }
.auth-panel .account-secondary { margin-top: 26px; }

/* History */
#history-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  background: rgba(18, 22, 19, .32);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 0s linear 160ms;
}

#history-modal.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

#history-panel {
  width: min(460px, calc(100% - 48px));
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--line-strong);
  border-radius: 0 22px 22px 0;
  background: var(--surface);
  box-shadow: 20px 0 64px rgba(22, 37, 29, .17), inset -1px 0 rgba(255, 255, 255, .7);
  transform: translateX(-22px);
  transition: transform 190ms ease;
}

#history-modal.visible #history-panel { transform: translateX(0); }

#history-header,
#history-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

#history-header { min-height: 86px; }
.history-heading h2 {
  margin: 0;
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: 27px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -.025em;
}
.history-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

#history-footer {
  justify-content: space-between;
  gap: 16px;
  border: 0;
  border-top: 1px solid var(--line);
  padding-block: 14px;
}

#history-storage-note { color: var(--muted); font-size: 11px; }

#history-content {
  flex: 1 1 auto;
  min-height: 160px;
  padding: 20px 14px 28px;
  overflow: auto;
  color: var(--muted);
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.history-group + .history-group { margin-top: 24px; }
.history-group-title {
  margin: 0 10px 8px;
  color: #888e87;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.history-list { display: flex; flex-direction: column; gap: 3px; }

.history-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
  padding: 13px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease;
}

.history-row:hover,
.history-row:focus-visible { background: var(--surface-subtle); border-color: var(--line); }
.history-row-main { min-width: 0; }
.history-row-title {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-row-preview {
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.history-row-time { color: #8b908a; font-size: 11px; white-space: nowrap; }
.history-row-count { color: #969b95; font-size: 10px; white-space: nowrap; }

.history-empty {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 44px 28px;
  text-align: center;
}
.history-empty-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin-bottom: 17px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--accent);
  font-family: "Intuitize Serif", Georgia, serif;
  font-size: 22px;
}
.history-empty-icon {
  width: 42px;
  height: 42px;
  margin-bottom: 17px;
  opacity: .72;
}
.history-empty h3 { margin: 0; color: var(--text); font-size: 15px; font-weight: 500; }
.history-empty p { max-width: 260px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

#history-clear {
  padding: 8px 11px;
  border: 1px solid #e0c8c5;
  border-radius: 9px;
  background: transparent;
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
}
#history-clear:hover { background: #fbf1f0; }
#history-clear.armed { border-color: var(--danger); background: var(--danger); color: white; }
#history-clear:disabled { opacity: .45; cursor: default; }

/* Incognito and settings */
#incognito-banner {
  position: fixed;
  top: 82px;
  left: 50%;
  z-index: 310;
  transform: translateX(-50%);
  pointer-events: none;
}

#incognito-banner-inner {
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--text);
  color: white;
  font-size: 12px;
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 160ms ease, transform 160ms ease;
}

#incognito-banner.show #incognito-banner-inner { opacity: 1; transform: none; }

body.incognito-on:not(.overlay-open) #input {
  background: #222825;
  color: #f3f5f2;
  border-color: #222825;
}
body.incognito-on:not(.overlay-open) #input::placeholder { color: #a8aea9; }

#settings-dropdown {
  position: fixed !important;
  min-width: 164px !important;
  padding: 6px !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: 12px !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: 0 12px 32px rgba(17, 25, 20, .12) !important;
}

#settings-dropdown button {
  padding: 9px 10px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: var(--text);
  font-size: 13px;
  transition: background-color 140ms ease, color 140ms ease !important;
}
#settings-dropdown button:hover { background: var(--surface-subtle) !important; }

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 80;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(17, 25, 20, .1);
}
.suggestion-item { padding: 10px 11px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.suggestion-item:hover { background: var(--surface-subtle); }
.suggestion-item small { display: block; margin-top: 3px; color: var(--muted); }

@media (max-width: 640px) {
  #top-controls { height: 56px; padding: 0 12px; }
  .brand { font-size: 21px; }
  .icon-btn { width: 38px; height: 38px; }
  #main-model-picker { top: 62px; left: 8px; }

  #app {
    width: min(100% - 24px, 768px);
    min-height: 0;
    padding: 70px 0 24px;
    gap: 22px;
  }
  .eco-mission { width: calc(100% - 24px); grid-template-columns: 1fr auto; gap: 8px 16px; margin-bottom: 10px; padding-inline: 0; }
  .eco-mission p { grid-column: 1 / -1; grid-row: 2; }
  .eco-mission i { grid-column: 2; grid-row: 1; }
  .hero-copy h1 { margin-top: 15px; font-size: 34px; }
  #input { height: 58px; min-height: 58px; padding-block: 16px 15px; }

  #overlay-header { flex-basis: 56px; padding: 0 12px; }
  #overlay-content { padding: 14px 14px 6px; }
  .messages { gap: 22px; padding-bottom: 14px; }
  .bubble.user { max-width: 88%; }
  .assistant-plain { font-size: 15px; line-height: 1.65; }
  #overlay-footer { padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
  #overlay-disclaimer { display: none !important; }

  .canvas-header { align-items: flex-start; flex-direction: column; gap: 7px; padding: 13px; }
  .canvas-actions { width: 100%; }
  .canvas-action { flex: 1; }
  .canvas-change-button { justify-content: center; }
  .canvas-body { padding: 12px; }
  .canvas-change-form { flex-direction: column; }
  .canvas-change-submit { width: 100%; }
  .canvas-editor { width: calc(100% - 20px); min-height: 260px; margin: 10px; }

  #history-panel { width: 100%; border: 0; border-radius: 0; box-shadow: none; }
  #history-header { min-height: 78px; padding: 18px; }
  #history-footer { padding-inline: 18px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  #history-content { padding-inline: 8px; }
  #personalize-modal, #skills-modal, #welcome-modal { padding: 12px; }
  .account-modal { padding: 12px; }
  .account-panel { padding: 28px 22px; }
  #skills-form { padding-inline: 14px; }
  #skills-footer { margin-inline: -14px; padding-inline: 14px; }
  .welcome-step { padding: 28px 22px; }
  .privacy-mark { margin-bottom: 24px; }
  .release-banner { bottom: calc(env(safe-area-inset-bottom) + 82px); gap: 14px; padding: 13px 13px 13px 16px; }
  .release-banner-copy strong { font-size: 18px; }
  .release-banner-actions { gap: 6px; }
  .release-banner-actions a,
  .release-banner-actions button { min-width: 52px; padding-inline: 10px; }
}

.mobile-mode #app { min-height: 0; }
.mobile-mode #overlay-panel { min-height: 100dvh; }

@media (min-width: 901px) {
  #overlay { left: 260px; }
  #incognito-banner { left: calc(50% + 130px); }
  #main-model-picker { top: 14px; left: 278px; }

  .eco-mission {
    position: fixed;
    left: 14px;
    bottom: 14px;
    z-index: 121;
    width: 232px;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    margin: 0;
    padding: 14px 12px 10px;
  }

  .eco-mission p {
    grid-column: 1 / -1;
    font-size: 11px;
    line-height: 1.45;
  }

  .eco-mission i { grid-column: 2; grid-row: 1; }
  body.overlay-open .eco-mission { visibility: visible; }
}

/* Mobile: floating chat button */
#chat-fab { display: none; }

@media (max-width: 900px) {
  /* Attachments are desktop-only; on phones hide the plus button, the file
     inputs, and any chips, and give the inputs back their original padding. */
  .attach-btn,
  #file-input,
  #overlay-file-input,
  #attachments,
  #overlay-attachments {
    display: none !important;
  }

  #input,
  #overlay-input,
  #overlay-input:focus { padding-left: 20px; }

  /* Floating chat button in the corner */
  #chat-fab {
    position: fixed;
    right: 16px;
    bottom: calc(env(safe-area-inset-bottom) + 16px);
    z-index: 150;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 10px 26px rgba(17, 25, 20, .24);
    transition: transform 160ms ease, opacity 160ms ease, background 140ms ease;
  }

  #chat-fab:hover { background: #3d5d4c; }
  #chat-fab:active { transform: scale(.94); }

  #chat-fab svg {
    width: 24px;
    height: 24px;
    opacity: 1;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  body.overlay-open #chat-fab {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
  }

  /* Keep the mission link clear of the floating button */
  .eco-mission { margin-bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
