/* 산나비 조선어 — 편집기 양식
 * 바탕은 마고 도시의 콘크리트빛, 강조색은 게임의 {Red} 표식 색(#C00A32) 하나만 쓴다.
 * 말칸 미리보기는 게임에서 뽑은 말칸 그림(ui/bubble_*.png)을 3배로 키워 쓴다.
 */

@font-face {
  font-family: "Chollima Pixel";
  src: url("fonts/ChollimaPixel.ttf") format("truetype");
  font-display: block;
}

:root {
  --canvas: #f2f1ee;
  --sheet: #ffffff;
  --sheet-hover: #fafaf8;
  --inset: #f7f6f3;
  --ink: #16181b;
  --ink-2: #4b5058;
  --ink-3: #7d828a;
  --ink-4: #a9adb3;
  --line: rgba(22, 24, 27, 0.09);
  --line-2: rgba(22, 24, 27, 0.16);
  --line-3: rgba(22, 24, 27, 0.28);
  --sanabi-red: #c00a32;
  --red-soft: rgba(192, 10, 50, 0.075);
  --red-line: rgba(192, 10, 50, 0.32);
  --ok: #22835d;
  --warn: #a36a00;
  --warn-soft: rgba(163, 106, 0, 0.09);
  --glass: rgba(255, 255, 255, 0.78);
  --shadow-pop: 0 0 0 1px rgba(22, 24, 27, 0.06), 0 8px 24px -6px rgba(22, 24, 27, 0.18), 0 2px 6px rgba(22, 24, 27, 0.06);
  --tag-pause: #6b7380;
  --tag-size: #3b5bb5;
  --tag-shake: #b3461f;
  --tag-wave: #1f7a8c;
  --tag-color: #c00a32;
  --tag-fx: #7a4bb0;
  --tag-key: #4b5058;

  --ui: "Pretendard Variable", Pretendard, "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  --mono: ui-monospace, "D2Coding", Consolas, "SF Mono", monospace;
  --side-w: 17.5rem;
  --top-h: 56px;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;
  /* 감쇠비 0.82 스프링 */
  --spring: linear(0, 0.0432, 0.1446, 0.2724, 0.4057, 0.5316, 0.6431, 0.7374, 0.8139, 0.8739, 0.9193, 0.9526, 0.976, 0.9917, 1.0017, 1.0074, 1.0102, 1.0111, 1.0107, 1.0096, 1.0082, 1.0068, 1.0053, 1.0041, 1);
  --spring-soft: linear(0, 0.0411, 0.1364, 0.2554, 0.3788, 0.4954, 0.5995, 0.6886, 0.7626, 0.8223, 0.8696, 0.9062, 0.934, 0.9547, 0.9699, 0.9807, 0.9884, 0.9935, 0.997, 0.9991, 1.0004, 1.0011, 1.0015, 1.0015, 1);
  --out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #111214;
    --sheet: #18191c;
    --sheet-hover: #1c1d21;
    --inset: #131417;
    --ink: #ecebe7;
    --ink-2: #b5b3ad;
    --ink-3: #85837e;
    --ink-4: #5d5c58;
    --line: rgba(255, 255, 255, 0.07);
    --line-2: rgba(255, 255, 255, 0.13);
    --line-3: rgba(255, 255, 255, 0.24);
    --sanabi-red: #e5375c;
    --red-soft: rgba(229, 55, 92, 0.12);
    --red-line: rgba(229, 55, 92, 0.42);
    --ok: #4cbf8b;
    --warn: #e0a43a;
    --warn-soft: rgba(224, 164, 58, 0.12);
    --glass: rgba(24, 25, 28, 0.74);
    --shadow-pop: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 12px 32px -8px rgba(0, 0, 0, 0.6);
    --tag-pause: #9aa1ac;
    --tag-size: #8aa4f0;
    --tag-shake: #f08a63;
    --tag-wave: #5cc3d6;
    --tag-color: #ff6b88;
    --tag-fx: #c09af0;
    --tag-key: #b5b3ad;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #111214;
  --sheet: #18191c;
  --sheet-hover: #1c1d21;
  --inset: #131417;
  --ink: #ecebe7;
  --ink-2: #b5b3ad;
  --ink-3: #85837e;
  --ink-4: #5d5c58;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --line-3: rgba(255, 255, 255, 0.24);
  --sanabi-red: #e5375c;
  --red-soft: rgba(229, 55, 92, 0.12);
  --red-line: rgba(229, 55, 92, 0.42);
  --ok: #4cbf8b;
  --warn: #e0a43a;
  --warn-soft: rgba(224, 164, 58, 0.12);
  --glass: rgba(24, 25, 28, 0.74);
  --shadow-pop: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 12px 32px -8px rgba(0, 0, 0, 0.6);
  --tag-pause: #9aa1ac;
  --tag-size: #8aa4f0;
  --tag-shake: #f08a63;
  --tag-wave: #5cc3d6;
  --tag-color: #ff6b88;
  --tag-fx: #c09af0;
  --tag-key: #b5b3ad;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--ui);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss06";
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
code, kbd { font-family: var(--mono); font-size: 0.86em; }
code { padding: 0.08em 0.35em; border-radius: 4px; background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

.px {
  font-family: "Chollima Pixel", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: none;
  font-smooth: never;
  font-weight: 400;
  letter-spacing: 0;
  font-synthesis: none;
}

/* ───────── 머리띠 ───────── */

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px 20px;
  height: var(--top-h);
  padding: 0 16px 0 20px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.star { display: block; width: 20px; height: 20px; }
.title { font-size: 16px; line-height: 16px; white-space: nowrap; transform: translateY(1px); }

.tabs { position: relative; display: flex; gap: 2px; flex: none; height: 100%; align-items: stretch; }
.tab {
  position: relative;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-weight: 500;
  font-size: 14px;
  transition: color 160ms var(--out);
}
.tab:hover { color: var(--ink-2); }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tab-ink {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 10px;
  background: var(--ink);
  border-radius: 2px;
  transform-origin: 0 0;
  transition: transform 520ms var(--spring), width 520ms var(--spring);
}

.meter { display: flex; align-items: center; gap: 10px; flex: 1 1 10rem; min-width: 8rem; max-width: 22rem; margin-left: auto; }
.meter-bar { position: relative; flex: 1; height: 4px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.meter-fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0); background: var(--ink); border-radius: inherit; transition: transform 700ms var(--spring-soft); }
.meter-text { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-text b { color: var(--ink); font-weight: 600; }

.actions { display: flex; align-items: center; gap: 6px; flex: none; }
.saved { font-size: 12px; color: var(--ink-4); white-space: nowrap; margin-right: 4px; font-variant-numeric: tabular-nums; transition: opacity 300ms; }
.saved.is-bad { color: var(--sanabi-red); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 140ms var(--out), box-shadow 140ms var(--out), transform 160ms var(--spring);
}
.btn:hover { background: var(--sheet-hover); box-shadow: inset 0 0 0 1px var(--line-3); }
.btn:active { transform: scale(0.97); }
.btn-main { background: var(--ink); color: var(--canvas); box-shadow: none; }
.btn-main:hover { background: var(--ink); box-shadow: none; opacity: 0.9; }
.btn-icon { width: 32px; padding: 0; color: var(--ink-2); }
.btn-icon svg { fill: currentColor; }
.btn-wide { width: 100%; }

/* 설정 판 */
.more {
  position: fixed;
  inset: auto;
  top: calc(var(--top-h) + 6px);
  right: 12px;
  left: auto;
  margin: 0;
  width: 18.5rem;
  padding: 16px;
  border: 0;
  border-radius: var(--r-l);
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  display: none;
  gap: 14px;
  transform-origin: calc(100% - 20px) -6px;
}
.more:popover-open { display: grid; animation: pop-in 380ms var(--spring) both; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96) translateY(-4px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
.field { display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.field input[type="text"] {
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-s);
  background: var(--inset);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--ink);
  font-size: 14px;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.check input { accent-color: var(--ink); width: 15px; height: 15px; margin: 0; }
.more-foot { margin: 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }

/* 나눔 단추(segmented) */
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); }
.seg-full { display: flex; }
.seg-full label { flex: 1; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  text-align: center;
  white-space: nowrap;
  transition: background-color 160ms var(--out), color 160ms var(--out), box-shadow 160ms var(--out);
}
.seg label:hover span { color: var(--ink-2); }
.seg input:checked + span { background: var(--sheet); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.06); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ───────── 화면 바꾸기 ───────── */

.view { animation: view-in 420ms var(--spring-soft) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ───────── 번역 ───────── */

.view-tr { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); align-items: start; }

.side {
  position: sticky;
  top: var(--top-h);
  height: calc(100vh - var(--top-h));
  height: calc(100dvh - var(--top-h));
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.side-tools { display: grid; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--line); }

#search {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-s);
  background: var(--sheet);
  box-shadow: inset 0 0 0 1px var(--line-2);
  font-size: 14px;
}
#search:focus { box-shadow: inset 0 0 0 1px var(--line-3); }

