:root {
  --ink: #102029;
  --ink-soft: #263b45;
  --paper: #f1eee3;
  --paper-deep: #e5e0d2;
  --cream: #fbfaf5;
  --acid: #d8ff57;
  --acid-deep: #b8e529;
  --coral: #f05a3c;
  --sea: #0c6b66;
  --sea-light: #d7ebe5;
  --line: rgba(16, 32, 41, 0.14);
  --muted: #63747a;
  --shadow: 0 26px 70px rgba(16, 32, 41, 0.14);
  --font-display: "Iowan Old Style", "Songti SC", "STSong", Georgia, serif;
  --font-body: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 8% 10%, rgba(216, 255, 87, 0.3), transparent 24rem),
    radial-gradient(circle at 92% 14%, rgba(240, 90, 60, 0.14), transparent 28rem),
    linear-gradient(135deg, #f5f2e9 0%, var(--paper) 55%, #e7e4d8 100%);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(16, 32, 41, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 32, 41, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent 82%);
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(240, 90, 60, 0.34);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.page-noise {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.025;
  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='.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px 4px 12px 4px;
  background: var(--ink);
  color: var(--acid);
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  transform: rotate(-2deg);
  box-shadow: 5px 5px 0 var(--coral);
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.1; }
.brand-copy strong { font-size: 16px; letter-spacing: 0.02em; }
.brand-copy small { margin-top: 5px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 0.18em; }
.brand-lockup.compact .brand-mark { width: 34px; height: 34px; font-size: 21px; box-shadow: 4px 4px 0 var(--coral); }
.brand-lockup.compact .brand-copy strong { font-size: 14px; }

.eyebrow {
  margin: 0 0 9px;
  color: var(--sea);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(390px, 0.88fr);
  min-height: 100vh;
}
.auth-story {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  padding: 7vh clamp(38px, 7vw, 110px) 6vh;
}
.auth-story::after {
  content: "01";
  position: absolute;
  right: -0.04em;
  bottom: -0.23em;
  z-index: -1;
  color: rgba(16, 32, 41, 0.045);
  font-family: var(--font-display);
  font-size: clamp(18rem, 38vw, 38rem);
  font-weight: 700;
  line-height: 0.8;
}
.auth-story .brand-lockup { position: absolute; top: 40px; left: clamp(38px, 7vw, 110px); }
.auth-story > .eyebrow { margin-top: clamp(60px, 13vh, 130px); animation: rise-in 0.65s ease both; }
.auth-story h1 {
  max-width: 740px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 7.2vw, 7.2rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.91;
  animation: rise-in 0.75s 0.05s ease both;
}
.auth-story h1 em { color: var(--coral); font-weight: 500; }
.auth-lede {
  max-width: 570px;
  margin: 28px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.85;
  animation: rise-in 0.75s 0.12s ease both;
}
.auth-steps {
  display: flex;
  gap: 0;
  max-width: 680px;
  margin: 42px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  animation: rise-in 0.75s 0.2s ease both;
}
.auth-steps li { display: flex; gap: 12px; flex: 1; padding: 18px 20px 0 0; }
.auth-steps li + li { padding-left: 20px; border-left: 1px solid var(--line); }
.auth-steps li > span { color: var(--coral); font-family: var(--font-display); font-size: 13px; }
.auth-steps div { display: flex; flex-direction: column; gap: 5px; }
.auth-steps strong { font-size: 12px; }
.auth-steps small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.auth-footnote { margin-top: auto; padding-top: 48px; color: var(--muted); font-size: 10px; letter-spacing: 0.08em; }

.auth-card-wrap {
  display: grid;
  place-items: center;
  padding: 36px;
  background:
    linear-gradient(150deg, rgba(16, 32, 41, 0.96), rgba(12, 55, 58, 0.96)),
    var(--ink);
  border-left: 1px solid rgba(255,255,255,0.08);
}
.auth-card {
  width: min(100%, 430px);
  padding: clamp(30px, 5vw, 52px);
  background: var(--cream);
  border-radius: 24px 6px 24px 6px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.3), 10px 10px 0 rgba(216, 255, 87, 0.2);
  animation: card-in 0.75s 0.12s cubic-bezier(.2,.75,.25,1) both;
}
.auth-card-heading { display: flex; align-items: center; gap: 16px; margin-bottom: 36px; }
.auth-card-heading h2, .section-heading h2, .identity-card h2 { margin: 0; font-family: var(--font-display); font-weight: 500; letter-spacing: -0.03em; }
.auth-card-heading h2 { font-size: 36px; }
.status-orbit { position: relative; width: 46px; height: 46px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; }
.status-orbit::before, .status-orbit::after { content: ""; position: absolute; border-radius: 50%; }
.status-orbit::before { inset: 9px; background: var(--acid); box-shadow: 0 0 0 7px rgba(216,255,87,0.2); animation: orbit-pulse 2.2s ease-in-out infinite; }
.status-orbit::after { width: 5px; height: 5px; top: 0; right: 4px; background: var(--coral); }

