:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --line: #dce3ea;
  --line-strong: #c3ccd6;
  --ink: #1b1f26;
  --glyph: #1b1f26;
  --text: #161a20;
  --text-2: #4d5665;
  --text-3: #7b8494;
  --accent: #ffc928;
  --accent-hover: #ffd34d;
  --accent-soft: #fff4cc;
  --data: #2457c5;
  --ok: #188a57;
  --warn: #b25e00;
  --danger: #d92d20;
  --sky-top: #8fcbf0;
  --sky-bot: #d6ecfa;
  --grass: #5cb85c;
  --grass-dark: #3f8f3f;
  --byte-zero: #e4eaf0;
  --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 4px 14px rgba(20, 30, 45, .05);
  --r: 14px;
  --sans: "Pretendard Variable", Pretendard, "Malgun Gothic", system-ui, sans-serif;
  --display: "Jua", "Pretendard Variable", sans-serif;
  --mono: "JetBrains Mono", "Pretendard Variable", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1319;
    --surface: #171c24;
    --surface-2: #1d232c;
    --line: #2a313c;
    --line-strong: #3a4250;
    --glyph: #cfd6e0;
    --text: #e7ebf0;
    --text-2: #aab2bf;
    --text-3: #7a8392;
    --accent-soft: rgba(255, 201, 40, .13);
    --data: #8db0ff;
    --ok: #3fcf8e;
    --warn: #f0a24a;
    --danger: #ff6b5e;
    --sky-top: #0a1830;
    --sky-bot: #1d3557;
    --grass: #2f6b3a;
    --grass-dark: #234f2b;
    --byte-zero: #252c37;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: .01em; margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.ico { display: inline-flex; align-items: center; line-height: 0; }
