:root {
  --bg: #000;
  --ink: #f2f2f2;
  --muted: #8a8a8a;
  --dim: #555;
  --hair: rgba(255, 255, 255, 0.09);
  --hair-2: rgba(255, 255, 255, 0.16);
  --glass: rgba(8, 8, 8, 0.72);
  --rail: 64px;
  --panel: 300px;
  --body: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.65 var(--body); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono); }
#starfield { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

.app { position: relative; z-index: 1; display: flex; height: 100vh; height: 100dvh; }

/* ---------- Rail ---------- */
.rail {
  width: var(--rail); flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 0; border-right: 1px solid var(--hair); background: rgba(0,0,0,.55); backdrop-filter: blur(12px);
}
.rail-logo { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 14px; }
.rail-logo img { filter: drop-shadow(0 0 8px rgba(255,255,255,.35)); }
.rail-btn {
  position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid transparent; background: none; color: var(--muted); transition: .2s;
}
.rail-btn:hover { color: var(--ink); border-color: var(--hair-2); background: rgba(255,255,255,.04); }
.rail-btn::after {
  content: attr(data-tip); position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; font: 500 .72rem var(--mono); letter-spacing: .06em; padding: 5px 9px; border-radius: 6px;
  background: #fff; color: #000; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.rail-btn:hover::after { opacity: 1; }
.rail-spacer { flex: 1; }
.rail-status { display: grid; place-items: center; width: 40px; height: 40px; }

.pulse { width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 0 rgba(255,255,255,.6); animation: pulse 2.2s infinite; display: inline-block; }
.pulse.off { background: var(--dim); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(255,255,255,0); } 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } }

/* ---------- History panel (slide-over) ---------- */
.panel {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: var(--rail); width: var(--panel);
  display: flex; flex-direction: column; gap: 10px; padding: 18px 14px;
  background: rgba(6,6,6,.96); border-right: 1px solid var(--hair-2); backdrop-filter: blur(18px);
  transform: translateX(calc(-100% - var(--rail))); transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 6px; }
