:root {
  --ink: #171b16;
  --paper: #f2efe6;
  --card: #fbf9f2;
  --acid: #d8ff45;
  --coral: #ff7557;
  --muted: #73786d;
  --line: rgba(23, 27, 22, .14);
  --shadow: 0 1.5rem 4rem rgba(26, 32, 22, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 20rem; background: var(--ink); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(216,255,69,.26), transparent 28rem),
    linear-gradient(135deg, #e9e4d8 0%, var(--paper) 52%, #e4e9dc 100%);
  font: 1rem/1.5 Manrope, sans-serif;
}

button, input, textarea { font: inherit; }
button { min-width: 2.75rem; min-height: 2.75rem; cursor: pointer; }
.shell { width: min(100%, 96rem); min-height: 100dvh; margin: auto; padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--ink); color: var(--acid); font: 500 1.2rem DM Mono, monospace; transform: rotate(-8deg); }
.brand strong { display: block; font-size: .95rem; letter-spacing: .14em; line-height: 1.1; }
.brand small { color: var(--muted); font-size: .76rem; }
.connection { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.44); font-size: .78rem; }
.connection span { width: .55rem; height: .55rem; border-radius: 50%; background: #6b7465; box-shadow: 0 0 0 .25rem rgba(107,116,101,.12); }
.connection.live span { background: #54b454; box-shadow: 0 0 0 .25rem rgba(84,180,84,.15); }
.connection.busy span { background: var(--coral); animation: pulse 1s infinite; }
.header-actions { display: flex; align-items: center; gap: .45rem; }
.settings-button { min-height: 2.75rem; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.44); color: var(--ink); font: 500 .72rem DM Mono, monospace; }

.workspace { display: grid; gap: 1rem; }
.browser-card, .chat-card { border: 1px solid var(--line); border-radius: 1.25rem; background: rgba(251,249,242,.92); box-shadow: var(--shadow); overflow: hidden; }
.chat-card { order: 1; }
.browser-card { order: 2; }
.browser-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem; }
.eyebrow { margin: 0 0 .25rem; color: var(--muted); font: 500 .7rem/1 DM Mono, monospace; letter-spacing: .15em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; max-width: 16ch; font-size: clamp(1.4rem, 6vw, 2.75rem); line-height: 1; letter-spacing: -.05em; }
h2 { margin-bottom: .5rem; font-size: clamp(1.25rem, 4vw, 1.8rem); line-height: 1.08; letter-spacing: -.035em; }
.ghost, .text-button { border: 0; background: transparent; color: var(--muted); }
.ghost { padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.browser-stage { position: relative; min-height: 21rem; margin: 0 .75rem; border-radius: 1rem; overflow: hidden; background: #20251e; }
.browser-stage.collapsed { display: none; }
.browser-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 2rem; color: #f8f6ef; text-align: center; background: radial-gradient(circle at 50% 45%, #343d2f 0%, #20251e 55%, #171b16 100%); }
.browser-empty p { max-width: 30ch; color: #aeb5a8; }
.orbit { position: relative; display: grid; place-items: center; width: 5.5rem; height: 5.5rem; margin-bottom: 1.1rem; border: 1px solid rgba(216,255,69,.42); border-radius: 50%; }
.orbit::before, .orbit::after { content: ''; position: absolute; border: 1px solid rgba(216,255,69,.18); border-radius: 50%; }
.orbit::before { inset: .65rem; }
.orbit::after { inset: 1.35rem; }
.orbit i { width: .8rem; height: .8rem; border-radius: 50%; background: var(--acid); box-shadow: 0 0 1.4rem var(--acid); animation: orbit 3s linear infinite; }
.primary { border: 0; border-radius: .85rem; padding: .75rem 1rem; background: var(--acid); color: var(--ink); font-weight: 800; box-shadow: 0 .5rem 1.5rem rgba(216,255,69,.15); }
.primary:disabled { opacity: .55; cursor: wait; }
.primary.danger { background: var(--coral); color: white; }
#live-browser { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: white; }
.session-strip { display: flex; align-items: center; justify-content: space-between; min-height: 3rem; padding: .4rem 1rem; color: var(--muted); font: .76rem DM Mono, monospace; }
.session-actions { display: flex; align-items: center; gap: .75rem; }
.text-button { min-height: 2.75rem; text-decoration: underline; text-underline-offset: .2rem; }

.chat-card { display: flex; min-height: 30rem; max-height: 34rem; flex-direction: column; }
.chat-heading { padding: 1rem 1rem .5rem; }
.quick-actions { display: flex; gap: .5rem; padding: 0 1rem .75rem; overflow-x: auto; scrollbar-width: none; }
.quick-actions::-webkit-scrollbar { display: none; }
.quick-actions button { flex: 0 0 auto; max-width: 14rem; padding: .65rem .85rem; border: 1px solid var(--line); border-radius: .75rem; background: white; color: var(--ink); text-align: left; font-size: .82rem; }
.messages { flex: 1; min-height: 12rem; overflow-y: auto; padding: .75rem 1rem 1rem; scroll-behavior: smooth; }
.message { display: flex; align-items: flex-start; gap: .65rem; margin: 0 0 .9rem; animation: rise .25s ease-out; }
.message > span { display: grid; flex: 0 0 2rem; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--ink); color: var(--acid); font: .68rem DM Mono, monospace; }
.message p { max-width: 85%; margin: 0; padding: .75rem .9rem; border-radius: .2rem 1rem 1rem 1rem; background: #ece9de; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { flex-direction: row-reverse; }
.message.user > span { background: var(--acid); color: var(--ink); }
.message.user p { border-radius: 1rem .2rem 1rem 1rem; background: var(--ink); color: white; }
.message.error p { background: #ffe0d8; color: #7e2615; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: .55rem; padding: .75rem; border-top: 1px solid var(--line); background: var(--card); }
.composer label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.composer textarea { width: 100%; min-height: 3.25rem; max-height: 8rem; resize: none; border: 1px solid var(--line); border-radius: .9rem; padding: .8rem; background: white; color: var(--ink); font-size: 1rem; outline: none; }
.composer textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 .2rem rgba(23,27,22,.08); }
.composer button { align-self: end; width: 3.25rem; height: 3.25rem; border: 0; border-radius: .9rem; background: var(--ink); color: var(--acid); }
.composer svg { width: 1.4rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }

.modal { width: min(calc(100% - 2rem), 29rem); border: 1px solid var(--line); border-radius: 1.2rem; padding: 0; background: var(--card); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(18,22,17,.68); backdrop-filter: blur(.35rem); }
.modal form { padding: 1.35rem; }
.modal p { color: var(--muted); }
.modal input { width: 100%; min-height: 3rem; margin: .5rem 0 .75rem; border: 1px solid var(--line); border-radius: .75rem; padding: .75rem; font-size: 1rem; }
.cookies-modal { width: min(calc(100% - 2rem), 38rem); }
.cookies-modal textarea { width: 100%; min-height: 13rem; resize: vertical; border: 1px solid var(--line); border-radius: .75rem; padding: .8rem; background: #fff; color: var(--ink); font: .78rem/1.45 DM Mono, monospace; }
.cookie-status { min-height: 1.5rem; margin: .5rem 0; color: var(--muted); font-size: .8rem; }
.cookie-status.good { color: #27722d; }
.cookie-status.bad { color: #a23b28; }
.modal .primary { width: 100%; }
.modal small { display: block; min-height: 1.2rem; margin-top: .5rem; color: #a23b28; }
.impact { display: inline-flex; margin-bottom: .75rem; padding: .35rem .55rem; border-radius: .35rem; background: #ffe0d8; color: #8f2c19; font: 500 .7rem DM Mono, monospace; letter-spacing: .08em; }
blockquote { margin: 1rem 0; padding: 1rem; border-left: .25rem solid var(--coral); border-radius: 0 .75rem .75rem 0; background: #ece9de; font-weight: 700; }
.modal-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: .65rem; }

@keyframes orbit { to { transform: rotate(360deg) translateX(2.15rem) rotate(-360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes rise { from { opacity: 0; transform: translateY(.4rem); } }

@media (min-width: 48rem) {
  .shell { padding: 1.25rem; }
  .workspace { grid-template-columns: minmax(0, 1.45fr) minmax(21rem, .75fr); min-height: calc(100dvh - 6rem); }
  .browser-card { order: 1; }
  .chat-card { order: 2; }
  .browser-card { display: flex; flex-direction: column; }
  .browser-stage { flex: 1; min-height: 34rem; }
  .chat-card { min-height: 0; max-height: calc(100dvh - 6rem); }
  .browser-toolbar, .chat-heading { padding: 1.25rem; }
  .quick-actions { padding-inline: 1.25rem; }
  .messages { padding-inline: 1.25rem; }
}

@media (min-width: 90rem) {
  .shell { padding-inline: 2rem; }
  .workspace { grid-template-columns: minmax(0, 1.6fr) 28rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; }
}