.field-label { display: block; margin: 18px 0 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.05em; }
.text-field {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(16, 32, 41, 0.18);
  border-radius: 10px;
  transition: border-color .18s, box-shadow .18s;
}
.text-field:focus { border-color: var(--sea); box-shadow: 0 0 0 4px rgba(12, 107, 102, 0.1); outline: 0; }
.password-field { position: relative; }
.password-field .text-field { padding-right: 64px; }
.text-button { position: absolute; top: 50%; right: 13px; transform: translateY(-50%); padding: 5px; border: 0; color: var(--sea); background: transparent; font-size: 11px; font-weight: 700; cursor: pointer; }
.form-message { min-height: 22px; margin: 10px 0 4px; color: #b62e21; font-size: 12px; line-height: 1.5; }
.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
  background: var(--acid);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.primary-button:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.primary-button:disabled { opacity: 0.55; cursor: wait; }
.primary-button b { font-size: 20px; }
.security-note { margin: 20px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; text-align: center; }

.app-shell { position: relative; z-index: 1; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 68px;
  padding: 10px clamp(18px, 3vw, 42px);
  background: rgba(241, 238, 227, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.connection-chip { display: flex; align-items: center; gap: 8px; padding: 8px 13px; color: var(--muted); background: rgba(255,255,255,0.52); border: 1px solid var(--line); border-radius: 999px; font-size: 10px; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #a7aaa4; box-shadow: 0 0 0 4px rgba(167,170,164,0.14); }
.connection-chip.live { color: var(--sea); border-color: rgba(12,107,102,0.24); }
.connection-chip.live .connection-dot { background: #19a88f; box-shadow: 0 0 0 4px rgba(25,168,143,0.14); animation: soft-pulse 1.8s infinite; }
.connection-chip.offline .connection-dot { background: var(--coral); box-shadow: 0 0 0 4px rgba(240,90,60,0.13); }
.topbar-right { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip div { display: flex; flex-direction: column; gap: 2px; }
.user-chip strong { font-size: 11px; }
.user-chip small { color: var(--muted); font-size: 9px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--acid); background: var(--ink); font-family: var(--font-display); font-size: 14px; }
.icon-button { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,0.48); font-weight: 700; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.icon-button:hover { background: #fff; border-color: rgba(16,32,41,0.3); }
.subtle-text-button { width: auto; color: var(--muted); background: transparent; font-size: 10px; }
.danger-hover:hover { color: #a62b1f; border-color: rgba(240,90,60,0.5); background: #fff2ef; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 22px;
  max-width: 1760px;
  margin: 0 auto;
  padding: 22px clamp(16px, 3vw, 42px) 34px;
}
.stage-panel { min-width: 0; background: var(--ink); border-radius: 18px 5px 18px 5px; box-shadow: var(--shadow); overflow: hidden; animation: rise-in .55s ease both; }
.stage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px; padding: 8px 12px 8px 16px; color: #dce4df; border-bottom: 1px solid rgba(255,255,255,0.09); }
.stage-address { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 10px; }
.stage-address span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #65737a; }
.live-dot.active { background: var(--acid); box-shadow: 0 0 0 4px rgba(216,255,87,0.1); }
.toolbar-actions { display: flex; gap: 6px; }
.stage-toolbar .icon-button { color: #dce4df; border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.05); }
.stage-toolbar .icon-button:hover { color: #fff; background: rgba(255,255,255,0.12); }
.browser-stage { position: relative; aspect-ratio: 1366 / 900; min-height: 260px; overflow: hidden; background: #0a1115; cursor: default; }
.browser-stage:focus { outline: 0; }
#browserImage { display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px; color: #e9eee9; text-align: center; background: radial-gradient(circle at 50% 35%, rgba(12,107,102,0.3), transparent 44%), #0a1115; }
.empty-kicker { color: var(--acid); font-size: 9px; font-weight: 800; letter-spacing: 0.2em; }
.stage-empty h2 { margin: 14px 0 8px; font-family: var(--font-display); font-size: clamp(25px, 3vw, 42px); font-weight: 500; }
.stage-empty p { max-width: 430px; margin: 0 0 22px; color: #91a0a6; font-size: 12px; line-height: 1.7; }
.outline-button { min-height: 42px; padding: 0 18px; color: var(--ink); background: var(--acid); border: 1px solid var(--acid); border-radius: 8px; font-size: 11px; font-weight: 800; cursor: pointer; }
.outline-button:hover { background: #e4ff8c; }
.frame-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #d2dad7; background: rgba(10,17,21,0.82); font-size: 11px; }
.frame-loading span { width: 28px; height: 28px; border: 2px solid rgba(255,255,255,0.15); border-top-color: var(--acid); border-radius: 50%; animation: spin .8s linear infinite; }
.frame-loading p { margin: 0; }
.stage-caption { display: flex; justify-content: space-between; gap: 20px; padding: 11px 16px; color: #75858b; font-size: 9px; }

.control-rail { display: flex; flex-direction: column; gap: 14px; min-width: 0; animation: rise-in .55s .08s ease both; }
.identity-card, .workflow-card, .input-card, .notice-card { background: rgba(251,250,245,0.88); border: 1px solid rgba(16,32,41,0.12); box-shadow: 0 12px 35px rgba(16,32,41,0.06); backdrop-filter: blur(10px); }
.identity-card { display: grid; grid-template-columns: 1fr auto; align-items: start; padding: 19px 20px; border-radius: 14px 4px 14px 4px; }
.identity-card h2 { font-size: 27px; }
.slot-badge { padding: 6px 9px; color: var(--sea); border: 1px solid rgba(12,107,102,0.22); border-radius: 999px; background: var(--sea-light); font-size: 8px; font-weight: 800; letter-spacing: 0.08em; }
.identity-status { grid-column: 1 / -1; display: flex; align-items: center; gap: 7px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.identity-status > span { width: 6px; height: 6px; border-radius: 50%; background: #a1aaa7; }
.identity-status > span.running { background: #19a88f; box-shadow: 0 0 0 4px rgba(25,168,143,0.12); }
.workflow-card { padding: 20px; border-radius: 14px 4px 14px 4px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 13px; }
.section-heading h2 { font-size: 25px; }
.section-heading.small h2 { font-size: 21px; }
.step-counter { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: 0.12em; }
.workflow-step { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 12px 10px; text-align: left; border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; transition: padding .15s, background .15s; }
.workflow-step:hover { padding-left: 14px; background: rgba(216,255,87,0.2); }
.workflow-step:disabled { opacity: .55; cursor: wait; }
.workflow-step.upload-step { margin-top: 5px; border: 1px solid var(--ink); border-radius: 9px; background: var(--acid); box-shadow: 3px 3px 0 var(--ink); }
.workflow-step.upload-step:hover { background: #e4ff8c; }
.workflow-step.secondary-step { margin-top: 8px; border-bottom: 1px solid var(--line); }
.step-number { color: var(--coral); font-family: var(--font-display); font-size: 13px; }
.step-copy { display: flex; flex-direction: column; gap: 4px; }
.step-copy strong { font-size: 11px; }
.step-copy small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.step-arrow { font-size: 16px; font-weight: 700; }
.workflow-warning { margin: 14px 0 0; padding: 10px; color: #6e4a3e; background: #fff0e9; border-left: 2px solid var(--coral); font-size: 9px; line-height: 1.65; }
.upload-progress { padding: 12px 4px 8px; }
.upload-progress > div:first-child { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 9px; }
.progress-track { height: 5px; overflow: hidden; background: rgba(16,32,41,0.1); border-radius: 99px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--sea), var(--acid-deep)); border-radius: inherit; transition: width .2s; }
.input-card { padding: 18px 20px; border-radius: 14px 4px 14px 4px; }
.input-card textarea { width: 100%; resize: vertical; min-height: 72px; padding: 11px 12px; color: var(--ink); background: #fff; border: 1px solid rgba(16,32,41,0.16); border-radius: 8px; font-size: 11px; line-height: 1.6; }
.input-card textarea:focus { border-color: var(--sea); outline: 0; box-shadow: 0 0 0 3px rgba(12,107,102,0.09); }
.input-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.primary-button.small-button { width: auto; min-height: 34px; padding: 0 13px; box-shadow: 2px 2px 0 var(--ink); font-size: 10px; }
.key-cluster { display: flex; gap: 5px; }
.key-cluster button { min-height: 30px; padding: 0 8px; color: var(--ink-soft); background: #fff; border: 1px solid var(--line); border-radius: 6px; font-size: 9px; cursor: pointer; }
.notice-card { display: flex; gap: 10px; padding: 13px 15px; color: var(--muted); border-radius: 10px; font-size: 9px; line-height: 1.65; }
.notice-icon { display: grid; place-items: center; width: 18px; height: 18px; flex: 0 0 auto; color: var(--ink); border-radius: 50%; background: var(--acid); font-family: var(--font-display); font-weight: 700; }
.notice-card p { margin: 0; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 40px)); }
.toast { padding: 12px 14px; color: #eef3ef; background: var(--ink); border: 1px solid rgba(255,255,255,0.12); border-left: 4px solid var(--acid); border-radius: 8px; box-shadow: 0 16px 40px rgba(0,0,0,0.25); font-size: 11px; line-height: 1.55; animation: toast-in .25s ease both; }
.toast.error { border-left-color: var(--coral); }
.toast.leaving { animation: toast-out .22s ease both; }
.browser-stage:fullscreen { width: 100vw; height: 100vh; aspect-ratio: auto; background: #000; }
.browser-stage:fullscreen #browserImage { width: auto; height: 100%; max-width: 100%; margin: 0 auto; }

@keyframes rise-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes card-in { from { opacity: 0; transform: translateY(22px) rotate(0.5deg); } to { opacity: 1; transform: translateY(0) rotate(0); } }
@keyframes orbit-pulse { 0%,100% { transform: scale(.88); opacity: .8; } 50% { transform: scale(1); opacity: 1; } }
@keyframes soft-pulse { 50% { box-shadow: 0 0 0 7px rgba(25,168,143,0.05); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr); }
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
  .stage-caption span:last-child { display: none; }
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-story { min-height: 62vh; padding: 100px 28px 45px; }
  .auth-story .brand-lockup { top: 28px; left: 28px; }
  .auth-story > .eyebrow { margin-top: 20px; }
  .auth-story h1 { font-size: clamp(3rem, 12vw, 5.4rem); }
  .auth-lede { max-width: 620px; }
  .auth-footnote { display: none; }
  .auth-card-wrap { padding: 32px 22px 44px; border-left: 0; }
  .auth-card { width: min(100%, 520px); }
  .topbar { grid-template-columns: 1fr auto; }
  .connection-chip { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .control-rail { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .workflow-card { grid-row: span 2; }
  .stage-panel { position: relative; }
}

@media (max-width: 640px) {
  .auth-story { min-height: auto; padding-top: 92px; }
  .auth-story h1 { font-size: clamp(2.75rem, 14vw, 4.2rem); }
  .auth-steps { flex-direction: column; gap: 10px; border-top: 0; }
  .auth-steps li { padding: 10px 0; border-top: 1px solid var(--line); }
  .auth-steps li + li { padding-left: 0; border-left: 0; }
  .auth-card { padding: 28px 22px; border-radius: 18px 4px 18px 4px; }
  .topbar { min-height: 58px; padding: 9px 14px; }
  .brand-lockup.compact .brand-copy small, .user-chip div { display: none; }
  .topbar-right { gap: 7px; }
  .workspace { gap: 12px; padding: 12px 10px 24px; }
  .stage-panel { border-radius: 12px 3px 12px 3px; }
  .stage-toolbar { min-height: 44px; padding: 6px 8px 6px 11px; }
  .toolbar-actions { gap: 3px; }
  .icon-button { min-width: 31px; height: 31px; }
  .stage-caption { padding: 8px 10px; }
  .browser-stage { min-height: 220px; }
  .stage-empty { padding: 20px; }
  .stage-empty h2 { font-size: 25px; }
  .stage-empty p { font-size: 10px; }
  .control-rail { display: flex; }
  .workflow-card, .identity-card, .input-card { padding: 16px; }
  .workflow-step { min-height: 53px; }
  .toast-stack { right: 10px; bottom: 10px; width: calc(100vw - 20px); }
}

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