.label { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--hair); border-radius: 8px; color: var(--dim); }
.search:focus-within { border-color: var(--hair-2); }
.search input { flex: 1; min-width: 0; padding: 9px 0; background: none; border: 0; outline: 0; color: var(--ink); font: inherit; font-size: .88rem; }
.search input::placeholder { color: var(--dim); }
.threads { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.group-label { font: .66rem var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); padding: 14px 8px 6px; }
.thread {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 8px;
  border: 0; border-left: 1px solid transparent; background: none; color: var(--muted); font-size: .9rem;
}
.thread::before { content: ""; width: 5px; height: 5px; border: 1px solid var(--dim); border-radius: 50%; flex-shrink: 0; }
.thread:hover { color: var(--ink); background: rgba(255,255,255,.03); }
.thread.active { color: var(--ink); border-left-color: #fff; background: rgba(255,255,255,.05); }
.thread.active::before { background: #fff; border-color: #fff; }
.thread .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread .del { opacity: 0; display: grid; padding: 2px; border-radius: 4px; color: var(--dim); }
.thread:hover .del, .thread.active .del { opacity: 1; }
.thread .del:hover { color: #fff; }
.no-threads { color: var(--dim); font-size: .85rem; padding: 12px 8px; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px 0; border-top: 1px solid var(--hair); font-size: .78rem; color: var(--muted); }
.status { display: flex; align-items: center; gap: 8px; }
.link-btn { background: none; border: 0; color: var(--dim); font-size: .78rem; }
.link-btn:hover { color: #fff; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .28s; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar {
  display: flex; align-items: center; gap: 16px; height: 60px; padding: 0 26px;
  border-bottom: 1px solid var(--hair);
}
.wordmark { font-weight: 600; letter-spacing: .32em; font-size: .9rem; }
.wordmark span { color: var(--dim); margin-left: .5em; }
.title { flex: 1; min-width: 0; text-align: center; color: var(--muted); font-size: .9rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hud-right { display: flex; align-items: center; gap: 16px; }
.hud-clock { font-size: .74rem; letter-spacing: .12em; color: var(--dim); }
.mode { display: flex; border: 1px solid var(--hair-2); border-radius: 8px; overflow: hidden; }
.mode button { border: 0; background: none; padding: 5px 13px; font: 500 .74rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mode button + button { border-left: 1px solid var(--hair-2); }
.mode button[aria-checked="true"] { background: #fff; color: #000; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--ink); }
.icon-btn:hover { background: rgba(255,255,255,.07); }
.only-mobile { display: none; }

/* ---------- Dock (composer area) ---------- */
.dock { position: relative; display: flex; flex-direction: column; align-items: center; padding: 10px 26px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

.orbits { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; display: none; }
.orbits i { position: absolute; left: 0; top: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.06); transform: translate(-50%, -50%); }
.orbits i:nth-child(1) { width: 560px; height: 560px; }
.orbits i:nth-child(2) { width: 820px; height: 820px; border-style: dashed; border-color: rgba(255,255,255,.05); animation: orbit 90s linear infinite; }
.orbits i:nth-child(3) { width: 1120px; height: 1120px; border-color: rgba(255,255,255,.035); }
.orbits i:nth-child(2)::after { content: ""; position: absolute; top: 50%; left: -3px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 12px #fff; }
.orbits i:nth-child(1)::after { content: ""; position: absolute; top: -2px; left: 50%; width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,.7); }
@keyframes orbit { to { transform: translate(-50%, -50%) rotate(360deg); } }

.empty { position: relative; text-align: center; margin-bottom: 30px; }
.kicker { font-size: .74rem; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.empty h1 { margin: 0; font-weight: 300; font-size: clamp(2.4rem, 6vw, 4.2rem); line-height: 1.05; letter-spacing: -.02em; }
.sub { margin: 10px 0 0; color: var(--muted); font-size: 1.1rem; }

.composer {
  position: relative; width: 100%; max-width: 760px; padding: 14px 16px 10px;
  background: var(--glass); border: 1px solid var(--hair-2); border-radius: 4px; backdrop-filter: blur(16px);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: rgba(255,255,255,.35); box-shadow: 0 0 60px rgba(255,255,255,.07); }
.corner { position: absolute; width: 10px; height: 10px; border-color: #fff; border-style: solid; border-width: 0; }
.corner.tl { top: -1px; left: -1px; border-top-width: 1.5px; border-left-width: 1.5px; }
.corner.tr { top: -1px; right: -1px; border-top-width: 1.5px; border-right-width: 1.5px; }
.corner.bl { bottom: -1px; left: -1px; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.corner.br { bottom: -1px; right: -1px; border-bottom-width: 1.5px; border-right-width: 1.5px; }
.composer textarea {
  display: block; width: 100%; resize: none; border: 0; outline: 0; background: none; color: var(--ink);
  font: inherit; font-size: 1.05rem; line-height: 1.5; padding: 2px 0 10px; max-height: 220px;
}
.composer textarea::placeholder { color: var(--dim); }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.meta { font-size: .68rem; letter-spacing: .08em; color: var(--dim); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.send {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border: 0; border-radius: 3px;
  background: #fff; color: #000; font: 600 .74rem var(--mono); letter-spacing: .14em; text-transform: uppercase;
  transition: opacity .2s, transform .15s;
}
.send:hover:not(:disabled) { transform: translateX(2px); }
.send:disabled { opacity: .22; cursor: default; }
.send .i-stop { display: none; }
.send.stop .i-send { display: none; }
.send.stop .i-stop { display: block; }
.send.stop .send-label::after { content: ""; }
.send.stop .send-label { font-size: 0; }
.send.stop .send-label::before { content: "Stop"; font-size: .74rem; }

.suggestions { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; margin-top: 16px; }
.suggestions button {
  display: inline-flex; gap: 6px; padding: 8px 14px; border: 1px solid var(--hair-2); border-radius: 999px;
  background: rgba(0,0,0,.5); font-size: .85rem; color: var(--muted); transition: .2s;
}
.suggestions button:hover { color: #fff; border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.05); }
.suggestions b { color: var(--ink); font-weight: 500; }
.hint { position: relative; margin: 12px 0 0; font-size: .72rem; color: var(--dim); text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .rail { display: none; }
  .only-mobile { display: grid; }
  .panel { left: 0; width: min(86vw, 320px); transform: translateX(-100%); }
  .panel.open { transform: none; }
  .topbar { height: 56px; padding: 0 10px; gap: 8px; }
  .wordmark { flex: 1; text-align: center; font-size: .82rem; }
  .title { display: none; }
  .hud-clock { display: none; }
  .hud-right { gap: 6px; }
  .mode button { padding: 4px 9px; font-size: .68rem; }
  .messages { padding: 18px 16px 12px; }
  .msg { padding: 16px 0; }
  .dock { padding: 8px 12px 12px; }
  .orbits i:nth-child(1) { width: 340px; height: 340px; }
  .orbits i:nth-child(2) { width: 520px; height: 520px; }
  .orbits i:nth-child(3) { width: 720px; height: 720px; }
  .meta { display: none; }
  .composer-row { justify-content: flex-end; }
  .suggestions button:nth-child(n+4) { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }


/* ================= Accounts & billing ================= */
.account { position: relative; }
.account-btn {
  height: 32px; padding: 0 14px; border: 1px solid var(--hair-2); border-radius: 8px; background: none;
  font: 500 .74rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink);
}
.account-btn:hover { border-color: rgba(255,255,255,.4); }
.account-btn.signed-in { width: 32px; padding: 0; border-radius: 50%; background: #fff; color: #000; font: 600 .85rem var(--body); letter-spacing: 0; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 60; width: 270px; padding: 8px;
  background: rgba(10,10,10,.97); border: 1px solid var(--hair-2); border-radius: 10px; backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.account-menu[hidden] { display: none; }
.am-head { padding: 8px 10px 12px; border-bottom: 1px solid var(--hair); }
.am-email { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-plan { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.am-usage { padding: 12px 10px 6px; border-bottom: 1px solid var(--hair); }
.am-usage[hidden] { display: none; }
.meter { margin-bottom: 10px; }
.meter-top { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: 5px; }
.meter-top .mono { font-size: .72rem; color: var(--ink); }
.bar { height: 3px; background: rgba(255,255,255,.1); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: #fff; transition: width .4s; }
.am-note { font-size: .66rem; letter-spacing: .08em; color: var(--dim); margin: 2px 0 4px; }
.am-item { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: .88rem; }
.am-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.am-item[hidden] { display: none; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.72); backdrop-filter: blur(6px); opacity: 0; transition: opacity .2s; }
.modal[hidden] { display: none; }
.modal.open { opacity: 1; }
.modal-card {
  position: relative; width: 100%; max-height: calc(100dvh - 40px); overflow-y: auto; text-align: center;
  background: rgba(8,8,8,.96); border: 1px solid var(--hair-2); border-radius: 6px; padding: 34px 30px 26px;
  transform: translateY(10px) scale(.98); transition: transform .25s cubic-bezier(.2,.8,.2,1);
}
.modal.open .modal-card { transform: none; }
.modal-close { position: absolute; top: 10px; right: 10px; color: var(--muted); }
.modal-logo { filter: drop-shadow(0 0 14px rgba(255,255,255,.35)); margin-bottom: 14px; }
.modal-card h2 { margin: 0 0 18px; font-weight: 300; font-size: 1.8rem; letter-spacing: -.01em; }
.auth-card { max-width: 400px; }
.tabs { display: flex; border: 1px solid var(--hair-2); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.tabs button { flex: 1; padding: 9px; border: 0; background: none; color: var(--muted); font: 500 .74rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.tabs button + button { border-left: 1px solid var(--hair-2); }
.tabs button[aria-selected="true"] { background: #fff; color: #000; }
#authForm { display: flex; flex-direction: column; gap: 12px; text-align: left; }
#authForm label { display: flex; flex-direction: column; gap: 6px; font: .7rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
#authForm input {
  padding: 12px 14px; border: 1px solid var(--hair-2); border-radius: 4px; background: rgba(255,255,255,.03);
  color: var(--ink); font: 1rem var(--body); letter-spacing: 0; text-transform: none; outline: 0;
}
#authForm input:focus { border-color: rgba(255,255,255,.5); }
.form-error { min-height: 1.2em; margin: 0; color: #fff; font-size: .85rem; }
.form-error:not(:empty)::before { content: "⚠ "; }
.btn-primary, .btn-ghost {
  display: block; width: 100%; height: 44px; border-radius: 4px; font: 600 .78rem var(--mono); letter-spacing: .14em; text-transform: uppercase;
  transition: opacity .2s, background .2s;
}
.btn-primary { border: 0; background: #fff; color: #000; }
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-ghost { border: 1px solid var(--hair-2); background: none; color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: rgba(255,255,255,.45); background: rgba(255,255,255,.04); }
.btn-primary:disabled, .btn-ghost:disabled { opacity: .45; cursor: default; }
.fine { margin: 16px 0 0; font-size: .74rem; color: var(--dim); }

/* Plans */
.plans-card { max-width: 920px; }
.plans-sub { color: var(--muted); margin: -8px 0 24px; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: left; }
.plan { position: relative; display: flex; flex-direction: column; padding: 22px 20px 20px; border: 1px solid var(--hair-2); border-radius: 6px; background: rgba(255,255,255,.02); }
.plan.featured { border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.05); box-shadow: 0 0 60px rgba(255,255,255,.06); }
.plan.current { border-style: dashed; }
.badge { position: absolute; top: -10px; left: 20px; padding: 3px 9px; background: #fff; color: #000; font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; border-radius: 3px; }
.plan-name { font-size: .74rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.plan-price { font-size: 2.6rem; font-weight: 300; letter-spacing: -.02em; margin: 6px 0 2px; }
.plan-price span { font-size: .95rem; color: var(--muted); margin-left: 2px; }
.plan-blurb { margin: 0 0 14px; color: var(--muted); font-size: .9rem; }
.plan ul { list-style: none; margin: 0 0 20px; padding: 0; flex: 1; }
.plan li { padding: 7px 0; border-top: 1px solid var(--hair); font-size: .88rem; color: var(--muted); }
.plan li b { color: var(--ink); font-weight: 500; }

/* Toast */
.toast {
  position: fixed; z-index: 120; left: 50%; bottom: 28px; transform: translate(-50%, 20px); max-width: min(92vw, 520px);
  padding: 11px 18px; border-radius: 6px; background: #fff; color: #000; font-size: .9rem; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .plans { grid-template-columns: 1fr; }
  .modal { padding: 12px; align-items: end; }
  .modal-card { padding: 30px 18px 20px; }
  .plans-card h2, .auth-card h2 { font-size: 1.5rem; }
  .account-menu { position: fixed; top: 60px; right: 10px; left: auto; }
  .plan-price { font-size: 2.2rem; }
}
.modal { grid-template-columns: minmax(0, 1fr); justify-items: center; }
#authForm input { width: 100%; min-width: 0; }
.main, .app { overflow: hidden; }
.toast { width: max-content; text-align: center; }
@media (max-width: 820px) { .plan.featured { order: -1; margin-top: 8px; } }

/* ================= Profile ================= */
.rail-avatar.has-user { width: 34px; height: 34px; border-radius: 50%; background: #fff; color: #000; font: 600 .85rem var(--body); border: 0; margin-bottom: 4px; }
.rail-avatar.has-user:hover { background: #ddd; }
.am-strong { color: var(--ink) !important; font-weight: 500; }
.profile-card { max-width: 520px; text-align: left; padding: 30px 28px 24px; }
.pf-head { display: flex; align-items: center; gap: 18px; padding-bottom: 20px; border-bottom: 1px solid var(--hair); }
.pf-avatar { width: 64px; height: 64px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #000; font-size: 1.6rem; font-weight: 600; box-shadow: 0 0 30px rgba(255,255,255,.18); }
.pf-id { min-width: 0; }
.pf-id h2 { margin: 0 0 2px !important; font-size: 1.5rem !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-since { font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-top: 4px; }
.pf-sec { padding: 18px 0; border-bottom: 1px solid var(--hair); }
.pf-sec:last-child { border-bottom: 0; padding-bottom: 0; }
.pf-label { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.pf-row { display: flex; gap: 10px; }
.pf-row input, .pf-stack input {
  flex: 1; min-width: 0; width: 100%; padding: 11px 13px; border: 1px solid var(--hair-2); border-radius: 4px; background: rgba(255,255,255,.03);
  color: var(--ink); font: 1rem var(--body); outline: 0;
}
.pf-row input:focus, .pf-stack input:focus { border-color: rgba(255,255,255,.5); }
.btn-ghost.sm, .btn-primary.sm { width: auto; height: 42px; padding: 0 18px; flex-shrink: 0; }
.pf-plan { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.pf-plan-name { font-size: 1.15rem; font-weight: 500; }
.pf-sub { color: var(--dim); font-size: .82rem; margin: 2px 0 0; }
.pf-link { margin-top: 10px; padding: 0; font-size: .85rem; color: var(--muted); }
.pf-details summary { cursor: pointer; list-style: none; padding: 4px 0; color: var(--ink); font-size: .95rem; }
.pf-details summary::-webkit-details-marker { display: none; }
.pf-details summary::after { content: " +"; color: var(--dim); }
.pf-details[open] summary::after { content: " −"; }
.pf-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.pf-stack .btn-primary.sm { align-self: flex-start; }
.pf-actions { display: flex; flex-direction: column; gap: 14px; }
.pf-actions > .btn-ghost { height: 42px; }
.pf-details.danger summary { color: var(--muted); font-size: .85rem; }
.btn-danger { height: 42px; border: 1px solid rgba(255,255,255,.5); border-radius: 4px; background: transparent; color: #fff; font: 600 .74rem var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.btn-danger:hover { background: #fff; color: #000; }
@media (max-width: 820px) {
  .profile-card { padding: 26px 18px 18px; }
  .pf-avatar { width: 54px; height: 54px; font-size: 1.35rem; }
}

/* =====================================================================
   X09 DOCS
   ===================================================================== */
body { overflow: hidden; }
a { color: inherit; }
.wordmark { text-decoration: none; }
.rail-btn { text-decoration: none; }
.rail-btn.active { color: var(--ink); border-color: var(--hair-2); background: rgba(255,255,255,.06); }
.topbar { position: relative; z-index: 20; background: rgba(0,0,0,.35); backdrop-filter: blur(10px); }
.save-state { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
.topnav { gap: 4px; }
.topnav a { padding: 6px 10px; border-radius: 6px; text-decoration: none; font: 500 .72rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.topnav a.active { color: #000; background: #fff; }

/* ---------- Views ---------- */
.view { display: none; flex: 1; min-height: 0; position: relative; }
body[data-view="home"] .view-home,
body[data-view="docs"] .view-docs { display: block; overflow-y: auto; }
body[data-view="editor"] .view-editor { display: flex; flex-direction: column; }

/* ---------- Home ---------- */
.view-home { overflow-x: hidden; }
.view-home .orbits { display: block; position: absolute; top: 250px; }
.home-inner { position: relative; max-width: 780px; margin: 0 auto; padding: 9vh 26px 60px; }
.empty { margin-bottom: 26px; }
.type-pick { display: flex; justify-content: center; flex-wrap: wrap; gap: 0; width: max-content; max-width: 100%; margin: 0 auto 16px; border: 1px solid var(--hair-2); border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.6); }
.type-pick button { border: 0; background: none; padding: 8px 16px; font: 500 .74rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.type-pick button + button { border-left: 1px solid var(--hair-2); }
.type-pick button[aria-checked="true"] { background: #fff; color: #000; }
.type-pick button:hover:not([aria-checked="true"]) { color: #fff; }
.composer { margin: 0 auto; }
.composer textarea { min-height: 84px; }
.blank-btn { font-size: .8rem; color: var(--muted); padding: 0; }
.suggestions { margin: 16px auto 0; }
.suggestions button { text-align: left; }
.home-recent { margin-top: 56px; }
.home-recent[hidden] { display: none; }
.recent-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 8px; }
.recent-head .link-btn { text-decoration: none; font-size: .8rem; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 16px 18px; border: 1px solid var(--hair-2); border-radius: 6px; background: rgba(8,8,8,.7); backdrop-filter: blur(8px); }
.stat .k { font: .66rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 1.6rem; font-weight: 300; letter-spacing: -.01em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: .78rem; color: var(--dim); }

/* ---------- Document list ---------- */
.docs-inner { max-width: 1040px; margin: 0 auto; padding: 34px 26px 60px; }
.docs-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.docs-top .kicker { margin-bottom: 6px; }
.view-title { margin: 0; font-weight: 300; font-size: 2.2rem; letter-spacing: -.02em; }
a.btn-primary, a.btn-ghost { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 10px; flex-wrap: wrap; }
.seg { display: flex; border: 1px solid var(--hair-2); border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.6); }
.seg button { border: 0; background: none; padding: 7px 13px; font: 500 .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--hair-2); }
.seg button[aria-selected="true"] { background: #fff; color: #000; }
.filters .search { min-width: 240px; background: rgba(0,0,0,.6); }
.doc-list { display: flex; flex-direction: column; }
.doc-row {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) 110px 96px 120px; align-items: center; gap: 14px;
  padding: 13px 14px; border: 1px solid transparent; border-bottom-color: var(--hair); text-decoration: none; color: var(--ink);
  background: rgba(0,0,0,.45); transition: background .15s, border-color .15s;
}
.doc-row:hover { background: rgba(255,255,255,.04); border-color: var(--hair-2); }
.doc-type { font: .66rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.doc-type b { display: block; color: var(--ink); font-weight: 500; letter-spacing: .06em; }
.doc-main { min-width: 0; }
.doc-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-client { font-size: .82rem; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-date { font-size: .8rem; color: var(--muted); }
.doc-amt { text-align: right; font-variant-numeric: tabular-nums; }
.no-docs { padding: 40px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--hair-2); border-radius: 6px; }
.no-docs b { display: block; color: var(--ink); font-weight: 500; font-size: 1.05rem; margin-bottom: 4px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font: 500 .64rem var(--mono); letter-spacing: .1em; text-transform: uppercase; border: 1px solid var(--hair-2); color: var(--muted); white-space: nowrap; justify-self: start; }
.pill.sent { color: var(--ink); border-color: rgba(255,255,255,.45); }
.pill.viewed { color: var(--ink); border-color: #fff; border-style: dashed; }
.pill.accepted, .pill.paid { background: #fff; color: #000; border-color: #fff; }
.pill.declined, .pill.void { text-decoration: line-through; color: var(--dim); }
.pill.overdue { border-color: #fff; color: #fff; box-shadow: 0 0 0 1px #fff inset; }

/* ---------- Editor ---------- */
.ed-bar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--hair); background: rgba(0,0,0,.5); backdrop-filter: blur(10px); flex-shrink: 0; }
.ed-bar > a.icon-btn { text-decoration: none; }
.ed-id { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.ed-num { font-size: .82rem; letter-spacing: .1em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ed-actions { display: flex; align-items: center; gap: 8px; }
.ed-actions .btn-ghost.sm, .ed-actions .btn-primary.sm { height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; font-size: .7rem; }
.sel { height: 36px; padding: 0 30px 0 12px; border: 1px solid var(--hair-2); border-radius: 4px; color: var(--ink); font: 500 .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; appearance: none; -webkit-appearance: none;
  background: rgba(0,0,0,.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='14' height='14'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%23999' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 10px center; }
.sel option { background: #111; color: #eee; }
.more { position: relative; }
.more-menu { width: 220px; }

.ed-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); }
.ed-form { overflow-y: auto; padding: 18px 20px 80px; border-right: 1px solid var(--hair); background: rgba(0,0,0,.72); backdrop-filter: blur(12px); }
.ed-preview { min-width: 0; overflow: hidden; background: rgba(20,20,20,.55); }
.preview-scroll { height: 100%; overflow-y: auto; padding: 30px 28px 80px; }
.preview-scroll .paper { box-shadow: 0 30px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06); }

.lock-banner { margin-bottom: 14px; padding: 12px 14px; border: 1px solid rgba(255,255,255,.45); border-radius: 6px; font-size: .86rem; color: var(--ink); background: rgba(255,255,255,.04); }
.lock-banner button { margin-top: 8px; }
.fs { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.fs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fs-head .label { font-size: .68rem; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fgrid .full { grid-column: 1 / -1; }
.f { display: flex; flex-direction: column; gap: 5px; font: .64rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); min-width: 0; }
.f input, .f textarea, .f select, .item textarea, .item input, .sec input, .sec textarea, .grid-form input, .grid-form textarea, .grid-form select, .link-row input {
  width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--hair-2); border-radius: 4px; background: rgba(255,255,255,.03);
  color: var(--ink); font: .92rem/1.45 var(--body); letter-spacing: 0; text-transform: none; outline: 0; transition: border-color .15s;
}
.f textarea, .sec textarea, .grid-form textarea { resize: vertical; }
.f select, .grid-form select { appearance: none; -webkit-appearance: none; background: rgba(255,255,255,.03) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='14' height='14'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%23999' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 10px center; }
.f select option, .grid-form select option { background: #111; }
input:focus, textarea:focus, select:focus { border-color: rgba(255,255,255,.5) !important; }
input[type="date"] { color-scheme: dark; }
input:disabled, textarea:disabled, select:disabled { opacity: .55; }

.item { position: relative; padding: 10px; border: 1px solid var(--hair); border-radius: 6px; margin-bottom: 8px; background: rgba(255,255,255,.015); }
.item textarea { min-height: 40px; resize: none; overflow: hidden; }
.item-row { display: grid; grid-template-columns: 70px 1fr 1fr 30px; gap: 8px; align-items: center; margin-top: 8px; }
.item-row label { display: flex; flex-direction: column; gap: 3px; font: .58rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.item-amt { text-align: right; font-variant-numeric: tabular-nums; font-size: .92rem; padding-top: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.x-btn { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--dim); margin-top: 14px; }
.x-btn:hover { color: #fff; background: rgba(255,255,255,.07); }
.add-btn { width: 100%; padding: 10px; border: 1px dashed var(--hair-2); border-radius: 6px; background: none; color: var(--muted); font: 500 .72rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.add-btn:hover { color: #fff; border-color: rgba(255,255,255,.4); }
.sum-box { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--hair); border-radius: 6px; font-size: .88rem; }
.sum-box div { display: flex; justify-content: space-between; color: var(--muted); padding: 2px 0; }
.sum-box .grand { color: var(--ink); font-size: 1.05rem; font-weight: 500; border-top: 1px solid var(--hair); margin-top: 6px; padding-top: 8px; }

.sec { padding: 10px; border: 1px solid var(--hair); border-radius: 6px; margin-bottom: 8px; background: rgba(255,255,255,.015); }
.sec input { font-weight: 500; margin-bottom: 8px; }
.sec textarea { min-height: 110px; }
.sec-tools { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.sec-tools .sp { flex: 1; }
.tool { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--dim); font: .66rem var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 5px 8px; border-radius: 6px; }
.tool:hover:not(:disabled) { color: #fff; background: rgba(255,255,255,.06); }
.tool.ai { color: var(--ink); }
.tool:disabled { opacity: .4; cursor: default; }
.ai-row { display: flex; justify-content: flex-end; margin-top: 4px; }

.ed-tabs { display: none; border-bottom: 1px solid var(--hair); }
.ed-tabs button { flex: 1; padding: 10px; border: 0; background: none; color: var(--muted); font: 500 .72rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.ed-tabs button[aria-selected="true"] { color: #000; background: #fff; }

/* ---------- Working overlay ---------- */
.working { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; background: rgba(0,0,0,.78); backdrop-filter: blur(8px); }
.working[hidden] { display: none; }
.working-card { text-align: center; padding: 20px; }
.working-orbit { position: relative; width: 120px; height: 120px; margin: 0 auto 22px; display: grid; place-items: center; }
.working-orbit i { position: absolute; inset: 0; border: 1px dashed rgba(255,255,255,.3); border-radius: 50%; animation: spin 6s linear infinite; }
.working-orbit i::after { content: ""; position: absolute; top: -4px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: #fff; box-shadow: 0 0 14px #fff; }
.working-orbit img { filter: drop-shadow(0 0 14px rgba(255,255,255,.4)); }
.working-text { margin: 0; font-size: 1.3rem; font-weight: 300; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Business settings / send ---------- */
.biz-card { max-width: 640px; text-align: left; }
.biz-card h2, .biz-card .kicker, .biz-card .plans-sub { text-align: left; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-form .full { grid-column: 1 / -1; }
.grid-form label { display: flex; flex-direction: column; gap: 6px; font: .64rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.hint-inline { text-transform: none; letter-spacing: 0; font: .78rem var(--body); color: var(--dim); }
.logo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-box { width: 132px; height: 64px; display: grid; place-items: center; border: 1px dashed var(--hair-2); border-radius: 6px; background: #fff; overflow: hidden; }
.logo-box span { color: #999; font: .7rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-btns { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; height: 38px !important; }
.color-pick { margin-left: auto; flex-direction: row !important; align-items: center; gap: 10px !important; }
.color-pick input { width: 44px !important; height: 34px; padding: 2px !important; cursor: pointer; }
.send-card { max-width: 520px; }
.link-row { display: flex; gap: 8px; }
.link-row input { font: .82rem var(--mono); }
.send-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.send-opts .btn-ghost { height: 42px; }
.send-opts [hidden] { display: none; }

/* ---------- Plans (AI line) ---------- */
.plan li b { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .ed-body { grid-template-columns: minmax(330px, 400px) minmax(0, 1fr); }
  .preview-scroll { padding: 20px 16px 60px; }
}
@media (max-width: 820px) {
  .topbar .title { display: none; }
  .wordmark { flex: 0 0 auto; text-align: left; }
  .topnav { display: flex; flex: 1; justify-content: center; }
  .home-inner { padding: 6vh 16px 40px; }
  .type-pick { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .type-pick button { padding: 9px 6px; }
  .type-pick button + button { border-left: 0; }
  .type-pick button:nth-child(even) { border-left: 1px solid var(--hair-2); }
  .type-pick button:nth-child(n+3) { border-top: 1px solid var(--hair-2); }
  .suggestions button:nth-child(n+3) { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:first-child { grid-column: 1 / -1; }
  .docs-inner { padding: 22px 16px 60px; }
  .view-title { font-size: 1.7rem; }
  .filters { flex-direction: column; align-items: stretch; }
  .seg { overflow-x: auto; }
  .filters .search { min-width: 0; }
  .doc-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main amt" "type status"; gap: 6px 12px; padding: 12px; }
  .doc-row .doc-main { grid-area: main; }
  .doc-row .doc-amt { grid-area: amt; }
  .doc-row .doc-type { grid-area: type; }
  .doc-row .pill { grid-area: status; justify-self: end; }
  .doc-row .doc-date { display: none; }
  .doc-type b { display: inline; margin-right: 6px; }
  .ed-bar { padding: 0 8px; gap: 6px; }
  .ed-actions { gap: 6px; }
  .ed-actions .sel { width: 96px; padding-right: 22px; }
  .ed-actions .btn-ghost.sm span { display: none; }
  .ed-actions .btn-ghost.sm, .ed-actions .btn-primary.sm { padding: 0 11px; }
  .ed-tabs { display: flex; }
  .ed-body { display: block; overflow: hidden; }
  .ed-body[data-edtab="form"] .ed-preview { display: none; }
  .ed-body[data-edtab="preview"] .ed-form { display: none; }
  .ed-form, .ed-preview { height: 100%; border-right: 0; }
  .ed-form { padding: 14px 14px 80px; }
  .preview-scroll { padding: 12px 8px 60px; }
  .grid-form { grid-template-columns: 1fr; }
  .color-pick { margin-left: 0; }
  .ed-num { font-size: .72rem; }
  .ed-kind { display: none; }
  .ed-id .pill { display: none; }
  .save-state { display: none; }
}
@media (max-width: 420px) { .ed-id .pill { display: none; } #edSend span { display: none; } }