.ico svg { width: 18px; height: 18px; flex: none; }
kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--text-3); }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  height: 58px; padding: 0 22px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: var(--ink); border: 1.5px solid var(--ink); box-shadow: 0 2px 0 var(--ink);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { font-family: var(--display); font-size: 21px; }
.search-btn {
  margin-left: auto; display: flex; align-items: center; gap: 8px; height: 36px; min-width: 230px; padding: 0 8px 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text-3); cursor: pointer;
}
.search-btn:hover { border-color: var(--line-strong); color: var(--text-2); }
.search-btn-text { flex: 1; text-align: left; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; max-width: 240px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden;
}
#statusText { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.status.busy { background: var(--accent-soft); border-color: transparent; }
.status.busy .dot { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: ping 1.2s ease-out infinite; }
.status.off .dot { background: var(--danger); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255, 201, 40, .7); } 100% { box-shadow: 0 0 0 7px rgba(255, 201, 40, 0); } }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, transform .06s, box-shadow .06s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: var(--ink); border: 1.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  font-family: var(--display); font-weight: 400; font-size: 16px;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn-primary:disabled { box-shadow: none; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-primary.btn-sm { font-size: 15px; box-shadow: 0 2px 0 var(--ink); }
.btn-primary.btn-sm:active:not(:disabled) { transform: translateY(2px); }

/* ---------------------------------------------------------------- hero */
.hero { position: relative; overflow: hidden; background: linear-gradient(180deg, var(--sky-top), var(--sky-bot)); }
.scene { position: absolute; inset: 0; pointer-events: none; }
.ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 40px; border-top: 2px solid var(--ink);
  background: repeating-linear-gradient(90deg, transparent 0 38px, rgba(0,0,0,.07) 38px 40px), linear-gradient(var(--grass), var(--grass-dark));
}
.stars { position: absolute; inset: 0; opacity: 0; background-image:
  radial-gradient(1.5px 1.5px at 12% 22%, #fff, transparent), radial-gradient(1px 1px at 28% 48%, #fff, transparent),
  radial-gradient(1.5px 1.5px at 46% 18%, #fff, transparent), radial-gradient(1px 1px at 63% 38%, #fff, transparent),
  radial-gradient(1.5px 1.5px at 77% 14%, #fff, transparent), radial-gradient(1px 1px at 88% 44%, #fff, transparent),
  radial-gradient(1px 1px at 36% 30%, #fff, transparent), radial-gradient(1.5px 1.5px at 56% 52%, #fff, transparent); }
.cloud {
  position: absolute; width: 104px; height: 32px; background: #fff; border: 2px solid var(--ink); border-radius: 999px;
  animation: drift 70s linear infinite;
}
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border: 2px solid var(--ink); border-bottom: 0; border-radius: 50% 50% 0 0; }
.cloud::before { width: 40px; height: 26px; left: 16px; top: -17px; }
.cloud::after { width: 50px; height: 34px; left: 42px; top: -24px; }
.c1 { top: 34px; left: 58%; }
.c2 { top: 70px; left: 84%; transform: scale(.7); animation-duration: 95s; }
@keyframes drift { from { translate: 0 0; } to { translate: -110vw 0; } }
.base { position: absolute; bottom: 38px; width: 72px; height: 118px; background: no-repeat bottom center / contain; }
.base-cat {
  left: 2.5%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 92 150'%3E%3Cg stroke='%231b1f26' stroke-width='3' stroke-linejoin='round'%3E%3Cpath d='M14 148V52h64v96z' fill='%23fff'/%3E%3Cpath d='M8 54 46 18l38 36z' fill='%23ffc928'/%3E%3Cpath d='M46 18V4l14 6-14 5' fill='%23ff7a7a'/%3E%3Cpath d='M30 76l4-12 7 7q5-1 10 0l7-7 4 12q3 9-4 15-5 4-12 4t-12-4q-7-6-4-15z' fill='%23fff'/%3E%3Cpath d='M34 148v-26q12-10 24 0v26' fill='%23dbe4ec'/%3E%3C/g%3E%3Ccircle cx='40' cy='80' r='2' fill='%231b1f26'/%3E%3Ccircle cx='52' cy='80' r='2' fill='%231b1f26'/%3E%3C/svg%3E");
}
.base-enemy {
  right: 2.5%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 92 150'%3E%3Cg stroke='%231b1f26' stroke-width='3' stroke-linejoin='round'%3E%3Cpath d='M16 148 22 40h48l6 108z' fill='%234a4f5a'/%3E%3Cpath d='M16 40h60v-14h-10v8h-10v-8H36v8H26v-8H16z' fill='%23626877'/%3E%3Cpath d='M46 26V6l18 7-18 6' fill='%23e5484d'/%3E%3Cpath d='M34 148v-30q12-10 24 0v30' fill='%231b1f26'/%3E%3C/g%3E%3C/svg%3E");
}
.walker {
  position: absolute; bottom: 40px; width: 32px; height: 36px;
  background: no-repeat bottom center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 44'%3E%3Cg stroke='%231b1f26' stroke-width='2.5' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M8 12 10 3l6 5q4-1 8 0l6-5 2 9q3 8-1 14-4 5-11 5T9 26q-4-6-1-14z' fill='%23fff'/%3E%3Cpath d='M13 31v10M27 31v10' fill='none'/%3E%3C/g%3E%3Ccircle cx='16' cy='17' r='1.6' fill='%231b1f26'/%3E%3Ccircle cx='25' cy='17' r='1.6' fill='%231b1f26'/%3E%3C/svg%3E");
  animation: march 26s linear infinite, bob .45s ease-in-out infinite alternate;
}
@keyframes march { from { left: 10%; } to { left: 84%; } }
@keyframes bob { to { translate: 0 -3px; } }
@media (prefers-color-scheme: dark) {
  .stars { opacity: .8; }
  .cloud, .cloud::before, .cloud::after { background: #c9d3e0; }
}

.hero-inner { position: relative; z-index: 1; max-width: 1360px; margin: 0 auto; padding: 30px 130px 66px; }
.hero-intro { text-shadow: 0 0 8px var(--sky-bot), 0 0 3px var(--sky-bot); }
.hero-title { font-size: clamp(26px, 3.4vw, 38px); line-height: 1.2; color: #12233a; }
.hero-sub { margin: 6px 0 0; color: #2c4866; }
@media (prefers-color-scheme: dark) { .hero-title { color: #fff; } .hero-sub { color: #b9c8db; } }

.hero-save { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.save-card, .wallet {
  background: var(--surface); border: 1.5px solid var(--ink); border-radius: var(--r); box-shadow: 0 3px 0 var(--ink);
}
.save-card { position: relative; width: 270px; padding: 14px 16px 12px; }
.close-save { position: absolute; top: 10px; right: 10px; height: 28px; padding: 0 9px; font-size: 12px; font-weight: 500; color: var(--text-2); border-color: var(--line); }
.close-save .ico svg { width: 13px; height: 13px; }
.close-save:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }

.modal {
  width: min(440px, 92vw); padding: 22px 22px 18px; background: var(--surface); color: var(--text);
  border: 1.5px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink), 0 24px 60px rgba(0,0,0,.25); animation: rise .14s ease-out;
}
.modal-title { font-size: 20px; margin-bottom: 6px; }
.modal p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.danger-text { color: var(--danger); }

.palette-backdrop.login-backdrop { z-index: 70; place-items: center; padding-top: 0; background: linear-gradient(180deg, var(--sky-top), var(--sky-bot)); }
.login { display: flex; flex-direction: column; align-items: center; text-align: center; width: min(380px, 92vw); padding: 28px 26px 24px; }
.login-mark {
  display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 10px; border-radius: 16px;
  background: var(--accent); color: var(--ink); border: 1.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.login-mark svg { width: 36px; height: 36px; }
.login-field { width: 100%; margin-top: 18px; text-align: left; }
.login-error { min-height: 20px; margin: 8px 0 4px !important; font-size: 13px; color: var(--danger); }
.login-btn { width: 100%; }
.line.queued { color: var(--text-3); }
.save-top { display: flex; align-items: center; gap: 12px; }
.flag {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; flex: none;
  background: var(--accent); color: var(--ink); border: 1.5px solid var(--ink); font-family: var(--display); font-size: 18px;
}
.save-id { display: flex; flex-direction: column; }
.save-region { font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.save-ver { font-size: 24px; line-height: 1.15; }
.bytes { display: block; width: 100%; height: 26px; margin: 12px 0 6px; border-radius: 5px; cursor: crosshair; }
.save-meta { margin: 0; font-size: 11px; color: var(--text-3); overflow-wrap: anywhere; }

.wallet { flex: 1; min-width: 300px; margin: 0; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.coin { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: var(--surface-2); color: var(--glyph); }
.coin .ico svg { width: 24px; height: 24px; }
.coin dt { font-size: 11.5px; color: var(--text-3); line-height: 1.2; }
.coin dd { margin: 0; font-family: var(--mono); font-weight: 600; font-size: 15px; color: var(--text); line-height: 1.3; }
.coin.bump { animation: bump .6s ease; }
@keyframes bump { 30% { background: var(--accent-soft); transform: scale(1.03); } }

/* ---------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; max-width: 1360px; margin: -22px auto 0; padding: 0 22px 60px; position: relative; z-index: 2; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-title { font-size: 22px; }

/* sidebar */
.sidebar {
  position: sticky; top: 74px; align-self: start; max-height: calc(100vh - 92px);
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.side-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 2px; }
.side-title { font-size: 20px; }
.count { font-size: 12px; color: var(--text-3); }
.filter-wrap { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text-3); }
.filter-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-wrap input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.side-empty { margin: 4px 2px; font-size: 13px; color: var(--text-3); }
.tree { flex: 1; min-height: 0; overflow: auto; margin: 0 -6px; padding: 0 6px; }
.cat { margin-bottom: 2px; }
.cat-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px;
  background: none; border: 0; border-radius: 10px; cursor: pointer; text-align: left; color: var(--glyph); font-weight: 600;
}
.cat-btn > span:nth-child(2) { color: var(--text); }
.cat-btn:hover { background: var(--surface-2); }
.cat-btn .n { margin-left: auto; font-size: 11.5px; font-weight: 500; color: var(--text-3); background: var(--surface-2); border-radius: 999px; padding: 0 8px; }
.cat-btn .chev { color: var(--text-3); transition: transform .15s; }
.cat-btn .chev svg { width: 14px; height: 14px; }
.cat.open > .cat-btn { background: var(--accent-soft); }
.cat.open > .cat-btn .chev { transform: rotate(90deg); }
.cat ul { list-style: none; margin: 2px 0 6px 19px; padding: 0 0 0 10px; border-left: 2px solid var(--line); display: none; }
.cat.open ul, .tree.searching .cat ul { display: block; }
.feat {
  width: 100%; display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 8px;
  background: none; border: 0; border-radius: 8px; cursor: pointer; text-align: left; color: var(--glyph); font-size: 13.5px;
}
.feat .lbl { flex: 1; line-height: 1.35; color: var(--text); }
.feat .ico svg { width: 16px; height: 16px; }
.feat:hover:not(:disabled) { background: var(--accent-soft); }
.feat.running { background: var(--accent); }
.feat.running .lbl { color: var(--ink); font-weight: 600; }
.feat:disabled:not(.running) { opacity: .45; cursor: not-allowed; }
.risk { flex: none; font-size: 10.5px; font-weight: 600; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-radius: 5px; padding: 1px 6px; }
.side-foot { display: flex; align-items: center; gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.link-btn { display: inline-flex; align-items: center; gap: 5px; padding: 2px 0; background: none; border: 0; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.link-btn .ico svg { width: 15px; height: 15px; }
.link-btn:hover:not(:disabled) { color: var(--text); }
.link-btn:disabled { opacity: .45; cursor: not-allowed; }
.ver { margin-left: auto; font-size: 11px; color: var(--text-3); }

/* stage */
.stage { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.load-card { padding: 22px 24px 24px; }
.load-card > .muted { margin: 6px 0 0; }
.seg { display: inline-flex; gap: 2px; margin: 18px 0 16px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--text-2); font-weight: 500; }
.seg-btn.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg-btn .ico svg { width: 16px; height: 16px; }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); transition: background .12s, border-color .12s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { color: var(--text-3); }
.drop-icon svg { width: 30px; height: 30px; }
.form-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input { height: 38px; width: 100%; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); }
.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.opt-card p { margin: 0 0 8px; }

/* quick actions */
.section-title {
  display: inline-block; font-size: 17px; margin: 0 0 10px; padding: 3px 14px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--ink); box-shadow: 0 2px 0 var(--ink);
}
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
.qa {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 14px 14px 13px;
  text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); color: var(--glyph); transition: transform .1s, border-color .1s, box-shadow .1s;
}
.qa:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.qa:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.qa:disabled { opacity: .5; cursor: not-allowed; }
.qa .ico svg { width: 28px; height: 28px; }
.qa-label { margin-top: 6px; font-family: var(--display); font-size: 16.5px; color: var(--text); }
.qa-val { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.qa .risk { position: absolute; top: 12px; right: 12px; }

/* ---------------------------------------------------------------- log */
.log-card { display: flex; flex-direction: column; min-height: 340px; }
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.log-head .card-title { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console { padding: 16px 20px 22px; overflow-wrap: anywhere; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 0; color: var(--text-3); text-align: center; }
.empty-cat { color: var(--text-3); }
.empty-cat svg { width: 46px; height: 46px; }
.empty p { margin: 0; }
.task { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.task::before { content: ""; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1.5px var(--accent); }
.task.done::before { background: var(--ok); box-shadow: 0 0 0 1.5px var(--ok); }
.task.failed::before { background: var(--danger); box-shadow: 0 0 0 1.5px var(--danger); }
.task:last-child { border-left-color: transparent; }
.task-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.task-name { font-family: var(--display); font-size: 17px; }
.task-time { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.task-state { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--warn); }
.task.done .task-state { background: color-mix(in srgb, var(--ok) 13%, transparent); color: var(--ok); }
.task.failed .task-state { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.line { margin: 2px 0; white-space: pre-wrap; }
.line.progress { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.answered { margin: 3px 0 5px; font-size: 13.5px; color: var(--text-3); }
.answered b { color: var(--text); font-weight: 600; background: var(--accent-soft); border-radius: 6px; padding: 0 7px; margin-left: 4px; }
.error-box { margin: 8px 0; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--danger) 7%, transparent); }
.error-box pre { white-space: pre-wrap; font-family: var(--mono); font-size: 11.5px; max-height: 260px; overflow: auto; }
.dl { margin: 8px 0; }

/* cat assistant dialog */
.prompt-wrap { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0 12px; animation: rise .18s ease-out; }
.prompt-avatar {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: var(--ink); border: 1.5px solid var(--ink); box-shadow: 0 2px 0 var(--ink);
}
.prompt-avatar svg { width: 28px; height: 28px; }
.prompt {
  position: relative; flex: 1; min-width: 0; padding: 14px 16px 16px;
  background: var(--surface); border: 1.5px solid var(--ink); border-radius: 16px; box-shadow: 0 3px 0 var(--ink);
}
.prompt::before {
  content: ""; position: absolute; left: -9px; top: 15px; width: 14px; height: 14px; background: var(--surface);
  border-left: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(45deg);
}
.prompt-q { font-weight: 500; font-size: 14.5px; margin-bottom: 12px; white-space: pre-wrap; }
.prompt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.opt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; max-height: 380px; overflow: auto; padding: 2px; }
.opt {
  display: flex; align-items: flex-start; gap: 8px; padding: 9px 11px; text-align: left; cursor: pointer; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text);
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.num { flex: none; display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 4px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.check { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: 13.5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check input { margin-top: 3px; accent-color: var(--accent); width: 15px; height: 15px; }
.filter { margin-bottom: 8px; max-width: 320px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 210px; overflow: auto; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); cursor: pointer; font-size: 12.5px; color: var(--text); }
.chip:hover { border-color: var(--accent); }
.num-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.num-row .input { max-width: 240px; font-family: var(--mono); font-size: 15px; }
.hint { margin: 0 0 8px; font-size: 12px; color: var(--text-3); }
.num-row .hint { margin: 0; font-family: var(--mono); }

/* bcsfe markup colours */
.m-s { color: var(--data); font-weight: 500; }
.m-t { font-weight: 600; }
.m-q { color: #7a5af5; font-weight: 500; }
.m-e { color: var(--danger); font-weight: 500; }
.m-w { color: var(--warn); }
.m-su { color: var(--ok); font-weight: 500; }

/* ---------------------------------------------------------------- palette */
.palette-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding-top: 12vh; background: rgba(10, 15, 22, .4); }
.palette { width: min(600px, 92vw); overflow: hidden; background: var(--surface); border: 1.5px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink), 0 24px 60px rgba(0,0,0,.25); animation: rise .14s ease-out; }
.palette-input { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15.5px; color: var(--text); }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palette-list li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--glyph); }
.palette-list li > span:nth-child(2) { color: var(--text); }
.palette-list li .path { margin-left: auto; font-size: 12px; color: var(--text-3); }
.palette-list li.sel { background: var(--accent-soft); }
.palette-list .none { color: var(--text-3); cursor: default; }
.palette-foot { display: flex; align-items: center; gap: 6px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); max-width: min(500px, 90vw);
  padding: 11px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .hero-inner { padding: 26px 22px 64px; }
  .base { opacity: .3; }
  .search-btn { min-width: 0; }
  .search-btn-text, .search-btn kbd { display: none; }
}
@media (max-width: 860px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 12px; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; }
  .layout { grid-template-columns: 1fr; padding: 0 12px 40px; }
  .stage { order: -1; }
  .sidebar { position: static; max-height: 60vh; }
  .grid2 { grid-template-columns: 1fr; }
  .save-card { width: 100%; }
  .wallet { min-width: 0; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .status { display: none; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .prompt-avatar { width: 34px; height: 34px; }
  .prompt-avatar svg { width: 22px; height: 22px; }
}
