:root {
  --back: #1b0714; --bg: #300a24; --bar: #2b2b2b; --bartext: #bbb; --fg: #eeeeec; --ok: #fff; --out: #d3d0d2;
  --dim: #8d7f89; --todo: #7d6676; --green: #8ae234; --blue: #729fcf; --red: #ef2929; --yellow: #fce94f; --line: #4a2a40;
  --mono: "Ubuntu Mono", "JetBrains Mono", "D2Coding", Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dracula"] {
  --back: #191a21; --bg: #282a36; --bar: #21222c; --bartext: #b9bbcb; --fg: #f8f8f2; --ok: #fff; --out: #d6d6e0;
  --dim: #7c88b5; --todo: #6272a4; --green: #50fa7b; --blue: #bd93f9; --red: #ff5555; --yellow: #f1fa8c; --line: #44475a;
}
:root[data-theme="nord"] {
  --back: #232831; --bg: #2e3440; --bar: #3b4252; --bartext: #c3cad8; --fg: #eceff4; --ok: #fff; --out: #d8dee9;
  --dim: #8792a8; --todo: #677691; --green: #a3be8c; --blue: #88c0d0; --red: #bf616a; --yellow: #ebcb8b; --line: #434c5e;
}
:root[data-theme="solarized"] {
  --back: #001f27; --bg: #002b36; --bar: #073642; --bartext: #93a1a1; --fg: #eee8d5; --ok: #fdf6e3; --out: #93a1a1;
  --dim: #6c8189; --todo: #56737c; --green: #9bb300; --blue: #3a9be0; --red: #dc322f; --yellow: #d9a400; --line: #0e4450;
}
:root[data-theme="matrix"] {
  --back: #020a02; --bg: #000; --bar: #0a140a; --bartext: #49b049; --fg: #b6ffb6; --ok: #eaffea; --out: #39d353;
  --dim: #2f8a2f; --todo: #1f6b1f; --green: #00ff41; --blue: #00d0a8; --red: #ff3b3b; --yellow: #d4ff5a; --line: #123312;
}
:root[data-theme="light"] {
  --back: #d9d2bf; --bg: #fdf6e3; --bar: #eee8d5; --bartext: #586e75; --fg: #073642; --ok: #000; --out: #4f656c;
  --dim: #7f9092; --todo: #a8b3b0; --green: #4f7a00; --blue: #1f73b7; --red: #dc322f; --yellow: #a85400; --line: #d8d1bb;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--back); color: var(--fg); font: 15px/1.45 var(--mono); display: flex; justify-content: center; align-items: center; overflow: hidden; }
.win { position: relative; width: 100%; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.grip, .fsbtn { display: none; }
/* 데스크톱: 창처럼 띄우고 오른쪽 아래 모서리로 크기 조절 (--w/--h 는 app.js 가 넣는다) */
@media (min-width: 700px) {
  .win {
    width: var(--w, 1000px); height: var(--h, calc(100dvh - 48px));
    min-width: 420px; min-height: 260px; max-width: 100vw; max-height: 100dvh;
    border-radius: 10px; overflow: hidden; box-shadow: 0 20px 60px #000a;
  }
  .grip {
    display: block; position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none;
    background: linear-gradient(135deg, transparent 50%, var(--dim) 50%, var(--dim) 58%, transparent 58%, transparent 70%, var(--dim) 70%, var(--dim) 78%, transparent 78%);
    opacity: .6;
  }
  .grip:hover { opacity: 1; }
  .keys { padding-right: 24px; }
}
.fsbtn.can { display: inline-flex; align-items: center; background: none; border: 0; color: var(--bartext); padding: 2px 4px; cursor: pointer; border-radius: 4px; }
.fsbtn:hover { color: var(--fg); background: var(--line); }
.theme { font: inherit; font-size: 12px; color: var(--bartext); background: var(--bar); border: 1px solid var(--line); border-radius: 4px; padding: 1px 2px; cursor: pointer; }
.theme:hover { color: var(--fg); }
body.fs .win { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; box-shadow: none; }
body.fs .grip { display: none; }
body.resizing { user-select: none; cursor: nwse-resize; }

.bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--bar); flex: none; }
.dots { display: flex; gap: 6px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #5a5a5a; }
.dots i:first-child { background: #e95420; }
.title { flex: 1; min-width: 0; color: var(--bartext); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.stats { display: flex; gap: 14px; font-size: 13px; color: var(--bartext); white-space: nowrap; }
.stats b { color: var(--yellow); font-weight: 700; display: inline-block; min-width: 2ch; text-align: right; }

.opts { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  font: inherit; font-size: 13px; color: var(--dim); background: none; border: 1px solid var(--line);
  border-radius: 4px; padding: 2px 8px; cursor: pointer;
}
.chips button:hover { color: var(--fg); }
.chips button.on { color: var(--bg); background: var(--green); border-color: var(--green); font-weight: 700; }

.term { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; cursor: text; scrollbar-color: var(--line) transparent; }
.line { white-space: pre-wrap; word-break: break-all; }
.out { margin: 0; font: inherit; white-space: pre; overflow-x: auto; color: var(--out); scrollbar-width: none; }
.out::-webkit-scrollbar { display: none; }
.out.sys { color: var(--dim); }
.out.res { color: var(--fg); }
.entry { margin-bottom: 2px; }
.entry.skip .cmd { color: var(--dim); text-decoration: line-through; }
.pu { color: var(--green); font-weight: 700; }
.pd { color: var(--blue); font-weight: 700; }

.now { position: relative; font-size: 18px; padding: 6px 0; }
.now .todo { color: var(--todo); }
.now .ok { color: var(--ok); }
.now .bad { color: #fff; background: var(--red); border-radius: 2px; }
.now .cur { background: var(--fg); color: var(--bg); animation: blink 1.1s steps(1) infinite; }
.now .ret { color: var(--green); margin-left: 6px; font-size: 14px; }
.now.shake { animation: shake .18s linear; }
@keyframes blink { 50% { background: transparent; color: var(--todo); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
#inp { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0; outline: 0; opacity: 0; font-size: 16px; }
.ime { color: var(--yellow); font-size: 13px; }

.keys { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; flex: none; }
.keys .note { margin-left: auto; }
kbd { font: inherit; color: var(--fg); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }

@media (max-width: 600px) {
  body { font-size: 13px; }
  .now { font-size: 16px; }
  .dots, .keys .note { display: none; }
  .opts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips { flex-wrap: nowrap; }
  .chips button { white-space: nowrap; }
}
