:root {
  /* default: dark */
  --bg: #0b1320;
  --panel: #121a2a;
  --text: #e8eefc;
  --muted: #a9b7d0;
  --accent: #5aa9ff;
  --btn: #1e88e5;
  --line: rgba(255,255,255,0.08);
}

[data-theme="light"] {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #0c1424;
  --muted: #53617a;
  --accent: #2f6df6;
  --btn: #2f6df6;
  --line: rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; padding: 0;
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  background: radial-gradient(1000px 600px at 20% -20%, rgba(31,43,69,0.9), var(--bg));
  color: var(--text);
}

.header { text-align: center; padding: 28px 16px 8px; position: relative; }
.header h1 { margin: 0; font-size: 28px; font-weight: 700; }
.header .sub { margin: 6px 0 0; color: var(--muted); }
.header-actions {
  display: flex; gap: 8px; justify-content: center; margin-top: 10px;
}

.container { max-width: 1000px; margin: 0 auto; padding: 12px 16px 40px; }
.panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px; padding: 16px; margin: 12px 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25), inset 0 0 0 1px rgba(255,255,255,0.02);
  backdrop-filter: saturate(140%) blur(10px);
  transition: transform 120ms ease, box-shadow 160ms ease, background 200ms ease;
}
.panel:hover { transform: translateY(-1px); box-shadow: 0 14px 36px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.03); }
.panel-title { font-weight: 700; margin-bottom: 10px; color: var(--muted); }

.label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--muted); }
.hint { color: var(--muted); margin: 8px 0 0; font-size: 13px; }

.textarea {
  width: 100%; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.3); color: var(--text);
  border-radius: 10px; padding: 12px; font-size: 18px; line-height: 1.5;
  resize: vertical; outline: none;
}
.textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(90,169,255,0.15); }

.controls { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.control { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.control input[type="text"] { width: 60px; padding: 6px 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12); background: rgba(0,0,0,0.3); color: var(--text); }
.sep-input { width: 120px; font-size: 18px; text-align: center; }
.control input[type="text"]:focus { border-color: var(--accent); outline: none; }
.sep-preview { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); background: rgba(0,0,0,0.25); font-weight: 600; }
.chips { display: flex; gap: 8px; align-items: center; }
.chip { border: 1px solid var(--line); background: rgba(0,0,0,0.25); color: var(--text); border-radius: 999px; padding: 4px 10px; cursor: pointer; transition: transform 100ms ease, box-shadow 160ms ease, background 150ms ease; }
.chip:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,0.25); }
.chip.active { background: var(--accent); color: #fff; }

.sep-controls { display: flex; gap: 12px; align-items: center; }
.sep-controls.hidden { display: none; }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  background: var(--btn); color: white; border: none; border-radius: 10px;
  padding: 8px 14px; font-weight: 600; cursor: pointer; transition: transform 100ms ease, filter 120ms ease;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text); font-size: 18px;}
.btn-link { background: transparent; color: var(--accent); border: 0; text-decoration: none; padding: 8px 10px; }

.status { color: var(--muted); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top;
}
.table th { color: var(--muted); font-weight: 700; }
.table td .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

.interlinear { display: grid; gap: 12px; }
.inter-block { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(0,0,0,0.25); cursor: pointer; transition: transform 120ms ease, box-shadow 160ms ease; }
.inter-block:hover { outline: 2px solid rgba(90,169,255,0.25); transform: translateY(-1px) scale(1.01); box-shadow: 0 10px 24px rgba(0,0,0,0.25); }
.inter-block .line { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; white-space: pre-wrap; }
.inter-block .line.top { color: var(--text); }
.inter-block .line.bottom { color: var(--muted); }

.footer { text-align: center; color: var(--muted); padding: 20px 0 30px; }

/* drawers */
.drawer {
  position: fixed; top: 0; right: -420px; width: 420px; max-width: 92vw; height: 100%;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0,0,0,0.35);
  transition: right 200ms ease; z-index: 50; display: flex; flex-direction: column;
}
.drawer.open { right: 0; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px; border-bottom: 1px solid var(--line);
}
.drawer-title { font-weight: 700; }
.drawer-body { padding: 12px; overflow: auto; }

/* switches */
.switch { display: inline-flex; align-items: center; gap: 8px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: relative; width: 44px; height: 26px; border-radius: 999px;
  background: rgba(255,255,255,0.2); border: 1px solid var(--line);
  transition: background 150ms ease;
}
.switch .slider::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform 150ms ease;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch .switch-label { color: var(--muted); }

/* backdrop for drawers */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 40; }
[hidden].backdrop { display: none !important; }

@media (max-width: 640px) {
  .drawer { max-width: 100vw; width: 100vw; }
}

/* mapping grid */
.map-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.map-section { border: 1px solid var(--line); border-radius: 10px; }
.map-section .ttl { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-weight: 700; }
.map-section .body { padding: 10px; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.map-cell {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center;
  background: rgba(0,0,0,0.25); cursor: default;
}
.map-cell small { display: block; color: var(--muted); margin-top: 4px; }

/* 참조 패널 설명문에 위쪽 여백 추가 */
.drawer-body .hint {
  margin-top: 16px;
  display: block;
}

.hint a.btn {
  margin-left: 12px;
  margin-top: 8px;
}

/* history */
.history-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px;
  background: rgba(0,0,0,0.25); display: grid; gap: 6px;
}
.hist-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.hist-tools { display: flex; gap: 8px; }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 11px; color: var(--muted); }
.pin { color: var(--accent); }

.hidden { display: none; }

/* ---------- Light theme: switches made clearer ---------- */
.switch { cursor: pointer; } /* 포인터 커서로 상호작용 힌트 */

[data-theme="light"] .switch .slider {
  background: rgba(0,0,0,.07);          /* 오프 트랙이 흰 배경에 묻히지 않도록 */
  border-color: rgba(0,0,0,.18);        /* 경계 대비 강화 */
}

/* 토글 손잡이(thumb) 시각 강도 ↑ */
[data-theme="light"] .switch .slider::after {
  background: #fff;
  box-shadow:
    0 1px 1px rgba(0,0,0,.18),
    0 0 0 1px rgba(0,0,0,.08) inset;    /* 얇은 링으로 형태 또렷 */
}

/* 체크 시 트랙을 확실한 색으로, 포커스 링 추가 */
.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px rgba(90,169,255,.35);
}
[data-theme="light"] .switch input:checked + .slider {
  background: var(--accent);
}

/* 상태에 따라 라벨 색/두께로 ON/OFF를 더 분명히 */
.switch .switch-label { color: var(--muted); transition: color .15s ease, font-weight .15s ease; }
.switch input:checked + .slider + .switch-label {
  color: var(--text);
  font-weight: 600;
}

/* (선택) 호버 시 트랙 살짝 밝게 — 클릭 가능성 강화 */
label.switch:hover .slider { filter: brightness(1.06); }
