/* line — command deck. hkbit design language: deep green-black terminal,
   neon #00ff88 accent, Rajdhani / Space Mono / Noto Sans KR.
   Mobile-first: single column + bottom tab bar; desktop becomes a grid. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* an explicit display rule (e.g. .grid2{display:grid}) otherwise beats the
   [hidden] attribute, so toggling .hidden silently fails — enforce it. */
[hidden] { display: none !important; }

:root {
  --bg-deep:  #050908;
  --bg-base:  #08100a;
  --bg-card:  #0c1710;
  --bg-up:    #111e15;
  --accent:   #00ff88;
  --accent-d: #00cc66;
  --accent-g: rgba(0, 255, 136, 0.12);
  --danger:   #ff4444;
  --warn:     #ffaa00;
  --info:     #4db8ff;
  --tp:       #ddfce9;
  --ts:       #7fb892;
  --tm:       #3d5c48;
  --border:   rgba(0, 255, 136, 0.12);
  --border-b: rgba(0, 255, 136, 0.35);
  --mono: "Space Mono", "Noto Sans KR", monospace;
  --disp: "Rajdhani", "Noto Sans KR", sans-serif;
  --body: "Noto Sans KR", sans-serif;
  --nav-h: 58px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(0, 255, 136, 0.06), transparent 60%),
    var(--bg-deep);
  background-attachment: fixed;
  color: var(--tp);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100dvh;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 255, 136, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 136, 0.03) 1px, transparent 1px);
  background-size: 64px 64px;
}

::selection { background: rgba(0, 255, 136, 0.2); color: var(--accent); }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: rgba(0, 255, 136, 0.25); border-radius: 2px; }

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select {
  font-family: var(--mono);
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--tp);
  padding: 12px 14px;
  font-size: 16px; /* >=16px: prevents iOS zoom-on-focus */
  width: 100%;
}
input::placeholder { color: var(--tm); }
input:focus, select:focus { outline: none; border-color: var(--border-b); box-shadow: 0 0 0 2px var(--accent-g); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--accent); }
.neg { color: var(--danger); }
.muted { color: var(--ts); }
.dim { color: var(--tm); }

/* ---------- shell / topbar ---------- */
.shell {
  position: relative; z-index: 1;
  max-width: 1240px; margin: 0 auto;
  padding: 0 14px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 24px);
}
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 2px 10px;
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(var(--bg-deep) 75%, transparent);
}
.logo {
  font-family: var(--disp); font-weight: 700; font-size: 26px;
  letter-spacing: 0.08em; line-height: 1;
  text-shadow: 0 0 18px rgba(0, 255, 136, 0.35);
}
.logo em { font-style: normal; color: var(--accent); }
.logo-sub { font-family: var(--mono); font-size: 9px; letter-spacing: 0.22em; color: var(--ts); margin-top: 3px; }
.topbar .spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card);
  white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; animation: pulse 2s infinite; }
.dot.on    { background: var(--accent); color: var(--accent); }
.dot.off   { background: var(--tm); color: var(--tm); animation: none; }
.dot.warn  { background: var(--warn); color: var(--warn); }
.dot.hot   { background: var(--danger); color: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 0.65; box-shadow: 0 0 3px currentColor; }
  50% { opacity: 1; box-shadow: 0 0 10px currentColor; }
}

