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

[hidden] { display: none !important; }

:root {
  --bg: #faf9f7;
  --bg-2: #f2f0ec;
  --surface: #ffffff;
  --ink: #17161a;
  --ink-2: #55524e;
  --ink-3: #8c8880;
  --line: #e4e0d8;
  --line-2: #d3cec4;
  --accent: #1b4dff;
  --accent-ink: #ffffff;
  --accent-soft: #e8edff;
  --good: #0d7a4f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(23,22,26,.05), 0 1px 1px rgba(23,22,26,.03);
  --shadow: 0 8px 30px rgba(23,22,26,.08), 0 2px 8px rgba(23,22,26,.04);
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e10;
    --bg-2: #141416;
    --surface: #17171a;
    --ink: #f4f2ee;
    --ink-2: #a8a49d;
    --ink-3: #6f6b64;
    --line: #26262a;
    --line-2: #34343a;
    --accent: #6d8cff;
    --accent-ink: #0b0b0d;
    --accent-soft: #1a2140;
    --good: #35d08a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 12px 40px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.3);
  }
}

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}
body.home-mode { overflow: auto; }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: radial-gradient(circle at 15% 0%, rgba(27,77,255,.06), transparent 45%),
                    radial-gradient(circle at 85% 10%, rgba(255,140,60,.05), transparent 40%);
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-weight: 600; letter-spacing: -.02em; font-size: 15.5px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.model-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11px; letter-spacing: -.2px;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line); padding: 6px 11px; border-radius: 999px;
}
.model-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 18%, transparent); }
.model-pill.err .dot { background: #d9534f; box-shadow: 0 0 0 3px rgba(217,83,79,.18); }

/* ---------------------------------------------------------------- buttons */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 500; letter-spacing: -.01em;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 10px 16px; cursor: pointer; display: inline-flex; align-items: center;
  gap: 7px; transition: background .15s, border-color .15s, transform .12s, color .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: #000; }
@media (prefers-color-scheme: dark) { .btn-primary:hover { background: #fff; color: #000; } }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.live { background: var(--good); border-color: var(--good); color: #fff; }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
  flex: none; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }

/* ---------------------------------------------------------------- home */
.home { position: relative; z-index: 1; max-width: 880px; margin: 0 auto; padding: 40px 24px 120px; }
.hero { padding-top: clamp(30px, 8vh, 90px); text-align: center; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 22px;
}
.hero h1 {
  margin: 0; font-size: clamp(44px, 8vw, 76px); line-height: .98; letter-spacing: -.045em;
  font-weight: 600;
}
.hero h1 em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -.02em; }
.sub {
  margin: 22px auto 0; max-width: 520px; color: var(--ink-2);
  font-size: clamp(15px, 2vw, 17px); line-height: 1.55; letter-spacing: -.01em;
}

.composer {
  margin: 42px auto 0; max-width: 660px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px 6px 6px 6px; text-align: left;
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--line-2); box-shadow: 0 12px 40px rgba(23,22,26,.1); }
.composer textarea {
  width: 100%; border: 0; resize: none; background: transparent; color: var(--ink);
  font-family: inherit; font-size: 16px; line-height: 1.5; padding: 14px 14px 8px;
  outline: none; min-height: 62px;
}
.composer textarea::placeholder { color: var(--ink-3); }
.composer-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 4px 4px 4px 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.composer-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.seg {
  display: flex; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 2px;
}
.seg-btn {
  font-family: inherit; font-size: 12px; color: var(--ink-3); background: transparent;
  border: 0; border-radius: 6px; padding: 5px 10px; cursor: pointer; font-weight: 500;
  transition: background .15s, color .15s;
}
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.chip {
  font-family: inherit; font-size: 12px; color: var(--ink-2); background: var(--bg-2);
  border: 1px solid transparent; border-radius: 999px; padding: 6px 11px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--accent-soft); color: var(--ink); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }

