:root {
  --ink: #11120f;
  --ink-soft: #171815;
  --paper: #eeeadd;
  --paper-muted: #aaa89f;
  --line: rgba(238, 234, 221, .14);
  --line-strong: rgba(238, 234, 221, .28);
  --accent: #f4b942;
  --accent-ink: #211a08;
  --danger: #ff776d;
  --success: #9fcf72;
  --header-height: 86px;
  color-scheme: dark;
  font-family: Inter, Pretendard, "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--ink); scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--ink);
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.hidden { display: none !important; }

.signal-line {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0, var(--accent) 42%, #ffe4a2 50%, var(--accent) 58%, transparent 100%);
  background-size: 220% 100%;
  animation: signalSweep 7s linear infinite;
}

.site-header {
  position: relative;
  z-index: 20;
  height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 clamp(22px, 4vw, 68px);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 18, 15, .84);
  backdrop-filter: blur(18px);
}

.brand {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--paper);
  text-decoration: none;
  font-size: 11px;
  font-weight: 760;
  line-height: .92;
  letter-spacing: .13em;
}

.brand svg { width: 32px; height: 32px; }
.brand path { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand circle { fill: var(--accent); }

.system-state {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--paper-muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(159, 207, 114, .4);
  animation: statePulse 2.4s ease-out infinite;
}

.state-divider { width: 1px; height: 12px; background: var(--line-strong); }

.text-button {
  justify-self: end;
  border: 0;
  padding: 8px 0;
  background: transparent;
  color: var(--paper-muted);
  font-size: 12px;
  cursor: pointer;
}
.text-button:hover { color: var(--paper); }

.login-view {
  min-height: calc(100svh - var(--header-height));
  display: grid;
  grid-template-columns: minmax(420px, .9fr) minmax(460px, 1.1fr);
}

.login-copy {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(54px, 7vw, 116px) clamp(28px, 7vw, 120px);
  border-right: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 24px;
  color: var(--accent);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
}

.login-copy h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(42px, 4.5vw, 76px);
  font-weight: 520;
  line-height: 1.06;
  letter-spacing: -.055em;
  word-break: keep-all;
}

.lead {
  max-width: 440px;
  margin: 30px 0 38px;
  color: var(--paper-muted);
  font-size: clamp(14px, 1.2vw, 17px);
  line-height: 1.8;
  word-break: keep-all;
}