.groups { flex: 1; overflow-y: auto; padding: 6px 6px 40px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

.chapter { margin-bottom: 2px; }
.chapter > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--r-s);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.chapter > summary::-webkit-details-marker { display: none; }
.chapter > summary:hover { background: var(--line); }
.chev { flex: none; width: 10px; height: 10px; color: var(--ink-3); transition: transform 360ms var(--spring); }
.chapter[open] > summary .chev { transform: rotate(90deg); }
.chapter > summary .cnt { margin-left: auto; }
.chapter-body { padding: 2px 0 6px; }
.chapter[open] .chapter-body { animation: fold-in 360ms var(--spring-soft) both; }
@keyframes fold-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.cnt { font-size: 12px; font-weight: 400; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

.grp {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px 5px 26px;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  text-align: left;
  font-size: 13px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
  transition: background-color 120ms var(--out);
}
.grp-name { flex: 1; min-width: 0; }
.grp:hover { background: var(--line); }
.grp.is-current { background: var(--sheet); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.04); }
.grp::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--ink-4);
}
.grp.is-part::before { box-shadow: inset 0 0 0 1.5px var(--ink-2); background: linear-gradient(90deg, var(--ink-2) 50%, transparent 50%); }
.grp.is-done::before { background: var(--ok); box-shadow: none; }
.grp.is-done .cnt { color: var(--ok); }