/* ---------- HUD ---------- */
.hud {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin: 6px 0 16px;
}
.hud-cell {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; min-height: 74px;
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
}
.hud-cell .k { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--ts); text-transform: uppercase; }
.hud-cell .v { font-family: var(--mono); font-size: 19px; font-weight: 700; line-height: 1.2; word-break: break-all; }
.hud-cell .s { font-size: 11.5px; color: var(--ts); }
.hud-cell.hot { border-color: rgba(255, 68, 68, 0.4); }
.hud-cell.hot .k { color: #ff8a8a; }

/* ---------- panels & cards ---------- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.panel-hdr {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px;
}
.panel-hdr h2 {
  font-family: var(--disp); font-size: 17px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase;
}
.panel-hdr .tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--ts); }
.panel-hdr .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  font-family: var(--disp); font-weight: 700; font-size: 15px; letter-spacing: 0.08em;
  border-radius: 10px; border: 1px solid var(--border-b);
  background: var(--accent-g); color: var(--accent);
  transition: transform 0.06s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--ts); }
.btn.hot { background: rgba(255, 68, 68, 0.12); border-color: rgba(255, 68, 68, 0.5); color: #ff8a8a; }
.btn.block { width: 100%; }

.chiprow { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  font-family: var(--mono); font-size: 14px; font-weight: 700;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-up); color: var(--tp);
  -webkit-tap-highlight-color: transparent;
}
.chip:active { border-color: var(--border-b); }
.chip.sel { border-color: var(--border-b); background: var(--accent-g); color: var(--accent); }
.chip .x { color: var(--tm); font-size: 12px; }

.formrow { display: flex; gap: 8px; }
.formrow input { flex: 1; min-width: 0; }
.formrow .btn { flex: none; }

/* agent / strategy cards */
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gcard {
  position: relative;
  border: 1px solid var(--border); border-radius: 12px;
  background: linear-gradient(160deg, var(--bg-up), var(--bg-card));
  padding: 12px; min-height: 116px;
  display: flex; flex-direction: column; gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.gcard.sel { border-color: var(--border-b); box-shadow: 0 0 0 2px var(--accent-g), 0 0 18px rgba(0,255,136,0.08); }
.gcard.dis { opacity: 0.45; }
.gcard .cls {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent-d);
}
.gcard .nm { font-family: var(--disp); font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.gcard .ds { font-size: 11.5px; color: var(--ts); line-height: 1.45; }
.gcard .sig { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.gcard .sig span {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 5px; background: var(--bg-base); color: var(--ts);
  border: 1px solid var(--border);
}
.gcard .duty {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--mono); font-size: 10px; color: var(--accent);
}

/* missions */
.mission { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px dashed var(--border); }
.mission:last-child { border-bottom: none; }
.mission .mk {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; border: 1px solid var(--border); background: var(--bg-base); color: var(--tm);
}
.mission.done .mk { background: var(--accent-g); border-color: var(--border-b); color: var(--accent); }
.mission .mt { font-weight: 500; font-size: 14px; }
.mission .md { font-size: 11.5px; color: var(--ts); }
.mission .mp { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ts); white-space: nowrap; }
.mission.done .mt { color: var(--accent); }

/* stats / kv rows */
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 2px; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { font-size: 13px; color: var(--ts); }
.kv .v { font-family: var(--mono); font-size: 15.5px; font-weight: 700; }

/* replay feed */
.replay { display: flex; flex-direction: column; gap: 10px; }
.rcard { border: 1px solid var(--border); border-left-width: 3px; border-radius: 10px; background: var(--bg-up); padding: 12px; }
.rcard.buy  { border-left-color: var(--accent); }
.rcard.sell { border-left-color: var(--info); }
.rcard.hold { border-left-color: var(--tm); }
.rcard-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rcard-head .tk { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-base); color: var(--ts); text-transform: uppercase;
}
.badge.buy  { color: var(--accent); border-color: var(--border-b); }
.badge.sell { color: var(--info); border-color: rgba(77, 184, 255, 0.4); }
.badge.fill { color: var(--accent); }
.badge.blocked { color: var(--warn); border-color: rgba(255, 170, 0, 0.4); }
.badge.hot { color: #ff8a8a; border-color: rgba(255, 68, 68, 0.45); }
.rcard ul { margin: 8px 0 0 2px; list-style: none; }
.rcard li { font-size: 12.5px; color: var(--ts); padding-left: 14px; position: relative; line-height: 1.5; }
.rcard li::before { content: "▸"; position: absolute; left: 0; color: var(--accent-d); }
.rcard .risk { margin-top: 8px; font-size: 12px; color: var(--warn); }
.rcard .meta { margin-top: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--tm); }

/* live zone */
.livebox { border: 1px solid rgba(255, 68, 68, 0.35); border-radius: 12px; padding: 14px; background: rgba(255, 68, 68, 0.04); margin-bottom: 12px; }
.livebox h3 { font-family: var(--disp); font-size: 14px; letter-spacing: 0.12em; color: #ff8a8a; margin-bottom: 8px; }
.live-form { display: flex; flex-direction: column; gap: 10px; }
.live-form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; font-family: var(--disp); font-weight: 700; letter-spacing: 0.08em; color: var(--ts); background: var(--bg-base); font-size: 14px; }
.seg button.sel { background: var(--accent-g); color: var(--accent); }
.seg button.sel.hot { background: rgba(255, 68, 68, 0.14); color: #ff8a8a; }

/* status line / toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%) translateY(20px);
  max-width: min(92vw, 480px);
  background: var(--bg-up); border: 1px solid var(--border-b); border-radius: 10px;
  padding: 12px 16px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 90;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: rgba(255, 68, 68, 0.55); color: #ffb3b3; }

.loading { position: relative; overflow: hidden; }
.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 136, 0.07), transparent);
  animation: sweep 1.1s infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.empty { padding: 18px 4px; text-align: center; color: var(--tm); font-size: 13px; }

/* ---------- bottom tab nav (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  background: rgba(8, 16, 10, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  flex: 1; min-height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  color: var(--tm);
  -webkit-tap-highlight-color: transparent;
}
.tabbar button .ic { font-size: 18px; line-height: 1; }
.tabbar button.sel { color: var(--accent); }
.tabbar button.sel .ic { text-shadow: 0 0 12px rgba(0, 255, 136, 0.6); }

section[data-view] { display: none; animation: fadein 0.18s ease; }
section[data-view].on { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; position: relative; z-index: 1;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 30px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-card .logo { font-size: 34px; text-align: center; }
.login-card .logo-sub { text-align: center; margin-bottom: 26px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-err { color: #ffb3b3; font-size: 13px; min-height: 1.2em; text-align: center; }

/* ---------- desktop ---------- */
@media (min-width: 980px) {
  :root { --nav-h: 0px; }
  .shell { padding-bottom: 40px; }
  .tabbar { display: none; }
  section[data-view] { display: block !important; }
  .deck-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; align-items: start; }
  .hud { grid-template-columns: repeat(4, 1fr); }
  #toast { bottom: 30px; }
}
