:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --line: #e2e5ea;
  --text: #14181f;
  --muted: #6b7482;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --live: #e5484d;
  --ok: #2b9a55;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --panel: #1b1f26;
    --panel-2: #232830;
    --line: #2e343e;
    --text: #e7eaef;
    --muted: #8b95a5;
    --accent: #4c8dff;
    --accent-ink: #0d1117;
    --live: #ff6369;
    --ok: #4cc06f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", "Malgun Gothic", Roboto, sans-serif;
}

button { font: inherit; cursor: pointer; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── 상단 바 ─────────────────────────────── */
.bar { display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 15px; letter-spacing: -.2px; color: var(--muted); }
.brand b { color: var(--text); font-weight: 700; }
.bar-right { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}
.badge.bad { color: var(--live); border-color: var(--live); }

/* ── 버튼 ───────────────────────────────── */
.ghost {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
}
.ghost:hover { background: var(--panel-2); }
.ghost.sm { padding: 4px 10px; font-size: 12.5px; }

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 16px;
  font-weight: 600;
}

/* ── 스테이지 ────────────────────────────── */
.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.status b { color: var(--text); }
.status.live { color: var(--live); font-weight: 600; }
.status.ok { color: var(--ok); font-weight: 600; }

.result {
  width: 100%;
  min-height: 62px;
  resize: vertical;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  font-family: var(--mono);
  font-size: 17px;
  line-height: 1.45;
}
.result:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.result::placeholder { font-family: inherit; font-size: 14px; color: var(--muted); }

.raw {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
  word-break: break-all;
}
.raw:not(:empty)::before { content: "원문 "; opacity: .65; }
.raw:not(:empty) { cursor: pointer; }
.raw:not(:empty):hover { color: var(--accent); }

.raw-row { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.raw-row .raw { flex: 1; min-height: 0; }

.mini {
  flex: none;
  font-size: 11.5px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
}
.mini:hover { color: var(--accent); border-color: var(--accent); }
.mini[hidden] { display: none; }

.actions { display: flex; gap: 8px; }
.actions.sub { gap: 6px; }
.actions.sub .ghost { flex: 1; padding: 7px 6px; font-size: 12.5px; white-space: nowrap; }

.ghost.wide { padding: 12px 18px; font-weight: 600; }
.ghost.wide.on { background: var(--live); color: #fff; border-color: transparent; }

.mic {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
}
.mic:disabled { opacity: .5; cursor: not-allowed; }
.mic.live { background: var(--live); color: #fff; }
.mic .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: currentColor; opacity: .85;
}
.mic.live .dot { animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(1.35); } }

/* ── 기록 ───────────────────────────────── */
.hist-wrap { display: flex; flex-direction: column; gap: 8px; }
.hist-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--muted);
}
.hist-head em { font-style: normal; opacity: .7; }
.hist-actions { display: flex; gap: 6px; }

.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hist li {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 13.5px;
  cursor: pointer;
}
.hist li:hover { border-color: var(--accent); }
.hist li span { flex: 1; word-break: break-word; }
.hist li .tag { font-family: inherit; font-size: 11px; color: var(--muted); flex: none; }
.hist li .copy {
  font-family: inherit; font-size: 11.5px; flex: none;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px;
}
.hist li .copy:hover { color: var(--accent); border-color: var(--accent); }

.note { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; }

/* ── 사전 모달 ───────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal[hidden] { display: none; }
.sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: min(620px, 100%);
  max-height: 88vh;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 15px; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.hint code { background: var(--panel-2); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); }

.dict-text {
  flex: 1;
  min-height: 320px;
  resize: vertical;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}

/* ── 토스트 ─────────────────────────────── */
.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  z-index: 60;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast[hidden] { display: none; }
.toast.bad { background: var(--live); color: #fff; }

.sel {
  font: inherit;
  font-size: 12.5px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
}
