:root {
  --bg: #101214;
  --bg-soft: #171a1d;
  --panel: #1b1f22;
  --panel-light: #23282c;
  --line: #343a3f;
  --line-soft: #292e32;
  --text: #f1f0ec;
  --muted: #9a9fa0;
  --muted-strong: #c3c5c1;
  --accent: #ff7952;
  --accent-dark: #c95638;
  --success: #9ed7a6;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.19);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
}

button, input, textarea, select { font: inherit; }
button, select, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .035;
  z-index: 9;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E");
}

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.view-shell { position: relative; z-index: 1; width: min(1400px, 100%); margin: 0 auto; padding: 18px; }
.auth-view { display: grid; gap: 34px; min-height: 100dvh; align-content: center; padding-top: 42px; padding-bottom: 42px; }
.dashboard-view { min-height: 100dvh; padding-top: 18px; padding-bottom: 28px; }

.brand-lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-decoration: none; }
.brand-mark { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--accent); color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; letter-spacing: -.08em; }
.eyebrow, .section-kicker, .field-label, .panel-topline, .footer-bar, .status-label, .counter { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-transform: uppercase; letter-spacing: .16em; }
.eyebrow { margin: 44px 0 12px; color: var(--accent); font-size: 10px; font-weight: 700; }
.auth-intro h1, .dashboard-hero h1 { margin: 0; color: var(--text); font-size: clamp(2.7rem, 12vw, 5.7rem); font-weight: 660; letter-spacing: -.065em; line-height: .96; }
.auth-intro h1 span, .dashboard-hero h1 span { color: var(--accent); }
.intro-copy, .hero-note { max-width: 34rem; margin: 24px 0 0; color: var(--muted); font-size: 15px; line-height: 1.75; }