.work { min-width: 0; padding-bottom: 120px; }

.work-head {
  position: sticky;
  top: var(--top-h);
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  min-height: 56px;
  padding: 10px 24px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.work-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.work-head .cnt { font-size: 13px; }
.work-tools { display: flex; gap: 6px; margin-left: auto; }
.work-tools .btn { height: 30px; font-size: 13px; }

.row {
  position: relative;
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) minmax(0, 1.12fr);
  gap: 0 20px;
  padding: 14px 24px 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--sheet);
  transition: background-color 160ms var(--out);
}
.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ok);
  transition: background-color 200ms var(--out);
}
.row.is-todo::before { background: var(--sanabi-red); }
.row.is-warn::before { background: var(--warn); }
.row.is-nosrc::before { background: var(--line-2); }
.row.is-nosrc { background: transparent; }
.row.is-active { background: var(--sheet-hover); }

.row-meta { display: grid; align-content: start; gap: 2px; font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; padding-top: 2px; }
.row-name { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.row-kind { display: inline-block; justify-self: start; padding: 0 5px; border-radius: 4px; background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); font-size: 11px; color: var(--ink-3); }
.row-where { margin-top: 4px; padding: 0; border: 0; background: none; color: var(--ink-3); font-size: 11.5px; text-align: left; text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 2px; }
.row-where:hover { color: var(--ink); }

