:root {
  --bg: #0f1218;
  --bg2: #161a23;
  --card: #1b202b;
  --line: #2a3140;
  --text: #e8ecf3;
  --muted: #9aa3b5;
  --accent: #ff3d9a;
  --accent2: #6ea8ff;
  --ok: #3ccf7a;
  --bad: #ff6b6b;
  --sticker: 26px;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.hidden { display: none !important; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.brand { display: flex; gap: 14px; align-items: center; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .2px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.logo { display: grid; grid-template-columns: repeat(3, 10px); gap: 2px; padding: 3px; background: #000; border-radius: 6px; }
.logo i { width: 10px; height: 10px; border-radius: 2px; background: #ffd500; }
.logo i:nth-child(2), .logo i:nth-child(6) { background: #009b48; }
.logo i:nth-child(4), .logo i:nth-child(9) { background: #c41e3a; }
.logo i:nth-child(3) { background: #0051ba; }
.logo i:nth-child(7) { background: #ff5800; }
.logo i:nth-child(5) { background: #fff; }

.ghost { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; color: var(--muted); }
.ghost:hover { color: var(--text); border-color: #3b4458; }

/* layout */
.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 0; min-height: 0; }
.viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px 16px 16px; gap: 10px; }
.panel { border-left: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; overflow: auto; }

.hold-tip { font-size: 14px; color: var(--muted); padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.hold-tip b { color: var(--text); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--c); vertical-align: -1px; box-shadow: 0 0 0 1px #0008; }

.stage3d { position: relative; flex: 1; min-height: 300px; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #232a38 0%, #12161e 70%); border: 1px solid var(--line); }
.stage3d canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.view-hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); pointer-events: none; }
.view-buttons { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.chip-btn { background: #0008; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 12px; color: var(--muted); }
.chip-btn:hover { color: var(--text); }

.move-banner { position: absolute; left: 12px; top: 12px; right: 12px; display: flex; gap: 14px; align-items: center; max-width: 560px;
  background: #0b0e14cc; backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.mb-move { font: 800 34px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent); min-width: 64px; text-align: center; }
.mb-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.mb-desc { font-size: 15px; margin-top: 2px; }
.move-banner.done .mb-move { color: var(--ok); }

/* player */
.player { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 12px; }
.progress { position: relative; height: 8px; border-radius: 99px; background: #2a3140; margin: 4px 0 12px; overflow: visible; cursor: pointer; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .15s; }
.stage-ticks span { position: absolute; top: -3px; width: 2px; height: 14px; background: #ffffff55; border-radius: 1px; }
.player-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.transport { display: flex; gap: 6px; }
.transport button { width: 42px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #222836; font-size: 15px; }
.transport button:hover { background: #2a3142; }
.transport .play { width: 56px; background: var(--accent); border-color: var(--accent); color: #fff; font-size: 17px; }
.transport .play:hover { background: #ff5aab; }
.counter { font: 600 14px ui-monospace, Menlo, monospace; color: var(--muted); min-width: 80px; }
.speed, .check { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.speed input { width: 110px; accent-color: var(--accent); }
.check input { accent-color: var(--accent); }

/* panel */
.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg2); z-index: 2; }
.tab { flex: 1; padding: 13px 10px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.lead { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }

.palette { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 10px; border: 2px solid #0009; position: relative; box-shadow: 0 0 0 2px transparent; transition: transform .08s; }
.swatch:hover { transform: translateY(-1px); }
.swatch.sel { box-shadow: 0 0 0 3px var(--bg2), 0 0 0 5px var(--accent); }
.swatch .k { position: absolute; right: 3px; bottom: 1px; font-size: 10px; font-weight: 700; color: #0008; }
.swatch.unknown { background: repeating-linear-gradient(45deg, #3a4150, #3a4150 5px, #303644 5px, #303644 10px); }
.swatch.unknown .k { color: #fff8; }

.net-wrap { display: flex; justify-content: center; padding: 6px 0; user-select: none; -webkit-user-select: none; }
.net { display: grid; grid-template-columns: repeat(4, auto); grid-template-rows: repeat(3, auto); gap: 4px; touch-action: none; }
.face { display: grid; grid-template-columns: repeat(3, var(--sticker)); grid-template-rows: repeat(3, var(--sticker)); gap: 2px; padding: 3px; background: #000; border-radius: 6px; }
.st { border-radius: 4px; position: relative; }
.st.paintable { cursor: crosshair; }
.st.paintable:hover { outline: 2px solid #fff9; outline-offset: -2px; }
.st.unknown { background: repeating-linear-gradient(45deg, #3a4150, #3a4150 4px, #303644 4px, #303644 8px) !important; }
.st.bad { outline: 2px solid var(--bad) !important; outline-offset: -2px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { outline-color: #ff6b6b44; } }
.st.center::after { content: attr(data-l); position: absolute; inset: 0; display: grid; place-items: center; font: 700 11px ui-sans-serif, system-ui; color: #0007; }
.st.flash { animation: flash .5s; }
@keyframes flash { 0% { filter: brightness(2); } }
.net.mini { --sticker: 15px; margin: 0 auto; }
.net.mini .face { gap: 1px; padding: 2px; border-radius: 4px; }
.net.mini .st { border-radius: 2px; }
.net.mini .st.center::after { font-size: 8px; }

.howto { font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.howto summary { cursor: pointer; color: var(--text); }
.howto ul { margin: 8px 0 2px; padding-left: 18px; line-height: 1.5; }

.counts { display: flex; gap: 6px; flex-wrap: wrap; }
.count { display: flex; align-items: center; gap: 6px; font: 600 12px ui-monospace, Menlo, monospace; padding: 4px 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.count.ok { color: var(--ok); }
.count.bad { color: var(--bad); border-color: #ff6b6b55; }

.messages { display: flex; flex-direction: column; gap: 6px; }
.msg { font-size: 13px; line-height: 1.4; padding: 8px 11px; border-radius: 9px; background: #ff6b6b14; border: 1px solid #ff6b6b44; color: #ffc2c2; }
.msg.good { background: #3ccf7a14; border-color: #3ccf7a44; color: #b8f0cf; }

.actions { display: flex; }
.primary { background: var(--accent); border: 0; color: #fff; border-radius: 12px; padding: 10px 16px; font-weight: 700; }
.primary:hover:not(:disabled) { background: #ff5aab; }
.primary.big { flex: 1; padding: 14px; font-size: 16px; }

.tools { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; border-top: 1px dashed var(--line); }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tool-row button { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; font-size: 13px; }
.tool-row button:hover { border-color: #3b4458; }
.tool-row input { flex: 1; min-width: 0; background: #0f1218; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; color: var(--text); font: 13px ui-monospace, Menlo, monospace; }

/* solve pane */
.solve-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sh-title { font-size: 18px; font-weight: 700; }
.sh-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stage-pills { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.pill { font-size: 10.5px; padding: 6px 2px; text-align: center; border-radius: 7px; background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill .n { display: block; font-weight: 800; font-size: 13px; }
.pill.done { color: var(--ok); border-color: #3ccf7a55; }
.pill.now { color: #fff; border-color: var(--accent); background: #ff3d9a22; }

.current-step { background: var(--card); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; }
.current-step .cs-stage { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); font-weight: 700; }
.current-step .cs-title { font-size: 16px; font-weight: 700; margin: 3px 0 6px; }
.current-step .cs-text { font-size: 13.5px; line-height: 1.5; color: #cfd6e4; }
.current-step.finished { border-color: var(--ok); }
.current-step.finished .cs-stage { color: var(--ok); }

.steps { display: flex; flex-direction: column; gap: 8px; }
.stage-h { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 8px 0 0; font-weight: 700; display: flex; justify-content: space-between; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.step:hover { border-color: #3b4458; }
.step.now { border-color: var(--accent); }
.step.done { opacity: .62; }
.step-t { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.step-t .cnt { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
.part { margin-top: 6px; }
.part-l { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.moves { display: flex; flex-wrap: wrap; gap: 3px; }
.mv { font: 600 12.5px ui-monospace, Menlo, monospace; min-width: 30px; padding: 3px 5px; text-align: center; border-radius: 6px; background: #252b39; border: 1px solid transparent; }
.mv:hover { border-color: #fff5; }
.mv.done { background: #3ccf7a22; color: #8fe3b4; }
.mv.next { background: var(--accent); color: #fff; }
.already { font-size: 12px; color: var(--ok); margin-top: 4px; }

.mini-net-wrap { margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line); }
.mini-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-align: center; }

/* modal */
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 10; padding: 20px; }
.modal-card { position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 22px 26px; max-width: 560px; line-height: 1.55; font-size: 14.5px; }
.modal-card h2 { margin-top: 0; }
.modal .close { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 26px; color: var(--muted); }
.notation { border-collapse: collapse; width: 100%; }
.notation td { padding: 4px 8px; border-bottom: 1px solid var(--line); }
.muted { color: var(--muted); }

@media (max-width: 980px) {
  body { height: auto; overflow: auto; }
  .layout { grid-template-columns: 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .stage3d { min-height: 340px; flex: none; height: 52vh; }
}
@media (max-width: 520px) {
  :root { --sticker: 21px; }
  .top p { display: none; }
  .mb-move { font-size: 26px; min-width: 48px; }
  .mb-desc { font-size: 13px; }
  .view-hint { display: none; }
  .stage3d { height: 44vh; }
}

.sticky-now { position: sticky; top: 48px; z-index: 1; background: var(--bg2); display: flex; flex-direction: column; gap: 10px; padding: 8px 0 10px; margin: -8px 0 0; box-shadow: 0 10px 12px -10px #000a; }
.current-step .cs-text { max-height: 9.5em; overflow: auto; }
@media (max-width: 980px) { .sticky-now { position: static; box-shadow: none; } }