.signal-card { display: grid; gap: 0; max-width: 390px; margin-top: 34px; border-top: 1px solid var(--line); }
.signal-row { display: grid; grid-template-columns: 13px 1fr auto; align-items: center; gap: 10px; min-height: 42px; border-bottom: 1px solid var(--line-soft); color: var(--muted-strong); font-size: 12px; }
.signal-row strong { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-weight: 500; letter-spacing: .08em; }
.signal-dot, .state-dot, .status-light { display: inline-block; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(255, 121, 82, .11); }
.signal-dot.muted { background: #6a7275; box-shadow: none; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.auth-panel { width: 100%; max-width: 520px; padding: 22px; }
.panel-topline { display: flex; justify-content: space-between; color: #777e80; font-size: 9px; }
.auth-tabs { display: flex; gap: 20px; margin-top: 30px; border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 0 0 13px; border: 0; background: none; color: var(--muted); font-size: 14px; }
.tab.active { color: var(--text); }
.tab.active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); content: ""; }
.auth-heading { margin: 28px 0 24px; }
.section-kicker { margin: 0 0 10px; color: var(--accent); font-size: 10px; }
.auth-heading h2, .section-heading h2 { margin: 0; color: var(--text); font-size: clamp(1.5rem, 5vw, 2rem); letter-spacing: -.04em; line-height: 1.1; }
.auth-heading p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.form-stack { display: grid; gap: 17px; }
.field { display: grid; gap: 8px; }
.field > span, .field-label { color: var(--muted-strong); font-size: 11px; font-weight: 650; letter-spacing: .02em; }
.field > span small { color: #747b7c; font-size: 10px; font-weight: 400; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid #3a4145;
  border-radius: 11px;
  outline: none;
  background: #15181a;
  color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field input, .field select { min-height: 47px; padding: 0 14px; }
.field textarea { min-height: 128px; padding: 13px 14px; resize: vertical; line-height: 1.6; }
.field input::placeholder, .field textarea::placeholder { color: #777e80; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); background: #191c1e; box-shadow: 0 0 0 3px rgba(255, 121, 82, .13); }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #a5aaa9 50%), linear-gradient(135deg, #a5aaa9 50%, transparent 50%); background-position: calc(100% - 17px) 21px, calc(100% - 12px) 21px; background-repeat: no-repeat; background-size: 5px 5px, 5px 5px; }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 13px; border: 1px solid transparent; border-radius: 999px; padding: 0 17px; font-size: 12px; font-weight: 750; letter-spacing: .01em; transition: transform .16s ease, background .16s ease, border-color .16s ease, color .16s ease; }
.button:active { transform: translateY(1px) scale(.985); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { background: var(--accent); color: #1d100c; }
.button-primary:hover { background: #ff8d6b; }
.button-wide { width: 100%; margin-top: 4px; }
.button-quiet { border-color: var(--line); background: transparent; color: var(--muted-strong); }
.button-quiet:hover { border-color: var(--accent); color: var(--text); }
.form-note { margin: 18px 0 0; color: #747b7c; font-size: 11px; line-height: 1.6; }

.topbar { display: flex; min-height: 52px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); }
.topbar-actions { display: flex; align-items: center; gap: 17px; }
.status-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; letter-spacing: .1em; }
.status-light { width: 6px; height: 6px; box-shadow: none; }
.status-label.online { color: var(--success); }
.status-label.online .status-light { background: var(--success); }
.status-label.offline .status-light { background: #e36a57; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.text-button:hover { color: var(--text); }
.dashboard-hero { display: grid; gap: 26px; align-items: end; padding: 52px 0 32px; }
.dashboard-hero .eyebrow { margin: 0 0 12px; }
.dashboard-hero h1 { font-size: clamp(2.6rem, 13vw, 6rem); }
.hero-note { margin: 0; max-width: 280px; justify-self: start; }

.device-strip { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: #15181a; }
.device-orb { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid #51595b; border-radius: 50%; background: #202528; }
.device-orb .signal-dot { width: 10px; height: 10px; }
.device-meta { min-width: 0; display: grid; gap: 3px; }
.device-meta select { width: 100%; padding: 0 22px 0 0; border: 0; outline: 0; appearance: none; background: transparent; color: var(--text); font-size: 15px; font-weight: 680; text-overflow: ellipsis; }
.device-meta code { overflow: hidden; color: #858d8e; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-overflow: ellipsis; }
.device-state { grid-column: 1 / -1; display: grid; grid-template-columns: 10px auto 1fr; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.state-dot { width: 7px; height: 7px; background: #737b7c; box-shadow: none; }
.device-state strong { color: var(--muted-strong); font-size: 11px; }
.device-state small { overflow: hidden; color: #777e80; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.device-strip > .button { grid-column: 1 / -1; width: 100%; }
.device-strip.empty .device-orb .signal-dot { background: #737b7c; box-shadow: none; }
.device-strip.online .state-dot { background: var(--success); box-shadow: 0 0 0 4px rgba(158, 215, 166, .1); }
.device-strip.online .device-state strong { color: var(--success); }
.device-strip.offline .state-dot { background: #e36a57; }
.device-strip.offline .device-state strong { color: #e78979; }

.bind-panel { display: grid; gap: 16px; margin-top: 10px; padding: 16px; border: 1px dashed #4b5355; border-radius: var(--radius); background: #171a1c; }
.bind-panel p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.bind-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.field.compact { gap: 0; }
.field.compact input { min-height: 44px; }

.workspace-grid { display: grid; gap: 50px; margin-top: 54px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { font-size: 1.45rem; }
.section-index { color: #687073; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.compose-card { display: grid; gap: 19px; padding: 17px; }
.image-lab { display: grid; gap: 14px; padding-top: 4px; border-top: 1px solid var(--line-soft); }
.image-lab-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.image-lab-heading h3 { margin: 0; color: var(--text); font-size: 1.05rem; letter-spacing: -.025em; }
.image-lab-heading p:last-child { max-width: 420px; margin: 7px 0 0; color: #858d8e; font-size: 11px; line-height: 1.55; }
.image-lab-mark { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; letter-spacing: -.05em; }
.image-lab-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.image-lab-footer > span { color: #777e80; font-size: 10px; }
.image-lab-footer .button { min-width: 126px; }
.attachment-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.upload-control { display: inline-flex; min-height: 40px; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted-strong); font-size: 12px; }
.upload-control:hover { border-color: var(--accent); color: var(--text); }
.upload-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-glyph { color: var(--accent); font-size: 18px; font-weight: 300; line-height: 1; }
.upload-note { color: #777e80; font-size: 10px; }
.image-preview { display: grid; grid-template-columns: 56px 1fr auto; gap: 11px; align-items: center; min-width: 0; padding: 8px; border: 1px solid var(--line-soft); border-radius: 12px; background: #15181a; }
.image-preview img { width: 56px; height: 42px; border-radius: 7px; object-fit: cover; background: #282d2f; }
.image-preview.generated { grid-template-columns: 120px 1fr auto; }
.image-preview.generated img { width: 120px; height: 90px; border-radius: 9px; }
.image-preview div { display: grid; gap: 4px; min-width: 0; }
.image-preview strong { overflow: hidden; color: var(--muted-strong); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.image-preview small { color: #777e80; font-size: 10px; }
.icon-button { width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; }
.icon-button:hover { background: #2a3033; color: var(--text); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compose-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 3px; }
.counter { color: #6f7778; font-size: 9px; letter-spacing: .08em; }
.compose-footer .button { min-width: 150px; }

.activity-section { min-width: 0; }
.activity-list { display: grid; gap: 1px; min-height: 140px; border-top: 1px solid var(--line); }
.empty-state { display: grid; align-content: center; justify-items: start; min-height: 140px; color: #737b7c; }
.empty-line { display: block; width: 35px; height: 1px; margin-bottom: 15px; background: var(--accent); }
.empty-state p { max-width: 230px; margin: 0; font-size: 12px; line-height: 1.6; }
.activity-item { display: grid; grid-template-columns: 9px 1fr auto; gap: 11px; align-items: start; padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.activity-item .signal-dot { width: 6px; height: 6px; margin-top: 5px; box-shadow: none; }
.activity-item strong { display: block; overflow: hidden; color: var(--muted-strong); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.activity-item p { overflow: hidden; margin: 5px 0 0; color: #858d8e; font-size: 11px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.activity-item time { color: #687073; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; white-space: nowrap; }
.capability-note { display: grid; grid-template-columns: 9px 1fr; gap: 11px; align-items: start; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.capability-note .signal-dot { margin-top: 5px; width: 6px; height: 6px; box-shadow: none; }
.capability-note p { margin: 0; color: #777e80; font-size: 11px; line-height: 1.6; }
.footer-bar { display: flex; justify-content: space-between; gap: 12px; margin-top: 70px; padding-top: 15px; border-top: 1px solid var(--line-soft); color: #626a6c; font-size: 8px; letter-spacing: .1em; }

.toast { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); left: 18px; z-index: 10; display: none; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #24292c; box-shadow: var(--shadow); color: var(--text); font-size: 12px; line-height: 1.45; }
.toast.show { display: block; animation: toast-in .22s ease-out both; }
.toast.error { border-color: #a75547; color: #ffd0c8; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 679px) {
  .view-shell {
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  .auth-view {
    align-content: start;
    gap: 28px;
    padding-top: max(28px, env(safe-area-inset-top));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .auth-intro .eyebrow { margin-top: 32px; }
  .auth-intro h1 { font-size: clamp(2.55rem, 14vw, 4.2rem); }
  .intro-copy { margin-top: 18px; font-size: 14px; line-height: 1.65; }
  .signal-card { margin-top: 24px; }
  .auth-panel { padding: 18px; border-radius: 16px; }
  .auth-heading { margin: 22px 0 20px; }
  .field input, .field select { min-height: 50px; }
  .field textarea { min-height: 116px; }

  .dashboard-view { padding-top: max(12px, env(safe-area-inset-top)); }
  .topbar { min-height: 46px; }
  .topbar-actions { gap: 12px; }
  .status-label { max-width: 105px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dashboard-hero { gap: 16px; padding: 36px 0 24px; }
  .dashboard-hero h1 { font-size: clamp(2.55rem, 14vw, 4.5rem); }
  .hero-note { font-size: 13px; line-height: 1.6; }

  .device-strip { grid-template-columns: 42px minmax(0, 1fr); gap: 12px; padding: 13px; }
  .device-orb { width: 42px; height: 42px; }
  .device-state { grid-column: 1 / -1; padding-top: 11px; }
  .workspace-grid { gap: 38px; margin-top: 36px; }
  .compose-card { gap: 17px; padding: 15px; }
  .image-lab-heading { gap: 12px; }
  .image-lab-heading p:last-child { font-size: 10px; }
  .image-lab-footer { align-items: stretch; flex-direction: column; }
  .image-lab-footer .button { width: 100%; }
  .image-preview.generated { grid-template-columns: 92px 1fr auto; }
  .image-preview.generated img { width: 92px; height: 70px; }
  .choice-grid { gap: 8px; }
  .compose-footer { align-items: stretch; }
  .compose-footer .button { min-width: 0; flex: 1; }
  .footer-bar { align-items: flex-start; flex-direction: column; margin-top: 50px; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .view-shell { padding-right: 12px; padding-left: 12px; }
  .brand-lockup { gap: 8px; font-size: 10px; }
  .topbar-actions { gap: 8px; }
  .status-label { max-width: 88px; font-size: 8px; letter-spacing: .06em; }
  .compose-footer { flex-direction: column; }
  .compose-footer .button { width: 100%; }
  .counter { align-self: flex-end; }
}

@media (min-width: 680px) {
  .view-shell { padding-right: 34px; padding-left: 34px; }
  .auth-view { grid-template-columns: minmax(0, 1fr) minmax(360px, 520px); gap: clamp(36px, 8vw, 130px); }
  .auth-intro { align-self: center; }
  .auth-panel { justify-self: end; }
  .dashboard-hero { grid-template-columns: minmax(0, 1fr) 280px; }
  .hero-note { justify-self: end; padding-bottom: 5px; }
  .device-strip { grid-template-columns: auto minmax(180px, 1fr) auto auto; gap: 16px; }
  .device-state { grid-column: auto; min-width: 190px; padding: 0 0 0 16px; border-top: 0; border-left: 1px solid var(--line-soft); }
  .device-strip > .button { grid-column: auto; width: auto; }
  .bind-panel { grid-template-columns: 1fr minmax(300px, 430px); align-items: center; }
  .workspace-grid { grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: clamp(36px, 7vw, 110px); align-items: start; }
  .compose-card { padding: 24px; }
  .toast { right: 34px; bottom: 34px; left: auto; width: min(360px, calc(100vw - 68px)); }
}

@media (min-width: 1040px) {
  .view-shell { padding-right: 70px; padding-left: 70px; }
  .auth-view { padding-top: 70px; padding-bottom: 70px; }
  .dashboard-view { padding-top: 22px; }
  .dashboard-hero { padding-top: 90px; padding-bottom: 45px; }
  .workspace-grid { margin-top: 74px; }
}

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