.row-src { min-width: 0; }
.src-ko { margin: 0; font-size: 15.5px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.src-en { margin: 4px 0 0; font-size: 13px; line-height: 1.6; color: var(--ink-3); white-space: pre-wrap; overflow-wrap: anywhere; }
body.hide-en .src-en { display: none; }

/* 표식 꼬리표 */
.tag {
  --c: var(--tag-pause);
  position: relative;
  display: inline-block;
  margin: 0 1px;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: color-mix(in srgb, var(--c) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent);
  color: var(--c);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 18px;
  vertical-align: 1px;
  white-space: nowrap;
  transition: background-color 120ms var(--out), transform 160ms var(--spring);
}
.tag:hover { background: color-mix(in srgb, var(--c) 18%, transparent); }
.tag:active { transform: scale(0.94); }
.tag[data-kind="pause"], .tag[data-kind="dots"], .tag[data-kind="speed"] { --c: var(--tag-pause); }
.tag[data-kind="size"] { --c: var(--tag-size); }
.tag[data-kind="shake"], .tag[data-kind="impulse"] { --c: var(--tag-shake); }
.tag[data-kind="wave"] { --c: var(--tag-wave); }
.tag[data-kind="color"] { --c: var(--tag-color); }
.tag[data-kind="error"], .tag[data-kind="flicker"], .tag[data-kind="material"], .tag[data-kind="sprite"] { --c: var(--tag-fx); }
.tag[data-kind="key"], .tag[data-kind="tmp"], .tag[data-kind="unknown"] { --c: var(--tag-key); }
span.tag { cursor: default; }

/* 꼬리표 풀이(마우스를 올리면) */
.tip {
  position: fixed;
  z-index: 60;
  max-width: 17rem;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--canvas);
  font-size: 12.5px;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px) scale(0.98);
  transition: opacity 140ms var(--out), transform 220ms var(--spring);
}
.tip.is-on { opacity: 1; transform: none; }
.tip code { background: transparent; box-shadow: none; color: inherit; opacity: 0.7; padding: 0; }

.row-dst { min-width: 0; }
.row-dst textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--r-s);
  background: var(--inset);
  box-shadow: inset 0 0 0 1px var(--line-2);
  font-size: 15.5px;
  line-height: 1.6;
  resize: none;
  overflow: hidden;
  transition: box-shadow 140ms var(--out), background-color 140ms var(--out);
}
.row-dst textarea:hover { box-shadow: inset 0 0 0 1px var(--line-3); }
.row-dst textarea:focus { outline: none; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--ink), 0 0 0 3px var(--line); }
.row-dst textarea.is-flash { animation: flash 700ms var(--out); }
@keyframes flash { from { background: var(--red-soft); } }

.row-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 6px; min-height: 24px; }
.mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 120ms var(--out), box-shadow 120ms var(--out), transform 160ms var(--spring), color 120ms;
}
.mini:hover { background: var(--sheet); box-shadow: inset 0 0 0 1px var(--line-3); color: var(--ink); }
.mini:active { transform: scale(0.96); }
.mini kbd { font-size: 10.5px; color: var(--ink-4); }
.mini-cr { color: var(--sanabi-red); box-shadow: inset 0 0 0 1px var(--red-line); }
.mini-cr:hover { color: var(--sanabi-red); background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--sanabi-red); }
.mini.is-busy { pointer-events: none; opacity: 0.6; }
.mini.is-busy::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.warn { flex: 1 1 12rem; min-width: 0; font-size: 12px; color: var(--warn); font-weight: 500; overflow-wrap: anywhere; text-align: right; }
.warn .miss { color: var(--sanabi-red); }