.primary-button {
  width: min(100%, 440px);
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--accent);
  padding: 0 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.primary-button:hover { background: #ffd16f; transform: translateY(-2px); }
.primary-button:disabled { opacity: .48; cursor: wait; transform: none; }
.primary-button svg { width: 22px; height: 22px; fill: currentColor; }
.button-arrow { font-family: "SFMono-Regular", Consolas, monospace; font-size: 18px; font-weight: 400; }

.recovery-toggle {
  width: max-content;
  margin-top: 24px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  padding: 4px 0;
  background: transparent;
  color: var(--paper-muted);
  font-size: 12px;
  cursor: pointer;
}
.recovery-toggle:hover { color: var(--paper); border-color: var(--paper); }

.recovery-form { width: min(100%, 440px); margin-top: 22px; animation: reveal .25s ease both; }
.recovery-form > label, .connect-form > label > span, .connect-form legend {
  display: block;
  margin-bottom: 9px;
  color: var(--paper-muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.inline-field { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--line-strong); }
.inline-field input { min-width: 0; border: 0; padding: 12px 0; background: transparent; color: var(--paper); }
.inline-field button { border: 0; background: transparent; color: var(--accent); cursor: pointer; }

.login-visual {
  position: relative;
  min-height: 580px;
  overflow: hidden;
  background:
    radial-gradient(circle at 66% 43%, rgba(244, 185, 66, .12), transparent 24%),
    linear-gradient(132deg, #181914, #0e0f0d 70%);
}

.market-grid {
  position: absolute;
  inset: 0;
  opacity: .7;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: clamp(54px, 7vw, 96px) clamp(54px, 7vw, 96px);
  mask-image: linear-gradient(to bottom right, black, transparent 86%);
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(105deg, transparent 0 92px, rgba(255,255,255,.012) 92px 93px);
}

.signal-graph { position: absolute; z-index: 2; inset: 15% -4% 8% -4%; width: 108%; height: 74%; overflow: visible; }
.signal-graph path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.graph-ghost { stroke: rgba(244, 185, 66, .1); stroke-width: 18; filter: blur(8px); }
.graph-main { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 1300; stroke-dashoffset: 1300; animation: drawGraph 2.4s cubic-bezier(.6, 0, .2, 1) .25s forwards; }

.orbit { position: absolute; z-index: 1; border: 1px solid rgba(244, 185, 66, .16); border-radius: 50%; }
.orbit-one { width: 50vw; height: 50vw; min-width: 620px; min-height: 620px; right: -24vw; top: -17vw; }
.orbit-two { width: 24vw; height: 24vw; min-width: 320px; min-height: 320px; right: 4vw; bottom: -10vw; }

.visual-core {
  position: absolute;
  z-index: 3;
  right: clamp(50px, 10vw, 170px);
  top: 45%;
  width: 112px;
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid var(--accent);
  background: rgba(17, 18, 15, .72);
  backdrop-filter: blur(12px);
  transform: rotate(45deg);
  animation: coreEnter .8s cubic-bezier(.2,.8,.2,1) .8s both;
}
.visual-core span, .visual-core small { transform: rotate(-45deg); }
.visual-core span { color: var(--accent); font: 24px/1 "SFMono-Regular", Consolas, monospace; }
.visual-core small { color: var(--paper-muted); font: 8px/1.4 "SFMono-Regular", Consolas, monospace; letter-spacing: .12em; }

.visual-label { position: absolute; z-index: 3; display: flex; gap: 14px; color: var(--paper-muted); font: 9px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .1em; }
.visual-label strong { color: var(--paper); font-weight: 500; }
.label-top { top: 8%; left: 8%; }
.label-bottom { bottom: 8%; right: 8%; }

.account-view { min-height: calc(100svh - var(--header-height)); display: grid; grid-template-columns: minmax(260px, 24vw) 1fr; }
.account-rail { position: sticky; top: 0; height: calc(100svh - var(--header-height)); display: flex; flex-direction: column; padding: clamp(40px, 5vw, 76px) clamp(28px, 4vw, 64px); border-right: 1px solid var(--line); background: var(--ink-soft); }
.account-rail h1 { margin: 0; font-size: clamp(34px, 3.4vw, 54px); font-weight: 520; letter-spacing: -.05em; }

.steps { display: grid; gap: 0; margin: clamp(54px, 8vh, 94px) 0 0; padding: 0; list-style: none; }
.steps li { position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 14px; min-height: 86px; color: #6e6e67; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 14px; top: 33px; width: 1px; height: 48px; background: var(--line); }
.steps li > span { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font: 8px/1 "SFMono-Regular", Consolas, monospace; }
.steps div { display: flex; flex-direction: column; gap: 5px; padding-top: 3px; }
.steps strong { color: currentColor; font-size: 13px; font-weight: 620; }
.steps small { font-size: 10px; }
.steps li.complete, .steps li.active { color: var(--paper); }
.steps li.complete > span { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.steps li.active > span { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 5px rgba(244,185,66,.08); }

.rail-note { margin: auto 0 0; padding-top: 24px; border-top: 1px solid var(--line); color: var(--paper-muted); font-size: 10px; line-height: 1.7; word-break: keep-all; }

.account-workspace { width: min(100%, 1040px); padding: clamp(30px, 5vw, 72px) clamp(24px, 6vw, 92px) 100px; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: clamp(58px, 8vw, 110px); }
.identity { display: flex; align-items: center; gap: 13px; }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--paper); color: var(--ink); font-size: 12px; font-weight: 800; }
.identity div { display: flex; flex-direction: column; gap: 3px; }
.identity strong { font-size: 13px; }
.identity span:not(.avatar) { color: var(--paper-muted); font-size: 10px; }
.session-expiry { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.session-expiry span { color: var(--paper-muted); font: 8px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .13em; }
.session-expiry strong { font: 11px/1 "SFMono-Regular", Consolas, monospace; }

.status-block, .connect-block { padding-bottom: clamp(60px, 8vw, 100px); }
.connect-block { border-top: 1px solid var(--line); padding-top: clamp(60px, 8vw, 100px); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.section-heading .eyebrow { margin-bottom: 11px; }
.section-heading h2 { margin: 0; font-size: clamp(28px, 3vw, 42px); font-weight: 520; letter-spacing: -.045em; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--paper-muted); cursor: pointer; transition: border-color .2s, color .2s, transform .3s; }
.icon-button:hover { border-color: var(--paper); color: var(--paper); transform: rotate(45deg); }

.connection-empty { min-height: 170px; display: flex; align-items: center; gap: 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.connection-empty strong { display: block; margin-bottom: 8px; font-size: 15px; }
.connection-empty p { margin: 0; color: var(--paper-muted); font-size: 12px; }
.empty-mark { width: 74px; height: 74px; display: flex; align-items: flex-end; gap: 6px; padding: 18px; border: 1px solid var(--line); border-radius: 50%; }
.empty-mark span { flex: 1; background: var(--line-strong); }
.empty-mark span:nth-child(1) { height: 35%; }.empty-mark span:nth-child(2) { height: 64%; }.empty-mark span:nth-child(3) { height: 46%; }

.account-state-row { display: flex; align-items: center; justify-content: space-between; padding: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.account-state-row div { display: flex; flex-direction: column; gap: 8px; }
.account-state-row div span { color: var(--paper-muted); font: 8px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .12em; }
.account-state-row strong { font: 30px/1 "SFMono-Regular", Consolas, monospace; font-weight: 450; letter-spacing: -.04em; }
.status-badge { border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 12px; color: var(--paper-muted); font: 9px/1 "SFMono-Regular", Consolas, monospace; }
.status-badge.ready { border-color: rgba(159,207,114,.5); color: var(--success); background: rgba(159,207,114,.07); }
.status-badge.blocked { border-color: rgba(255,119,109,.5); color: var(--danger); background: rgba(255,119,109,.07); }
.connection-metadata { display: grid; grid-template-columns: repeat(2, 1fr); margin: 0; }
.connection-metadata div { padding: 24px 0; border-bottom: 1px solid var(--line); }
.connection-metadata div:nth-child(odd) { border-right: 1px solid var(--line); padding-right: 28px; }
.connection-metadata div:nth-child(even) { padding-left: 28px; }
.connection-metadata dt { margin-bottom: 10px; color: var(--paper-muted); font: 9px/1 "SFMono-Regular", Consolas, monospace; text-transform: uppercase; }
.connection-metadata dd { margin: 0; overflow: hidden; color: var(--paper); font: 12px/1.4 "SFMono-Regular", Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }

.encryption-label { color: var(--success); font: 8px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .1em; }
.connect-form { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 30px; }
.connect-form label { min-width: 0; }
.connect-form input[type="text"], .connect-form input[type="password"] { width: 100%; height: 54px; border: 0; border-bottom: 1px solid var(--line-strong); border-radius: 0; padding: 0; background: transparent; color: var(--paper); font: 13px/1 "SFMono-Regular", Consolas, monospace; }
.connect-form input::placeholder, .recovery-form input::placeholder { color: #63635e; }
.secret-field { position: relative; display: block; }
.secret-field input { padding-right: 54px !important; }
.secret-field button { position: absolute; right: 0; top: 0; height: 54px; border: 0; background: transparent; color: var(--paper-muted); font-size: 10px; cursor: pointer; }
.connect-form fieldset { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 10px 0 0; border: 0; padding: 0; background: var(--line); }
.connect-form legend { margin-bottom: 13px; }
.check-row { min-height: 82px; display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--ink); cursor: pointer; }
.check-row input { position: absolute; opacity: 0; pointer-events: none; }
.check-row > span { width: 18px; height: 18px; flex: 0 0 auto; border: 1px solid var(--line-strong); }
.check-row input:checked + span { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px var(--ink); }
.check-row div { display: flex; flex-direction: column; gap: 5px; }
.check-row strong { font-size: 12px; }
.check-row small { color: var(--paper-muted); font-size: 10px; }
.permission-warning { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; color: var(--paper-muted); }
.permission-warning svg { width: 28px; flex: 0 0 auto; fill: none; stroke: var(--accent); stroke-width: 1.5; }
.permission-warning p { margin: 0; font-size: 10px; line-height: 1.7; }
.permission-warning strong { color: var(--paper); font-weight: 620; }
.connect-button { grid-column: 1 / -1; justify-self: end; margin-top: 10px; }

.recovery-dialog { width: min(560px, calc(100% - 32px)); border: 1px solid var(--line-strong); padding: 42px; background: #191a16; color: var(--paper); box-shadow: 0 40px 100px rgba(0,0,0,.6); }
.recovery-dialog[open] { animation: dialogEnter .3s cubic-bezier(.2,.8,.2,1) both; }
.recovery-dialog::backdrop { background: rgba(3,4,3,.8); backdrop-filter: blur(8px); }
.dialog-index { margin-bottom: 28px; color: var(--accent); font: 9px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .14em; }
.recovery-dialog h2 { margin: 0 0 18px; font-size: clamp(32px, 6vw, 50px); font-weight: 520; line-height: 1.05; letter-spacing: -.05em; }
.recovery-dialog p { margin: 0; color: var(--paper-muted); font-size: 12px; line-height: 1.7; }
.recovery-dialog output { display: block; margin: 30px 0; border: 1px solid var(--line-strong); padding: 18px; overflow-wrap: anywhere; background: var(--ink); color: var(--accent); font: 12px/1.6 "SFMono-Regular", Consolas, monospace; user-select: all; }
.dialog-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.dialog-actions .primary-button { min-height: 50px; }
.secondary-button { border: 1px solid var(--line-strong); padding: 0 18px; background: transparent; color: var(--paper); font-size: 11px; cursor: pointer; }
.secondary-button:hover { border-color: var(--paper); }

.toast { position: fixed; z-index: 200; right: 24px; bottom: 24px; max-width: min(380px, calc(100% - 48px)); border-left: 2px solid var(--accent); padding: 15px 18px; background: var(--paper); color: var(--ink); font-size: 12px; line-height: 1.5; opacity: 0; pointer-events: none; transform: translateY(15px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--danger); }
.busy-overlay { position: fixed; z-index: 190; inset: 0; display: grid; place-items: center; background: rgba(17,18,15,.38); cursor: progress; }
.busy-overlay span { width: 34px; height: 34px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }

@keyframes signalSweep { to { background-position: -220% 0; } }
@keyframes statePulse { 50% { box-shadow: 0 0 0 7px rgba(159,207,114,0); } }
@keyframes drawGraph { to { stroke-dashoffset: 0; } }
@keyframes coreEnter { from { opacity: 0; transform: rotate(45deg) scale(.65); } }
@keyframes reveal { from { opacity: 0; transform: translateY(-8px); } }
@keyframes dialogEnter { from { opacity: 0; transform: translateY(22px) scale(.97); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 940px) {
  .site-header { grid-template-columns: 1fr auto; }
  .system-state { display: none; }
  .login-view { grid-template-columns: 1fr; }
  .login-copy { min-height: calc(100svh - var(--header-height)); border-right: 0; }
  .login-visual { display: none; }
  .account-view { grid-template-columns: 1fr; }
  .account-rail { position: static; height: auto; min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .steps { grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 40px; }
  .steps li { grid-template-columns: 30px 1fr; min-height: 52px; }
  .steps li::after { display: none; }
  .rail-note { display: none; }
  .account-workspace { margin: 0 auto; }
}

@media (max-width: 620px) {
  :root { --header-height: 72px; }
  .site-header { padding: 0 20px; }
  .brand svg { width: 28px; }
  .login-copy { justify-content: flex-end; padding: 52px 22px 56px; }
  .login-copy h1 { font-size: clamp(40px, 12vw, 56px); }
  .lead { margin: 24px 0 32px; }
  .account-rail { padding: 36px 22px; }
  .steps { grid-template-columns: 1fr; }
  .steps li { display: none; }
  .steps li.active, .steps li.complete:last-of-type { display: grid; }
  .account-workspace { padding: 30px 22px 76px; }
  .workspace-header { margin-bottom: 64px; }
  .session-expiry { display: none; }
  .connection-metadata { grid-template-columns: 1fr; }
  .connection-metadata div:nth-child(odd), .connection-metadata div:nth-child(even) { border-right: 0; padding: 20px 0; }
  .connect-form { grid-template-columns: 1fr; }
  .connect-form fieldset { grid-template-columns: 1fr; }
  .connect-form > *, .connect-button { grid-column: 1; }
  .connect-button { width: 100%; }
  .encryption-label { display: none; }
  .recovery-dialog { padding: 30px 22px; }
  .dialog-actions { grid-template-columns: 1fr; }
  .secondary-button { min-height: 46px; }
}

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