/* TokenMax ×20 Studio — /tokenmax
 * 원본 Lovable TokenMax Studio의 웜 다크 팔레트(오렌지 #FF5A2E / 크림 #F3EDE4)를
 * 그대로 가져오고, MOON RELAY의 카드 구조(.card/.btn/.pill) 위에 얹는다. */

body.tokenmax {
  --bg: #141210;
  --bg-grad:
    radial-gradient(900px 520px at 82% -8%, rgba(255, 90, 46, .16), transparent 62%),
    radial-gradient(760px 460px at 4% 108%, rgba(255, 168, 76, .07), transparent 60%);
  --panel: #1b1917;
  --panel-2: #201d1a;
  --panel-3: #26221e;
  --border: #2e2a26;
  --border-soft: #241f1b;
  --text: #f3ede4;
  --muted: #a89f93;
  --muted-2: #746c62;
  --accent: #ff5a2e;
  --accent-soft: rgba(255, 90, 46, .14);
  --mint: #41d19a;
  --mint-soft: rgba(65, 209, 154, .12);
  --amber: #f2b45c;
  --amber-soft: rgba(242, 180, 92, .13);
  --danger: #ff6f61;
  --danger-soft: rgba(255, 111, 97, .13);
  --radius: 14px;
}

body.tokenmax::before { background: var(--bg-grad); }

body.tokenmax .tokenmax-wrap {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 20px 96px;
}