/* 미리보기 칸 */
.preview { margin-top: 12px; animation: fold-in 380ms var(--spring-soft) both; }
.pv-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: var(--ink-3); }
.pv-bar .seg span { padding: 2px 8px; font-size: 12px; }
.pv-bar .who { font-weight: 600; color: var(--ink-2); }
.pv-bar .mini { margin-left: auto; }
.pv-stage {
  display: flex;
  justify-content: flex-start;
  padding: 18px 18px 26px;
  border-radius: var(--r-m);
  background:
    linear-gradient(var(--pv-grid) 1px, transparent 1px) 0 0 / 12px 12px,
    linear-gradient(90deg, var(--pv-grid) 1px, transparent 1px) 0 0 / 12px 12px,
    var(--pv-bg);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
  cursor: pointer;
  --pv-bg: #2a2d33;
  --pv-grid: rgba(255, 255, 255, 0.035);
}

/* ───────── 말칸(게임 효과 재생) ───────── */

.sfx { max-width: 100%; }
.sfx-stage { position: relative; display: inline-block; max-width: 100%; font-size: 32px; will-change: transform; }
.sfx-box {
  min-width: 2.2em;
  max-width: 15em;
  padding: 2px 6px 4px;
  border-style: solid;
  border-width: 24px 27px 27px 27px;
  border-image: url("ui/bubble_white.png") 8 9 9 9 fill / 24px 27px 27px 27px stretch;
  image-rendering: pixelated;
  color: #17181a;
}
.sfx-text { font-size: 32px; line-height: 40px; overflow-wrap: anywhere; }
.sfx-line { min-height: 40px; }
.sfx-w { white-space: nowrap; }
.sfx-c { display: inline-block; white-space: pre; will-change: transform, opacity; }
.sfx-tail {
  position: absolute;
  left: 36px;
  bottom: -27px;
  width: 21px;
  height: 36px;
  background: url("ui/bubble_tail_white.png") 0 0 / 21px 36px no-repeat;
  image-rendering: pixelated;
  margin-top: -9px;
}
.sfx-stage.sfx-speech { padding-bottom: 8px; }
.sfx-messenger .sfx-box, .sfx-ui .sfx-box {
  border-image: none;
  border: 0;
  padding: 10px 14px;
  background: #0d0e10;
  box-shadow: inset 0 0 0 2px #3a3d43;
  color: #e8e8e6;
  max-width: 17em;
}
.sfx-messenger .sfx-text, .sfx-ui .sfx-text { font-size: 16px; line-height: 22px; }
.sfx-messenger .sfx-line, .sfx-ui .sfx-line { min-height: 22px; }
.sfx-miss { outline: 1.5px dashed #c00a32; outline-offset: -2px; color: rgba(192, 10, 50, 0.55); }
.sfx-key {
  padding: 0 0.22em;
  margin: 0 0.05em;
  border-radius: 3px;
  background: #17181a;
  color: #fff;
  font-family: var(--ui);
  font-size: 0.42em;
  line-height: 1.7;
  vertical-align: 0.2em;
}
.sfx-nemo { width: 0.6em; height: 0.6em; background: #000; vertical-align: -0.02em; }
.sfx-m-glitch, .sfx-m-glitch_black { text-shadow: 0.06em 0 rgba(255, 0, 64, 0.7), -0.06em 0 rgba(0, 220, 255, 0.7); }
.sfx-m-glitch_black { color: #000 !important; text-shadow: 0.06em 0 rgba(0, 0, 0, 0.55), -0.05em 0 rgba(120, 120, 120, 0.7); }
.sfx-m-noise { filter: contrast(1.4); }

/* ───────── 사전 ───────── */

.dict, .guide { max-width: 860px; margin: 0 auto; padding: 44px 24px 120px; }
.dict-title, .guide-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.025em; text-wrap: balance; }
.dict-sub, .guide-sub { margin: 6px 0 0; color: var(--ink-3); font-size: 14.5px; text-wrap: pretty; max-width: 40rem; }

.dict-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  height: 56px;
  padding: 0 16px;
  border-radius: var(--r-l);
  background: var(--sheet);
  box-shadow: 0 0 0 1px var(--line-2), 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px -16px rgba(0, 0, 0, 0.2);
  color: var(--ink-3);
  transition: box-shadow 180ms var(--out);
}
.dict-search:focus-within { box-shadow: 0 0 0 1px var(--ink), 0 0 0 4px var(--line), 0 8px 24px -16px rgba(0, 0, 0, 0.25); }
.dict-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 18px; color: var(--ink); }
.dict-search input::-webkit-search-cancel-button { cursor: pointer; }
.dict-search kbd { padding: 1px 7px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-4); font-size: 12px; }