/* mode switch + source url */
.modes { display: flex; gap: 2px; padding: 6px 6px 0; }
.mode-btn {
  font-family: inherit; font-size: 12.5px; font-weight: 500; color: var(--ink-3);
  background: transparent; border: 0; border-radius: 7px; padding: 6px 11px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
.mode-btn:hover { color: var(--ink); background: var(--bg-2); }
.mode-btn.on { color: var(--ink); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); }
.mode-btn svg { opacity: .7; }

.url-field {
  display: flex; align-items: center; gap: 9px; margin: 10px 10px 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 0 12px; color: var(--ink-3);
}
.url-field:focus-within { border-color: var(--line-2); color: var(--ink-2); }
.url-field input {
  flex: 1; border: 0; background: transparent; outline: none; color: var(--ink);
  font-family: var(--mono); font-size: 12.5px; padding: 10px 0; min-width: 0;
}
.url-field input::placeholder { color: var(--ink-3); font-family: var(--sans); font-size: 13.5px; }

/* attachments */
.attach-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); color: var(--ink-2); }
.attach-btn:hover { background: var(--bg-2); }
.attach-btn.armed { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); }
.attach-strip { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 10px 0; }
.attach-strip:empty { display: none; }
.attach {
  position: relative; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  padding: 5px 26px 5px 5px; max-width: 200px; font-size: 11.5px; color: var(--ink-2);
}
.attach img { width: 30px; height: 30px; object-fit: cover; border-radius: 5px; flex: none; background: var(--bg-2); }
.attach .ico {
  width: 30px; height: 30px; border-radius: 5px; flex: none; display: grid; place-items: center;
  background: var(--bg-2); color: var(--ink-3);
}
.attach .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach .x {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 18px; height: 18px; border: 0; border-radius: 5px; background: transparent;
  color: var(--ink-3); cursor: pointer; display: grid; place-items: center; font-size: 12px; line-height: 1;
}
.attach .x:hover { background: var(--bg-2); color: var(--ink); }
.attach.up { opacity: .55; }

/* thumbnails inside the chat thread */
.msg-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg-thumbs img { width: 78px; height: 58px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.msg-thumbs .file-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; background: var(--bg);
}

.refine-row { display: flex; align-items: flex-end; gap: 8px; width: 100%; }

