:root {
  --bg: #0e0f13; --panel: #16171d; --panel-2: #1d1f27; --panel-3: #252833; --line: #2a2d38; --text: #ecebf0; --muted: #9a99a8;
  --ruby: #e0245e; --ruby-2: #ff4d7e; --ok: #2fbf71; --warn: #e5a323; --err: #ff5c6c;
  --radius: 12px; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; font-size: 14.5px; line-height: 1.45; overflow: hidden; }
h1 { font-size: 1.7rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }
h3 { font-size: .8rem; margin: 0 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 .5rem; }
a { color: var(--ruby-2); }
.muted { color: var(--muted); } .small { font-size: .8rem; } .pad { padding: .6rem; } .grow { flex: 1; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: .5rem .9rem; border-bottom: 1px solid var(--line); background: var(--panel); }
.tb-left { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.tb-right { grid-column: 3; display: flex; align-items: center; gap: .75rem; justify-content: flex-end; }
.switcher { position: relative; min-width: 0; }
.switcher-btn { background: transparent; border: 1px solid transparent; color: var(--text); font: inherit; font-weight: 600; padding: .35rem .55rem; border-radius: 8px; cursor: pointer; display: flex; gap: .4rem; align-items: center; max-width: 320px; }
.switcher-btn:hover { background: var(--panel-2); border-color: var(--line); }
.switcher-btn span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: .75rem; }
.switcher-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: 300px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.45); padding: .35rem; }
.switcher-list { max-height: 50vh; overflow-y: auto; }
.switcher-item, .switcher-new { width: 100%; display: flex; justify-content: space-between; gap: .5rem; background: none; border: 0; color: var(--text); font: inherit; text-align: left; padding: .5rem .6rem; border-radius: 7px; cursor: pointer; }
.switcher-item:hover, .switcher-new:hover { background: var(--panel-3); }
.switcher-item.active { background: rgba(224, 36, 94, .14); }
.switcher-new { border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; margin-top: .3rem; color: var(--ruby-2); font-weight: 600; }
.tabs { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: .35rem .9rem; border-radius: 7px; cursor: pointer; }
.tabs button.on { background: var(--panel-3); color: var(--text); }
.chip { font-size: .75rem; border: 1px solid var(--line); border-radius: 999px; padding: .15rem .55rem; color: var(--muted); white-space: nowrap; }
.who { background: var(--panel-2); border: 1px solid var(--line); padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; }