.dict-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 140ms var(--out), color 140ms, box-shadow 140ms, transform 160ms var(--spring);
}
.chip:hover { background: var(--sheet); }
.chip:active { transform: scale(0.96); }
.chip .cnt { margin-left: 4px; font-size: 11.5px; }
.chip[aria-checked="true"] { background: var(--ink); color: var(--canvas); box-shadow: none; }
.chip[aria-checked="true"] .cnt { color: inherit; opacity: 0.6; }

.dict-body { margin-top: 26px; }

.conv-card {
  display: grid;
  gap: 4px;
  margin-bottom: 26px;
  padding: 18px 20px;
  border-radius: var(--r-l);
  background: var(--sheet);
  box-shadow: 0 0 0 1px var(--line);
  animation: rise 420ms var(--spring-soft) both;
}
.conv-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; color: var(--sanabi-red); }
.conv-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.conv-from { color: var(--ink-3); font-size: 15px; }
.conv-arrow { color: var(--ink-4); font-size: 14px; }
.conv-to { font-size: 24px; font-weight: 650; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.conv-to mark { background: var(--red-soft); color: inherit; border-radius: 3px; box-shadow: 0 2px 0 var(--red-line); }
.conv-note { font-size: 12.5px; color: var(--ink-3); }

.dsec { margin-bottom: 30px; animation: rise 460ms var(--spring-soft) both; }
.dsec:nth-of-type(2) { animation-delay: 50ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.dsec-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; padding: 0 4px; }
.dsec-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.dsec-head .cnt { font-size: 12.5px; }

.dlist { margin: 0; padding: 0; list-style: none; border-radius: var(--r-l); background: var(--sheet); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.dent {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 15.5px;
}
.dent:first-child { border-top: 0; }
.dent:hover { background: var(--sheet-hover); }
.dent .ko { color: var(--ink-2); overflow-wrap: anywhere; }
.dent .kp { font-weight: 600; overflow-wrap: anywhere; }
.dent .arw { color: var(--ink-4); text-align: center; font-size: 13px; }
.dent.is-exact { background: var(--red-soft); }
.dent mark { background: transparent; color: inherit; text-decoration: underline; text-decoration-color: var(--sanabi-red); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.dcat { padding: 1px 7px; border-radius: 5px; background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.copy-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  border-radius: 4px;
  cursor: copy;
}
.copy-btn:hover { text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 3px; }

.dict-more { display: flex; justify-content: center; margin-top: 12px; }
.dict-empty { padding: 36px 8px; color: var(--ink-3); text-align: center; font-size: 14.5px; }
.dict-hint { display: grid; gap: 4px; padding: 16px 18px; border-radius: var(--r-m); background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-3); font-size: 13.5px; margin-bottom: 26px; }

/* ───────── 표식 안내 ───────── */

.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 25rem), 1fr)); gap: 14px; margin-top: 28px; }
.gcard {
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: var(--r-l);
  background: var(--sheet);
  box-shadow: 0 0 0 1px var(--line);
  overflow: hidden;
  animation: rise 460ms var(--spring-soft) both;
}
.gcard-text { padding: 16px 18px 14px; }
.gcard h3 { margin: 0 0 4px; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.gcard p { margin: 0 0 10px; color: var(--ink-3); font-size: 13.5px; text-wrap: pretty; }
.gtags { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.gtags li { display: grid; grid-template-columns: max-content 1fr; align-items: baseline; gap: 10px; font-size: 13px; color: var(--ink-2); }
.gtags .tag { justify-self: start; }
.gcard .pv-stage { border-radius: 0; box-shadow: none; padding: 16px 18px 26px; align-items: flex-start; min-height: 120px; }
.guide-rules { margin-top: 36px; padding: 20px 22px; border-radius: var(--r-l); background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); }
.guide-rules h2 { margin: 0 0 8px; font-size: 15px; }
.guide-rules ul { margin: 0; padding-left: 1.2em; color: var(--ink-2); font-size: 14px; display: grid; gap: 6px; }

/* ───────── 알림 ───────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(36rem, calc(100vw - 32px));
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--canvas);
  font-size: 13.5px;
  box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
  animation: toast-in 460ms var(--spring) both;
}
.toast.is-out { animation: toast-out 220ms var(--out) both; }
.toast.is-bad .toast-text::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--sanabi-red); vertical-align: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px) scale(0.97); filter: blur(3px); } to { opacity: 1; transform: translate(-50%, 0); filter: none; } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 6px) scale(0.98); filter: blur(2px); } }
.toast-act { flex: none; height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: rgba(127, 127, 127, 0.28); color: inherit; font-size: 12.5px; font-weight: 600; }
.toast-act:hover { background: rgba(127, 127, 127, 0.42); }

/* ───────── 없는 글자 창 ───────── */

.sheet { width: min(34rem, 92vw); max-height: 82vh; padding: 22px 24px; border: 0; border-radius: var(--r-l); background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-pop); }
.sheet[open] { animation: pop-in 380ms var(--spring) both; }
.sheet::backdrop { background: rgba(10, 11, 12, 0.36); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet h2 { margin: 0 0 4px; font-size: 17px; }
.sheet-note { margin: 0 0 14px; color: var(--ink-3); font-size: 13.5px; }
.sheet .btn { margin-top: 16px; }
.glyph-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 46vh; overflow-y: auto; }
.glyph { display: flex; align-items: baseline; gap: 6px; padding: 4px 10px; border: 0; border-radius: var(--r-s); background: var(--inset); box-shadow: inset 0 0 0 1px var(--line); }
.glyph:hover { box-shadow: inset 0 0 0 1px var(--line-3); }
.glyph b { font-size: 20px; color: var(--sanabi-red); }