/* recent */
.recent { margin-top: 84px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.count { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0; overflow: hidden; cursor: pointer; text-align: left;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.card-thumb {
  height: 128px; background: var(--bg-2); border-bottom: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.card-thumb iframe {
  position: absolute; top: 0; left: 0; width: 1400px; height: 900px; border: 0;
  transform: scale(.2); transform-origin: 0 0; pointer-events: none;
}
.card-actions {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 4px;
  opacity: 0; transition: opacity .15s; z-index: 2;
}
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }
.card-act {
  width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer;
  border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); padding: 0;
}
.card-act:hover { background: var(--bg-2); color: var(--ink); }
.card-act.danger:hover { color: #c0392b; border-color: #c0392b; }
.card-body { padding: 12px 14px 14px; }
.card-title { font-size: 13.5px; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.badge { padding: 1px 6px; border-radius: 4px; background: var(--bg-2); border: 1px solid var(--line); }
.badge.live { color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); background: color-mix(in srgb, var(--good) 9%, transparent); }

/* ---------------------------------------------------------------- builder */
.builder {
  position: fixed; inset: 0; display: grid; grid-template-columns: 380px 1fr;
  background: var(--bg); z-index: 5;
}
body.builder-mode .topbar { display: none; }
body.builder-mode { overflow: hidden; }
.panel {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: var(--surface);
}
.panel-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); flex: none;
}
.panel-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.panel-title span:first-child { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-sub { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: -.2px; }

.thread { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.thread:empty::after {
  content: "Describe the page you want, or ask for a change. Every revision is saved.";
  display: block; color: var(--ink-3); font-size: 13px; line-height: 1.55; padding: 6px 2px;
}
.msg { font-size: 13px; line-height: 1.55; }
.msg-user {
  align-self: flex-end; max-width: 88%; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px 12px 3px 12px; padding: 9px 12px; color: var(--ink);
}
.msg-ai {
  align-self: flex-start; max-width: 96%; color: var(--ink-2);
  padding-left: 2px; display: flex; gap: 8px; align-items: flex-start;
}
.msg-ai .ai-mark {
  width: 20px; height: 20px; border-radius: 5px; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; flex: none; margin-top: 1px; font-size: 10px;
}
.msg-ai .ai-mark svg { width: 12px; height: 12px; }
.msg-ai.err { color: #c0392b; }
@media (prefers-color-scheme: dark) { .msg-ai.err { color: #ff8f85; } }

.typing { display: inline-flex; gap: 3px; padding-top: 6px; }
.typing i { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.quick-actions { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; flex: none; scrollbar-width: none; }
.quick-actions::-webkit-scrollbar { display: none; }
.qa {
  font-family: inherit; font-size: 11.5px; white-space: nowrap; color: var(--ink-2);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.qa:hover { background: var(--accent-soft); color: var(--ink); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

.refine {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px;
  border-top: 1px solid var(--line); flex: none;
}
.refine-attach { padding: 8px 12px 0; }
.refine textarea {
  flex: 1; resize: none; border: 1px solid var(--line); background: var(--bg);
  border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 13.5px;
  line-height: 1.45; color: var(--ink); outline: none; max-height: 140px;
  transition: border-color .15s;
}
.refine textarea:focus { border-color: var(--line-2); }
.btn-send {
  width: 38px; height: 38px; padding: 0; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); border-radius: 10px; flex: none;
}
.btn-send:disabled { opacity: .35; }

/* stage */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-2); }
.stage-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex: none;
}
.url-bar {
  flex: 1; display: flex; align-items: center; gap: 7px; min-width: 0;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 11px; color: var(--ink-2);
}
.url-bar .lock { display: grid; place-items: center; color: var(--ink-3); flex: none; }
.url-text { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.devices { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; flex: none; }
.dev {
  width: 30px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-3); cursor: pointer; transition: background .15s, color .15s;
}
.dev:hover { color: var(--ink); }
.dev.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.stage-actions { display: flex; gap: 8px; flex: none; }

.frame-wrap { flex: 1; overflow: auto; padding: 20px; display: flex; justify-content: center; }
.frame {
  position: relative; width: 100%; max-width: 100%; background: #fff;
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--line); transition: max-width .3s ease;
}
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.frame[data-device="desktop"] { max-width: 100%; }
.frame[data-device="tablet"] { max-width: 834px; }
.frame[data-device="mobile"] { max-width: 390px; }
.frame-wrap { align-items: stretch; }
.frame { height: 100%; }

.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; background: #fbfaf8;
  color: #78736b; font-family: var(--sans); font-size: 13.5px;
}
.empty-state[hidden] { display: none; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #e3ded4; border-top-color: #1b4dff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-status {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--ink); color: var(--bg); font-size: 12.5px; font-weight: 500;
  padding: 9px 15px; border-radius: 999px; box-shadow: var(--shadow); z-index: 20;
}
.gen-status .pulse { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.3s infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(16,15,18,.45); backdrop-filter: blur(4px); padding: 20px;
  animation: fade .15s ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.28);
  animation: rise .18s ease;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -.02em; font-weight: 600; }
.modal-sub { margin: 0 0 20px; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 7px; }
.slug-row {
  display: flex; align-items: center; background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 0 0 0 12px; overflow: hidden;
}
.slug-row:focus-within { border-color: var(--line-2); }
.slug-prefix { font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); flex: none; }
.slug-row input {
  flex: 1; border: 0; background: transparent; padding: 10px 12px 10px 2px;
  font-family: var(--mono); font-size: 12.5px; color: var(--ink); outline: none; min-width: 0;
}
.slug-row input:first-child { padding-left: 2px; }
.slug-row .slug-prefix + input { padding-left: 2px; }
.slug-suffix {
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); flex: none;
  padding: 0 12px 0 0; white-space: nowrap;
}
.slug-suffix[hidden], .slug-prefix[hidden] { display: none; }
.field-hint.bad { color: #9b2c2c; }
.slug-row + .field-hint { word-break: break-all; }
@media (prefers-color-scheme: dark) { .field-hint.bad { color: #ff8f85; } }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-2); margin-bottom: 22px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.publish-result { margin-top: 18px; padding: 13px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12.5px; }
.publish-result[hidden] { display: none; }
.publish-result .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-family: var(--mono); margin-bottom: 6px; }
.publish-result a { color: var(--accent); font-family: var(--mono); font-size: 12px; word-break: break-all; }
.publish-result .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.copy-btn { font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 6px; padding: 4px 9px; cursor: pointer; }
.copy-btn:hover { background: var(--bg); color: var(--ink); }

/* domain + tunnel */
.modal { max-height: min(86vh, 720px); overflow-y: auto; }
.status-pill {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2);
  color: var(--ink-3); background: var(--bg-2); flex: none;
}
.status-pill.ok { color: #17683f; border-color: #b8e0c8; background: #eaf7ef; }
.status-pill.wait { color: #8a5a00; border-color: #efd9a8; background: #fdf5e3; }
.status-pill.bad { color: #9b2c2c; border-color: #f0c3c3; background: #fdecec; }
.dns-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.dns-host { font-family: var(--mono); font-size: 13.5px; color: var(--ink); word-break: break-all; flex: 1; }
.dns-steps { margin-bottom: 14px; }
.dns-lead { margin: 0 0 9px; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.dns-table { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--bg); }
.dns-row {
  display: grid; grid-template-columns: 62px 1fr; gap: 10px; align-items: baseline;
  padding: 9px 11px; border-bottom: 1px solid var(--line); font-size: 12px;
}
.dns-row:last-child { border-bottom: 0; }
.dns-row .k { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.dns-row .v { font-family: var(--mono); font-size: 11.5px; color: var(--ink); word-break: break-all; display: flex; align-items: center; gap: 7px; }
.dns-row .v .copy-mini {
  font-family: var(--mono); font-size: 10px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-3); border-radius: 5px; padding: 1px 6px; cursor: pointer; flex: none;
}
.dns-row .v .copy-mini:hover { color: var(--ink); }
.dns-ol { margin: 0; padding-left: 17px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.dns-ol li { margin-bottom: 6px; }
.dns-check {
  margin-bottom: 16px; padding: 10px 12px; border-radius: 9px; font-size: 12.5px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2); line-height: 1.5;
}
.dns-check[hidden] { display: none; }
.dns-check.ok { background: #eaf7ef; border-color: #b8e0c8; color: #17683f; }
.dns-check.bad { background: #fdecec; border-color: #f0c3c3; color: #9b2c2c; }
.dns-check b { font-weight: 600; }
.dns-check > div + div { margin-top: 5px; }
.dns-raw { opacity: .7; font-size: 11.5px; }
.tunnel-box {
  margin: 0 0 4px; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg-2);
}
.tunnel-box[hidden] { display: none; }
#domainEmpty[hidden], #domainSet[hidden] { display: none; }
#domainSet .modal-actions { margin-top: 18px; }
.tunnel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.tunnel-label { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.tunnel-help { margin: 0 0 11px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.tunnel-box .field { margin-bottom: 12px; }
.tunnel-box .modal-actions { justify-content: flex-end; }
.tunnel-box > .btn { margin-top: 2px; }
.danger-text { color: #9b2c2c; }
.danger-text:hover { background: #fdecec; color: #7d2020; }
.field-hint { display: block; margin-top: 6px; font-size: 11.5px; color: var(--ink-3); }
[hidden] { display: none !important; }

/* history drawer */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(300px, 85%);
  background: var(--surface); border-left: 1px solid var(--line); z-index: 30;
  padding: 16px; overflow-y: auto; box-shadow: -12px 0 40px rgba(0,0,0,.1);
  animation: slide .18s ease;
}
@keyframes slide { from { transform: translateX(20px); opacity: 0; } }
.drawer h4 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-family: var(--mono); font-weight: 500; }
.ver {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 7px;
  font-size: 12px; cursor: pointer; background: var(--bg);
}
.ver:hover { border-color: var(--line-2); }
.ver.cur { border-color: var(--accent); background: var(--accent-soft); }
.ver .n { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); flex: none; }
.ver .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.drawer .close { position: absolute; top: 12px; right: 12px; }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(0);
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 500;
  padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); z-index: 200;
  animation: toastIn .2s ease;
}
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

@media (max-width: 860px) {
  .builder { grid-template-columns: 1fr; grid-template-rows: 44vh 56vh; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage-bar .url-bar { display: none; }
  .frame-wrap { padding: 8px; }
  .topbar { padding: 14px 18px; }
  .home { padding: 20px 18px 80px; }
  .chips { display: none; }
  .model-pill { display: none; }
  .composer textarea { font-size: 15px; min-height: 96px; }
  .composer-bar { align-items: center; }
  .hero h1 { letter-spacing: -.035em; }
  .sub { font-size: 15px; }
  .recent { margin-top: 56px; }
}

@media (max-width: 460px) {
  .topbar { padding: 12px 14px; }
  .home { padding: 12px 14px 70px; }
  .composer { margin-top: 28px; }
  .composer-actions { width: 100%; justify-content: space-between; }
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- account */
.account { display: flex; align-items: center; gap: 8px; }
.account-chip {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------------------------------------------------------- auth */
body.auth-mode { overflow: auto; }
.auth {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px; gap: 28px;
}
.auth-brand { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 10px; }
.auth-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 30px 28px; box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.025em; font-weight: 600; }
.auth-sub { margin: 0 0 24px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.auth-submit { width: 100%; justify-content: center; padding: 11px 16px; }
.auth-error {
  margin: 0 0 14px; padding: 9px 11px; border-radius: 8px; font-size: 12.5px;
  color: #c0392b; background: color-mix(in srgb, #c0392b 8%, transparent);
  border: 1px solid color-mix(in srgb, #c0392b 22%, transparent);
}
.auth-switch { margin: 20px 0 0; font-size: 13px; color: var(--ink-2); text-align: center; }
.link-btn {
  background: none; border: 0; padding: 0 0 0 4px; font: inherit; font-size: 13px;
  color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.auth-fine {
  margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 11.5px; line-height: 1.55; color: var(--ink-3);
}
.opt { font-style: normal; color: var(--ink-3); font-weight: 400; }

/* ---------------------------------------------------------------- admin */
.admin-tag {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px;
}
.admin { position: relative; z-index: 1; max-width: 1000px; margin: 0 auto; padding: 24px 24px 100px; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 36px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
}
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.stat-label { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.admin-section { margin-bottom: 40px; }
.admin-note { margin: -6px 0 14px; font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; font-family: var(--mono); font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2);
  white-space: nowrap;
}
.admin-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .num { text-align: right; font-family: var(--mono); font-size: 12px; }
.admin-table .right { text-align: right; }
.admin-table .muted { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.admin-table .mono { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.cell-main { font-weight: 500; letter-spacing: -.01em; }
.drafts-row td { background: var(--bg-2); padding: 0; }
.drafts-panel { padding: 14px 16px; }
.support-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
  font-size: 12px;
}
.support-label {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--warn, #b06d00); border: 1px solid color-mix(in srgb, #b06d00 30%, transparent);
  background: color-mix(in srgb, #b06d00 8%, transparent); border-radius: 5px; padding: 3px 7px;
}
.support-owner { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.support-list { display: grid; gap: 6px; }
.support-item {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: 13px;
}
.support-item:hover { border-color: var(--line-2); }
.support-item-title { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.on { background: var(--bg-2); color: var(--ink); }