/* ---------- layout ---------- */
.shell { flex: 1; display: grid; grid-template-columns: minmax(340px, 420px) 1fr; min-height: 0; }
.chat { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); min-height: 0; }
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- chat ---------- */
.thread { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; max-width: 88%; text-align: right; }
.msg.user .bubble { display: inline-block; text-align: left; background: var(--panel-3); border: 1px solid var(--line); padding: .55rem .8rem; border-radius: 12px 12px 4px 12px; white-space: pre-wrap; word-break: break-word; }
.msg.user .bubble.clamp { max-height: 8.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 65%, transparent); mask-image: linear-gradient(#000 65%, transparent); }
.msg .meta { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.msg.ai { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; padding: .7rem .85rem; }
.msg.ai.live { border-color: rgba(224, 36, 94, .5); }
.msg.ai.failed { border-color: rgba(255, 92, 108, .4); }
.msg.ai.answer p { margin: 0 0 .55rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg.ai.answer a { color: #ff8fb1; text-decoration: underline; }
.msg.intro { background: transparent; border-style: dashed; }
.plan { white-space: pre-wrap; }
.summary { color: #c9e9d6; }
.ai-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .45rem; }
.grow-right { margin-left: auto; }
.spinner { width: 16px; height: 16px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ruby-2); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-files { list-style: none; margin: .4rem 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }
.progress-files li { display: grid; grid-template-columns: 1.2rem 1fr auto; gap: .3rem; align-items: center; }
.progress-files li.done .tick { color: var(--ok); }
.progress-files li.writing { color: #fff; }
.progress-files li.writing .tick { color: var(--ruby-2); animation: pulse 1s ease-in-out infinite; }
.progress-files li.deleted { color: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .35rem 0; }
.file-chip { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .72rem; background: var(--panel-3); border: 1px solid var(--line); border-radius: 6px; padding: .1rem .4rem; }
.file-chip.deleted { color: var(--err); }
.example { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: .3rem .7rem; font: inherit; font-size: .8rem; cursor: pointer; }
.example:hover { border-color: var(--ruby); }
.msg-actions { display: flex; align-items: center; gap: .8rem; margin-top: .35rem; }
.link { background: none; border: 0; color: var(--ruby-2); cursor: pointer; padding: 0; font: inherit; font-weight: 600; }

.composer { border-top: 1px solid var(--line); padding: .75rem; background: var(--panel); }
.composer textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: .65rem .75rem; font: inherit; resize: vertical; min-height: 4.5rem; max-height: 40vh; }
.composer textarea:focus { outline: 2px solid rgba(224, 36, 94, .5); border-color: transparent; }
.composer textarea:disabled { opacity: .6; }
.composer-bar { display: flex; align-items: center; gap: .6rem; margin-top: .45rem; }
.hint-keys { margin-left: auto; }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--ruby), #b3164a); color: #fff; font-size: 1rem; cursor: pointer; flex-shrink: 0; }
.send:disabled { opacity: .4; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted); }

/* ---------- shared ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: .55rem .95rem; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #3b3e4b; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--ruby), #b3164a); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; }
.btn-small { padding: .32rem .65rem; font-size: .82rem; }
.btn.danger, .danger { color: var(--err); }
.notice { margin: .5rem 0 0; padding: .55rem .75rem; border-radius: 8px; font-size: .85rem; }
.notice.error { background: rgba(255, 92, 108, .1); border: 1px solid rgba(255, 92, 108, .35); color: #ffb3bb; }
.notice.warn { background: rgba(229, 163, 35, .1); border: 1px solid rgba(229, 163, 35, .35); color: #f4d08a; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(224, 36, 94, .5); border-color: transparent; }
.form-card label { display: block; font-weight: 600; margin: .8rem 0 .35rem; font-size: .88rem; }
.form-card label:first-child { margin-top: 0; }
.form-card input, .form-card select, .form-card textarea { width: 100%; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: .5rem; margin-top: .9rem; }
.empty { margin: auto; color: var(--muted); text-align: center; padding: 2rem; }

/* ---------- welcome ---------- */
.welcome { align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.welcome p { max-width: 560px; }
.welcome-actions { margin-top: 1rem; }

/* ---------- preview ---------- */
.toolbar { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.toolbar select { padding: .32rem .5rem; font-size: .82rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; color: var(--muted); border: 0; padding: .32rem .65rem; font: inherit; font-size: .8rem; cursor: pointer; }
.seg button.on { background: var(--panel-3); color: var(--text); }
.preview-stage { flex: 1; min-height: 0; background: #23252d; display: flex; justify-content: center; overflow: auto; }
.preview-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; transition: width .2s ease; }

/* ---------- code ---------- */
.code-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 240px 1fr; }
.file-list { border-right: 1px solid var(--line); overflow-y: auto; padding: .4rem; background: var(--panel); }
.file-item { width: 100%; display: flex; justify-content: space-between; gap: .5rem; background: none; border: 0; color: var(--text); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; padding: .4rem .5rem; border-radius: 6px; cursor: pointer; text-align: left; }
.file-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item:hover { background: var(--panel-2); }
.file-item.on { background: rgba(224, 36, 94, .14); }
.code-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.code-path { padding: .45rem .9rem; border-bottom: 1px solid var(--line); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; color: var(--muted); }
.code-view { flex: 1; margin: 0; overflow: auto; padding: .6rem 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; line-height: 1.55; tab-size: 2; }
.code-view .line { display: block; padding-right: 1rem; white-space: pre; }
.code-view .ln { display: inline-block; width: 3.4rem; padding-right: 1rem; text-align: right; color: #555866; user-select: none; }

/* ---------- dashboard ---------- */
.dash { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px 1fr; }
.dash-nav { border-right: 1px solid var(--line); padding: .8rem .5rem; display: flex; flex-direction: column; gap: .15rem; background: var(--panel); }
.dash-nav button { background: none; border: 0; color: var(--text); font: inherit; text-align: left; padding: .55rem .7rem; border-radius: 8px; cursor: pointer; }
.dash-nav button:hover { background: var(--panel-2); }
.dash-nav button.on { background: var(--panel-3); font-weight: 600; }
.dash-body { overflow-y: auto; padding: 1.4rem 1.6rem; }
.dash-section { max-width: 980px; }
.overview-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stats .card { margin: 0; }
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin: .2rem 0; }
.publish-status p { margin: .25rem 0; word-break: break-all; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: .4rem; }
.stale { color: #f4d08a; }
.table-card { padding: 0; overflow-x: auto; }
.versions { width: 100%; border-collapse: collapse; }
.versions th { text-align: left; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.versions td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.versions tr:last-child td { border-bottom: 0; }
.versions td.what { max-width: 360px; }
.versions td.actions { white-space: nowrap; text-align: right; }
.versions td.actions .btn { margin-left: .3rem; }
.badge { white-space: nowrap; display: inline-block; margin-left: .4rem; font-size: .68rem; font-weight: 700; text-transform: uppercase; padding: .05rem .4rem; border-radius: 999px; background: var(--panel-3); color: var(--muted); }
.badge.live { background: rgba(47, 191, 113, .15); color: var(--ok); }
.danger-zone { border-color: rgba(255, 92, 108, .35); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog label { display: block; margin: .9rem 0 .35rem; font-weight: 600; font-size: .9rem; }
dialog input, dialog textarea { width: 100%; }

@media (max-width: 1000px) {
  body { overflow: auto; }
  .topbar { grid-template-columns: 1fr; }
  .tb-right { justify-content: flex-start; flex-wrap: wrap; }
  .shell { grid-template-columns: 1fr; }
  .chat { max-height: 55vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .view { min-height: 80vh; }
  .dash, .code-layout { grid-template-columns: 1fr; }
  .dash-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .file-list { max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--line); }
}

.address-field { display: flex; align-items: center; gap: .35rem; border: 1px solid var(--line); border-radius: 8px; padding: 0 .6rem; background: var(--panel); }
.address-field input { border: 0; background: transparent; padding-left: 0; padding-right: 0; flex: 1; min-width: 6rem; }
.address-field input:focus { outline: none; }
.address-field:focus-within { outline: 2px solid rgba(224, 36, 94, .6); }

.submission { display: grid; gap: .5rem; }
.submission-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.submission-head .grow-right-btn { margin-left: auto; }
.submission .fields { display: grid; grid-template-columns: minmax(6rem, max-content) 1fr; gap: .25rem .9rem; margin: 0; }
.submission .fields dt { color: var(--muted, #9a9aa5); text-transform: capitalize; }
.submission .fields dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.copy-btn { display: inline-flex; align-items: center; gap: .3rem; background: none; border: 0; padding: .15rem .25rem; margin-left: -.25rem; border-radius: 6px; color: var(--muted); cursor: pointer; font: inherit; font-size: .72rem; }
.copy-btn:hover, .copy-btn:focus-visible { color: var(--text); background: var(--panel-3); outline: none; }
.copy-btn.copied { color: #7fd6a4; }
.msg.user .meta { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; }

.connect-row { display: flex; gap: .5rem; }
.connect-row input { flex: 1; }
.connected-domain { border-top: 1px solid var(--line); padding-top: .75rem; margin-top: .75rem; display: grid; gap: .5rem; }
.connected-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.badge.error { background: rgba(255, 92, 108, .15); color: #ff8a96; }
.dns-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.dns-table th { text-align: left; color: var(--muted); font-weight: 500; padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
.dns-table td { padding: .4rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dns-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.dns-table tr.optional td { color: var(--muted); }
.error-text { color: #ff8a96; }
#connect-setup { background: rgba(255, 190, 80, .1); color: #f3c97a; padding: .6rem .8rem; border-radius: 8px; }

.plan-card { border-color: rgba(224, 36, 94, .45); }
.plan-card.approved, .plan-card.replaced { border-color: var(--line); }
.plan-card.replaced { opacity: .65; }
.plan-body p { margin: .3rem 0; line-height: 1.5; }
.plan-item { padding-left: .9rem; text-indent: -.9rem; margin: .2rem 0; line-height: 1.45; }

.images-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.images-bar #images-status { flex: 1; min-width: 16rem; line-height: 1.45; }
.upload-btn { cursor: pointer; }
.images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; margin-top: .9rem; }
.image-card { margin: 0; background: var(--panel-2, #17171c); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.image-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: repeating-conic-gradient(#2a2a31 0% 25%, #222228 0% 50%) 0 0 / 16px 16px; }
.image-card video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; }
.code-image video { max-width: 100%; max-height: 70vh; display: block; background: #000; border-radius: 8px; }
.videos-heading { margin: 1.6rem 0 .3rem; }
#motion-status { margin-bottom: .7rem; }
.audio-list { display: grid; gap: .5rem; margin-top: .7rem; }
.audio-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(220px, 2fr) auto auto; align-items: center; gap: .8rem; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2, #17171c); }
.audio-row audio { width: 100%; height: 34px; }
#videos-status { margin-bottom: .7rem; }
.image-card figcaption { padding: .55rem .65rem .65rem; display: grid; gap: .25rem; }
.image-name { font-weight: 600; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-actions { display: flex; align-items: center; gap: .4rem; margin-top: .2rem; }
.code-image { padding: 1rem; display: grid; gap: .6rem; justify-items: start; }
.code-image img { max-width: 100%; max-height: 60vh; border-radius: 8px; border: 1px solid var(--line); background: repeating-conic-gradient(#2a2a31 0% 25%, #222228 0% 50%) 0 0 / 16px 16px; }

.row-gap { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ----- + menu and attachments (v5.2) ----- */
.composer.dropping { outline: 2px dashed var(--accent, #e0446f); outline-offset: 3px; border-radius: 14px; }
.attach-wrap { position: relative; }
.attach-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line, #333); background: transparent; color: inherit; font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.attach-btn:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.attach-btn:disabled { opacity: .4; cursor: default; }
.attach-menu { position: absolute; left: 0; bottom: 44px; z-index: 30; min-width: 290px; max-width: 340px; padding: 6px; border-radius: 14px; background: #fff; color: #1c1c22; box-shadow: 0 12px 40px rgba(0,0,0,.35); border: 1px solid #e4e4ea; }
.attach-menu > button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: inherit; font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.attach-menu > button:hover { background: #f1f1f5; }
.attach-menu > button span { flex: 1; }
.attach-menu kbd { font: inherit; font-size: 12px; color: #8a8a96; }
.attach-menu .chev { font-weight: 400; color: #8a8a96; }
.attach-menu hr { border: 0; border-top: 1px solid #ececf1; margin: 5px 4px; }
.attach-pick { max-height: 260px; overflow: auto; margin: 2px 4px 4px; padding: 4px; border-radius: 10px; background: #f7f7fa; }
.attach-pick .muted, .attach-pick p { color: #6b6b78; padding: 6px; margin: 0; }
.pick-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 4px; border: 0; border-radius: 8px; background: none; cursor: pointer; color: inherit; }
.pick-row:hover:not(:disabled) { background: #ececf2; }
.pick-row:disabled { opacity: .45; cursor: default; }
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 220px; padding: 4px 8px 4px 4px; border-radius: 10px; border: 1px solid var(--line, #333); background: rgba(255,255,255,.06); font-size: 13px; }
.attach-menu .attach-chip, .attach-pick .attach-chip { border-color: #dcdce4; background: #fff; color: #1c1c22; }
.attach-chip img, .chip-icon { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; flex: none; }
.chip-icon { display: grid; place-items: center; background: #e0446f; color: #fff; font-size: 14px; }
.chip-icon.audio { background: #6d4ae0; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { border: 0; background: none; color: inherit; opacity: .6; font-size: 17px; line-height: 1; cursor: pointer; padding: 0 2px; }
.chip-x:hover { opacity: 1; }
.attach-chip.uploading { padding: 8px 10px; gap: 8px; }
.attach-chip .spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.25); border-top-color: currentColor; border-radius: 50%; animation: chip-spin .8s linear infinite; }
@keyframes chip-spin { to { transform: rotate(360deg); } }
.bubble-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ----- v5.5: website or video projects ----- */
.kind-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kind-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: rgba(255,255,255,.03); }
.kind-card:has(input:checked) { border-color: var(--ruby-2, #e0446f); background: rgba(224,68,111,.10); }
.kind-card input { position: absolute; opacity: 0; pointer-events: none; }
.kind-card .kind-icon { font-size: 22px; line-height: 1; }
.kind-card b { display: block; margin-bottom: 3px; }
.kind-card small { display: block; color: var(--muted, #9a9aa6); font-size: 12.5px; line-height: 1.35; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.video-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.video-player { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 100%; }
.video-player video { max-width: 100%; max-height: calc(100vh - 230px); border-radius: 12px; background: #000; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.video-meta { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 320px; flex-wrap: wrap; }
.scene-box { position: relative; overflow: hidden; border-radius: 12px; background: #000; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.scene-frame { position: absolute; top: 0; left: 0; border: 0; transform-origin: top left; }

/* ----- v6.1.3: what RubyAI is doing, pinned above the message box ----- */
.work-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 12px 8px; padding: 10px 12px; border-radius: 12px; background: rgba(224,68,111,.12); border: 1px solid rgba(224,68,111,.45); box-shadow: 0 -6px 18px rgba(0,0,0,.25); }
.work-bar .work-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.work-bar .work-status { font-size: 14px; line-height: 1.3; }
.work-details { flex-basis: 100%; max-height: 40vh; overflow: auto; padding-top: 6px; border-top: 1px solid rgba(224,68,111,.3); }
.work-details .plan { margin: 4px 0 8px; font-size: 13px; }

/* ----- v6.2: SEO ----- */
.seo-top { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; margin: 14px 0 18px; }
.seo-score { display: flex; align-items: center; gap: 16px; }
.seo-ring { width: 84px; height: 84px; border-radius: 50%; display: grid; place-content: center; text-align: center; border: 6px solid var(--line); }
.seo-ring strong { font-size: 28px; line-height: 1; }
.seo-ring span { font-size: 11px; color: var(--muted, #9a9aa6); }
.seo-ring.good, .seo-mini.good { border-color: #22b573; }
.seo-ring.ok, .seo-mini.ok { border-color: #f0a830; }
.seo-ring.poor, .seo-mini.poor { border-color: #e0446f; }
.seo-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seo-actions p { flex-basis: 100%; margin: 0; }
.seo-google { margin-bottom: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 8px; }
.seo-google-scores { display: flex; gap: 10px; flex-wrap: wrap; }
.seo-mini { min-width: 96px; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); display: flex; flex-direction: column; }
.seo-mini strong { font-size: 22px; }
.seo-issues { display: grid; gap: 8px; }
.seo-issue { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.seo-sev { flex: none; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.08); }
.seo-issue.high .seo-sev { background: rgba(224,68,111,.25); color: #ff9db8; }
.seo-issue.medium .seo-sev { background: rgba(240,168,48,.2); color: #f5c46b; }

/* ----- v6.3: photo projects ----- */
.photo-stage { justify-content: flex-start; }
#photo-main { max-width: 100%; max-height: calc(100vh - 320px); border-radius: 12px; background: #000; box-shadow: 0 12px 40px rgba(0,0,0,.4); object-fit: contain; }
.photo-name { font-weight: 600; overflow-wrap: anywhere; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; width: 100%; padding: 4px 2px 8px; }
.photo-thumb { flex: 0 0 auto; width: 84px; height: 84px; padding: 0; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: #111; cursor: pointer; position: relative; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb.on { border-color: #e0446f; }
.photo-thumb .tag { position: absolute; left: 4px; bottom: 4px; font-size: 10px; padding: 1px 5px; border-radius: 6px; background: rgba(0,0,0,.7); color: #fff; }
.kind-choice { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .kind-choice { grid-template-columns: 1fr; } }

.import-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.import-card p { margin: 4px 0 0; }
.notice.error.ok { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.45); color: #bbf7d0; }

/* ----- v6.5: connect your domain, find a domain ----- */
.dw-result { display: grid; gap: 10px; margin-top: 10px; }
.dw-result h4 { margin: 4px 0 0; font-size: 14px; }
.dw-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
.dw-list code, .ns code { background: rgba(255,255,255,.06); padding: 1px 6px; border-radius: 6px; }
.ns { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.dw-choice { border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.dw-live { display: grid; gap: 4px; font-size: 14px; }
.dw-live .ok { color: #4ade80; } .dw-live .wait { color: #fbbf24; }
.find-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.find-table td { padding: 7px 6px; border-top: 1px solid rgba(255,255,255,.07); }
.find-table .taken { color: #8b8b95; }
.find-table .free { color: #4ade80; font-weight: 600; }

/* ----- v7.0: sign-in, account menu, users ----- */
.signin { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg, #0e0e12); padding: 20px; }
.signin-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 10px; }
.signin-card h1 { margin: 4px 0 0; font-size: 22px; }
.signin-card form { display: grid; gap: 10px; }
.signin-card .agree { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.signin-card .agree input { margin-top: 3px; }
.linklike { background: none; border: 0; padding: 0; color: #e0446f; cursor: pointer; font: inherit; text-decoration: underline; }
.who-wrap { position: relative; }
button.who { cursor: pointer; color: inherit; font: inherit; font-size: .8rem; }
.who-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; min-width: 140px; }
.who-menu button { background: none; border: 0; color: inherit; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.who-menu button:hover { background: var(--panel-2); }
#users-dialog { width: min(1100px, 96vw); max-height: 92vh; }
.users-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-list td, .users-list th { padding: 6px; border-top: 1px solid var(--line); text-align: left; }
.users-list .suspended { color: #f87171; }

/* ----- v7.1: credits and billing ----- */
.credits-chip { cursor: pointer; background: rgba(224,68,111,.12); border-color: rgba(224,68,111,.4); color: inherit; font: inherit; font-size: .8rem; }
#billing-dialog { width: min(760px, 94vw); }
.billing-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 8px; }
.bill-balance { font-size: 34px; font-weight: 700; }
.bill-plan { text-align: right; display: grid; gap: 6px; justify-items: end; font-size: 14px; }
.bill-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 8px; }
.bill-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 6px; }
.bill-card .price { font-size: 22px; font-weight: 700; }
.bill-card .per { color: var(--muted, #9a9aa5); font-size: 13px; }
.bill-prices table, .bill-history table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.bill-prices td, .bill-history td { padding: 5px 4px; border-top: 1px solid var(--line); }
.bill-history .plus { color: #4ade80; } .bill-history .minus { color: #f0a0b4; }
details.bill-prices, details.bill-history { margin-top: 10px; }
#billing-dialog h3 { margin: 14px 0 2px; font-size: 15px; }

/* ----- v7.2: admin ----- */
.acting-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 7px 14px; background: #fff4d6; color: #5a3d00; border-bottom: 1px solid #f0d58a; font-size: 13.5px; }
.acting-bar .btn { background: #fff; color: #5a3d00; border-color: #e3c370; }
.admin-dialog { width: min(1100px, 96vw); max-height: 92vh; }
.admin-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.admin-head h2 { margin: 0; }
.admin-head #users-close { margin-left: auto; }
.admin-section { display: grid; gap: 10px; }
.admin-section h3 { margin: 12px 0 0; }
.admin-tools { display: flex; gap: 8px; align-items: center; }
.admin-tools input { flex: 1; max-width: 360px; }
.admin-new { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.admin-new label { display: grid; gap: 4px; font-size: 13px; }
.admin-new label.inline { display: flex; gap: 8px; align-items: center; }
.admin-new .row-end { grid-column: 1 / -1; }
.notice.ok-msg { background: rgba(47, 191, 113, .12); border: 1px solid rgba(47, 191, 113, .45); color: var(--ok-text); }
.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-email { margin: 0; font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text); }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 4px 0; font-size: 13.5px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.admin-section table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-section td, .admin-section th { padding: 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.scroll-table { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.scroll-table table td:first-child, .scroll-table table th:first-child { padding-left: 10px; }
.nowrap { white-space: nowrap; }
.mono-cell { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-word; }
.failed-row td { background: rgba(255, 92, 108, .06); }

/* ----- v7.2: white theme (the default; the account menu switches to dark) ----- */
:root { --ok-text: #bbf7d0; }
:root[data-theme="light"] {
  --bg: #ffffff; --panel: #ffffff; --panel-2: #f6f6f8; --panel-3: #ececf1; --line: #e1e1e8; --text: #111114; --muted: #5e5e6b;
  --ruby: #d61f57; --ruby-2: #c81d52; --ok: #15803d; --warn: #b45309; --err: #c62835; --ok-text: #14532d;
  color-scheme: light;
}
:root[data-theme="light"] .switcher-menu, :root[data-theme="light"] .who-menu, :root[data-theme="light"] dialog { box-shadow: 0 12px 40px rgba(20, 20, 40, .14); }
:root[data-theme="light"] dialog { background: #fff; color: var(--text); border: 1px solid var(--line); }
:root[data-theme="light"] dialog::backdrop { background: rgba(20, 20, 30, .35); }
:root[data-theme="light"] .msg.ai.answer a { color: #b0174a; }
:root[data-theme="light"] .summary { color: #14532d; }
:root[data-theme="light"] .progress-files li.writing { color: #000; }
:root[data-theme="light"] .btn:hover { border-color: #c6c6d0; }
:root[data-theme="light"] .notice.error { background: #fdecee; border-color: #f3b8bf; color: #9b1c2c; }
:root[data-theme="light"] .notice.warn, :root[data-theme="light"] #connect-setup { background: #fff6e0; border-color: #f1d49a; color: #7a4b00; }
:root[data-theme="light"] .notice.error.ok { background: #e9f8ef; border-color: #a7e3bf; color: #14532d; }
:root[data-theme="light"] .preview-stage { background: #e9e9ee; }
:root[data-theme="light"] .code-view .ln { color: #9a9aa8; }
:root[data-theme="light"] .stale { color: #8a5a00; }
:root[data-theme="light"] .copy-btn.copied { color: #15803d; }
:root[data-theme="light"] .badge.error, :root[data-theme="light"] .error-text, :root[data-theme="light"] .users-list .suspended { color: #b4232f; }
:root[data-theme="light"] .image-card img, :root[data-theme="light"] .code-image img { background: repeating-conic-gradient(#ececf1 0% 25%, #f8f8fa 0% 50%) 0 0 / 16px 16px; }
:root[data-theme="light"] .attach-btn:hover:not(:disabled), :root[data-theme="light"] .seo-sev { background: rgba(0, 0, 0, .06); }
:root[data-theme="light"] .attach-chip, :root[data-theme="light"] .kind-card, :root[data-theme="light"] .dw-list code, :root[data-theme="light"] .ns code { background: rgba(0, 0, 0, .04); }
:root[data-theme="light"] .dw-choice { border-color: var(--line); }
:root[data-theme="light"] .attach-chip .spinner { border-color: rgba(0, 0, 0, .15); border-top-color: currentColor; }
:root[data-theme="light"] .seo-issue.high .seo-sev { color: #a3123d; }
:root[data-theme="light"] .seo-issue.medium .seo-sev { color: #8a5a00; }
:root[data-theme="light"] .dw-live .ok, :root[data-theme="light"] .find-table .free, :root[data-theme="light"] .bill-history .plus { color: #15803d; }
:root[data-theme="light"] .dw-live .wait { color: #a16207; }
:root[data-theme="light"] .find-table td { border-top-color: var(--line); }
:root[data-theme="light"] .find-table .taken { color: #8a8a96; }
:root[data-theme="light"] .bill-history .minus { color: #b0174a; }
:root[data-theme="light"] .work-bar { box-shadow: 0 -6px 18px rgba(20, 20, 40, .08); }
:root[data-theme="light"] .linklike { color: #c81d52; }
:root[data-theme="light"] .photo-thumb { background: #eee; }
.admin-new label { margin: 0; font-weight: 600; }
.admin-new input[type="checkbox"] { width: auto; }
.admin-tools input { width: auto; }
.scroll-table > p { margin: 0; padding: 8px 10px; }
.server-box { display: grid; gap: 6px; }
.server-box .notice { margin: 0; }

/* ----- v7.7: Advanced Video Series ----- */
.costs-more { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #fff1d6; color: #8a5a00; font-size: 11px; font-weight: 700; vertical-align: middle; }
.series-dialog { width: min(640px, 94vw); }
.series-dialog fieldset.sd-choice { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; display: grid; gap: 6px; margin: 10px 0; }
.series-dialog fieldset.sd-choice label { display: flex; gap: 8px; align-items: baseline; margin: 0; font-weight: 400; }
.series-dialog fieldset.sd-choice input { width: auto; }
.sd-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sd-row label { display: grid; gap: 4px; }
.sd-estimate { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); display: grid; gap: 8px; }
.sd-estimate > div { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline; }
.sd-estimate > div small { grid-column: 1 / -1; color: var(--muted); }
.sd-estimate b { font-size: 18px; }

/* ----- v7.8: account approval, audit log ----- */
.pending-bar { background: #fff1d6; color: #6b4500; }
.status-tag { font-size: 12px; font-weight: 600; margin-left: 6px; }
.status-tag.pending { color: #8a5a00; }
.status-tag.suspended, .status-tag.revoked { color: #b3261e; }
.signup-mode { display: inline-flex; gap: 6px; align-items: center; margin: 0 8px 0 auto; font-size: 13px; }
.signup-mode select { width: auto; }
.btn-danger { color: #b3261e; border-color: #e7b2ad; }

/* ----- v7.8.1: 6- and 12-month plans ----- */
.bill-plans-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.term-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.term-switch button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font: inherit; font-size: 13px; cursor: pointer; color: inherit; }
.term-switch button.on { background: var(--accent, #c0304f); color: #fff; }
.term-switch button small { opacity: .85; font-weight: 600; margin-left: 4px; }
.bill-card .was { text-decoration: line-through; opacity: .6; }

/* ----- v7.8.5: New project button in the top bar ----- */
.new-project-top { margin-left: auto; white-space: nowrap; flex-shrink: 0; }
@media (max-width: 760px) { .new-project-top { padding-left: .6rem; padding-right: .6rem; } }