.empty { padding: 56px 24px; color: var(--ink-3); max-width: 38rem; font-size: 14.5px; }
.empty strong { color: var(--ink); }

/* ───────── 좁은 화면 ───────── */

@media (max-width: 1100px) {
  .meter { display: none; }
  .saved { display: none; }
}

@media (max-width: 900px) {
  :root { --top-h: 52px; }
  .top { padding: 0 10px 0 14px; gap: 8px; }
  .title { display: none; }
  .tab { padding: 0 9px; }
  .actions { margin-left: auto; }
  #btnOpen { display: none; }
  .view-tr { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; max-height: 15rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .work-head { top: var(--top-h); padding: 10px 16px; }
  .work-tools { margin-left: 0; width: 100%; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 14px 16px 14px 18px; }
  .row-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
  .dict, .guide { padding: 28px 16px 100px; }
  .dict-title, .guide-title { font-size: 23px; }
  .dict-search kbd { display: none; }
  .dent { grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr); padding: 10px 12px; font-size: 15px; }
  .dent .dcat { grid-column: 1 / -1; justify-self: start; }
  .sfx-stage { font-size: 16px; }
  .sfx-text { font-size: 16px; line-height: 22px; }
  .sfx-line { min-height: 22px; }
  .sfx-box { border-width: 16px 18px 18px 18px; border-image-width: 16px 18px 18px 18px; padding: 0 4px 2px; }
  .sfx-tail { width: 14px; height: 24px; background-size: 14px 24px; bottom: -18px; left: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