body.tokenmax .studio-nav { flex-wrap: wrap; gap: 6px; }
body.tokenmax .btn { border-color: var(--border); background: var(--panel-2); }
body.tokenmax .btn:hover { border-color: #453f38; background: #2a2521; }
body.tokenmax .btn.primary {
  background: linear-gradient(100deg, #ff6a3d, #f04a1f);
  color: #1a0d07;
  border-color: rgba(255, 122, 70, .55);
  font-weight: 700;
}
body.tokenmax .btn.primary:hover { background: linear-gradient(100deg, #ff7d55, #ff5a2e); }
body.tokenmax .btn.ghost { background: transparent; }
body.tokenmax .input, body.tokenmax .select, body.tokenmax textarea {
  border-color: var(--border);
  background: #171412;
  color: var(--text);
}
body.tokenmax .input:focus, body.tokenmax .select:focus, body.tokenmax textarea:focus {
  border-color: var(--accent);
  outline: none;
}
body.tokenmax .card { border-color: var(--border); background: linear-gradient(180deg, #1d1a17, #191614); }
body.tokenmax .card-head h3 { color: var(--text); }
body.tokenmax .pill.accent { background: var(--accent-soft); color: #ffb59c; border-color: rgba(255, 90, 46, .32); }
body.tokenmax .toast { background: #241f1b; border-color: var(--border); }

/* ------------------------------------------------------------------ hero */

.tm-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: end;
  padding: 6px 2px 18px;
}
.tm-hero h1 {
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: -.025em;
  margin: 6px 0 8px;
  background: linear-gradient(96deg, #fff4ea 10%, #ffb08d 58%, #ff5a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tm-hero p { color: var(--muted); font-size: 13.5px; max-width: 660px; }
.tm-hero p b { color: #ffc9b3; font-weight: 650; }
.tm-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: #ff9b76; font-weight: 700;
}
.tm-kicker::before { content: ""; width: 16px; height: 2px; background: var(--accent); border-radius: 2px; }

.tm-hero-stats { display: grid; grid-template-columns: repeat(4, minmax(86px, auto)); gap: 8px; }
.tm-hstat {
  border: 1px solid var(--border);
  background: rgba(32, 29, 26, .78);
  border-radius: 12px;
  padding: 9px 12px;
  min-width: 86px;
}
.tm-hstat .k { font-size: 10px; color: var(--muted-2); letter-spacing: .04em; }
.tm-hstat .v { font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; color: #ffe9dd; }
.tm-hstat .v small { font-size: 11px; color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------------ step rail */

.tm-step { margin-top: 16px; }
.tm-step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tm-step-no {
  width: 26px; height: 26px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(255, 90, 46, .34);
  color: #ffab8c; font-weight: 750; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.tm-step-head h3 { font-size: 15px; }
.tm-step-head .sub { margin: 0; }
.tm-step-head .tm-step-meta { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------ chips */

.tm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tm-chip {
  border: 1px solid var(--border);
  background: #1a1714;
  color: var(--muted);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all .14s ease;
  font-variant-numeric: tabular-nums;
}
.tm-chip:hover { border-color: #494037; color: var(--text); }
.tm-chip.on {
  border-color: rgba(255, 90, 46, .6);
  background: var(--accent-soft);
  color: #ffc0a8;
  font-weight: 650;
}

/* ------------------------------------------------------------------ layout */

.tm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tm-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tm-span2 { grid-column: span 2; }
.tm-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tm-row.end { justify-content: flex-end; }
.tm-note { font-size: 11.5px; color: var(--muted-2); line-height: 1.55; }
.tm-note b { color: #d9b9a5; font-weight: 600; }
.tm-divider { height: 1px; background: var(--border-soft); margin: 14px 0; }

/* ------------------------------------------------------------------ stats line */

.tm-inline-stat {
  display: flex; gap: 14px; flex-wrap: wrap;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(23, 20, 18, .6);
}
.tm-inline-stat b { color: #ffe2d3; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ progress */

.tm-bar {
  height: 8px;
  border-radius: 99px;
  background: #221e1a;
  border: 1px solid var(--border-soft);
  overflow: hidden;
}
.tm-bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #ff8a5c, #ff5a2e);
  transition: width .35s ease;
}
.tm-bar.mint > i { background: linear-gradient(90deg, #61e2b2, #22b982); }
.tm-progress-line { display: flex; align-items: center; gap: 10px; }
.tm-progress-line .tm-bar { flex: 1; }
.tm-progress-line span { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------------ slots */

.tm-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 10px; }
.tm-slot {
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #1a1714;
  padding: 10px 11px;
  display: grid;
  gap: 7px;
  min-height: 116px;
  transition: border-color .15s ease;
}
.tm-slot.running { border-color: rgba(255, 90, 46, .55); box-shadow: 0 0 0 1px rgba(255, 90, 46, .12) inset; }
.tm-slot.ok { border-color: rgba(65, 209, 154, .35); }
.tm-slot.err { border-color: rgba(255, 111, 97, .45); }
.tm-slot-top { display: flex; align-items: center; gap: 6px; }
.tm-slot-no {
  font-family: var(--mono); font-size: 10.5px; color: #ffb59c;
  background: var(--accent-soft); border-radius: 5px; padding: 1px 5px;
}
.tm-slot-title { font-size: 12px; font-weight: 650; color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-slot-meta { font-size: 10.5px; color: var(--muted-2); display: flex; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.tm-slot-out {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  background: #131110; border: 1px solid var(--border-soft); border-radius: 7px;
  padding: 6px 7px; max-height: 76px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.tm-slot-actions { display: flex; gap: 5px; }
.tm-slot-actions .btn { padding: 3px 7px; font-size: 10.5px; border-radius: 6px; }
.tm-slot details summary { cursor: pointer; font-size: 10.5px; color: var(--muted-2); }
.tm-slot details textarea { margin-top: 6px; font-size: 11px; min-height: 70px; }

/* ------------------------------------------------------------------ chunks */

.tm-chunks { display: grid; gap: 10px; }
.tm-chunk {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #1a1714;
  padding: 12px 14px;
}
.tm-chunk.ok { border-color: rgba(65, 209, 154, .32); }
.tm-chunk.fail { border-color: rgba(255, 111, 97, .42); }
.tm-chunk.running { border-color: rgba(255, 90, 46, .45); }
.tm-chunk-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tm-chunk-no { font-family: var(--mono); font-size: 11px; color: #ffb59c; }
.tm-chunk-title { font-size: 12.5px; font-weight: 650; }
.tm-chunk-meta { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--muted-2); }
.tm-dots { display: flex; gap: 4px; margin: 9px 0 2px; flex-wrap: wrap; }
.tm-dot {
  flex: 1 1 0; min-width: 22px; height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #141210;
  color: var(--muted-2);
  font-size: 9.5px;
  display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
  position: relative;
  transition: all .15s ease;
}
.tm-dot.run { border-color: rgba(255, 90, 46, .6); color: #ffb59c; background: rgba(255, 90, 46, .1); }
.tm-dot.pass { border-color: rgba(65, 209, 154, .45); color: #7ff0c4; background: rgba(65, 209, 154, .09); }
.tm-dot.fix { border-color: rgba(242, 180, 92, .5); color: #ffd49a; background: rgba(242, 180, 92, .1); }
.tm-dot.fail { border-color: rgba(255, 111, 97, .5); color: #ffb0a6; background: rgba(255, 111, 97, .1); }
.tm-dot.skip { opacity: .4; }
.tm-round-now { font-size: 11px; color: var(--muted); min-height: 16px; margin-top: 6px; }
.tm-chunk-log { margin-top: 8px; font-size: 11px; color: var(--muted); }
.tm-chunk-log details summary { cursor: pointer; color: var(--muted-2); font-size: 10.5px; }
.tm-log-line { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px dashed #221d19; font-size: 10.5px; }
.tm-log-line:last-child { border-bottom: 0; }
.tm-log-line .r { color: #ffb59c; font-family: var(--mono); flex: 0 0 34px; }
.tm-log-line .m { flex: 1; }
.tm-issue { color: #ffb0a6; }

/* ------------------------------------------------------------------ final */

.tm-final-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tm-final-text {
  width: 100%;
  min-height: 340px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  background: #100e0c !important;
  border-radius: 10px;
  padding: 12px;
  color: #e8ddd1;
}
.tm-badge-row { display: flex; gap: 7px; flex-wrap: wrap; margin: 10px 0; }
.tm-badge {
  font-size: 10.5px; padding: 3px 8px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--muted);
  background: #1a1714; font-variant-numeric: tabular-nums;
}
.tm-badge b { color: #ffd9c7; }

/* ------------------------------------------------------------------ history */

.tm-history { display: grid; gap: 8px; }
.tm-hist-item {
  display: flex; gap: 10px; align-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 11px;
  background: #1a1714;
  font-size: 11.5px;
  cursor: pointer;
}
.tm-hist-item:hover { border-color: #4a4038; }
.tm-hist-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-hist-item .d { color: var(--muted-2); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ legend */

.tm-legend { display: grid; gap: 6px; margin-top: 10px; }
.tm-legend-row { display: flex; gap: 8px; font-size: 11px; color: var(--muted); align-items: baseline; }
.tm-legend-row .n {
  flex: 0 0 30px; font-family: var(--mono); color: #ffb59c; font-size: 10px;
}
.tm-legend-row .tag {
  flex: 0 0 auto; font-size: 9.5px; border-radius: 4px; padding: 0 4px;
  border: 1px solid var(--border); color: var(--muted-2);
}
.tm-legend-row .tag.ai { color: #ffc09f; border-color: rgba(255, 90, 46, .35); }

/* ------------------------------------------------------------------ switch */

.tm-check { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.tm-check input { accent-color: var(--accent); }

@media (max-width: 900px) {
  .tm-hero { grid-template-columns: 1fr; }
  .tm-hero-stats { grid-template-columns: repeat(2, 1fr); }
  .tm-grid2, .tm-grid3 { grid-template-columns: 1fr; }
  .tm-span2 { grid-column: auto; }
  .tm-hero h1 { font-size: 26px; }
}
@media (max-width: 560px) {
  body.tokenmax .tokenmax-wrap { padding: 20px 13px 70px; }
  .tm-slots { grid-template-columns: 1fr; }
  .tm-dot { min-width: 17px; font-size: 8.5px; }
}

/* native controls follow the warm accent */
body.tokenmax input[type="range"] { accent-color: #ff5a2e; }
body.tokenmax ::selection { background: rgba(255, 90, 46, .35); }
body.tokenmax .switch input:checked + span { background: #ff5a2e; border-color: #ff5a2e; }
