:root {
  --bg: #14141a;
  --panel: #22222c;
  --cell: #2a2a36;
  --line: #3a3a48;
  --fg: #ffffff;
  --muted: #a0a0b0;
  --accent: #ffcc55;
  --gold: #e0b070;
  --r5: #8a6232;
  --r4: #5e4b8c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}
main { max-width: 1312px; margin: 0 auto; padding: 12px 16px 48px; }
button {
  font: inherit;
  color: #1d1d24;
  background: #e4e4ea;
  border: 1px solid #b8b8c4;
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #fff; }
button:disabled { opacity: 0.5; cursor: default; }
button.big { font-weight: bold; font-size: 15px; padding: 9px 20px; }
input, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}
input { font-size: 16px; padding: 4px 8px; }
input:focus, textarea:focus { outline: 2px solid #6d5aa8; outline-offset: -1px; }

.preview-wrap { background: #000; line-height: 0; }
#preview { width: 100%; height: auto; display: block; }

.panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 24px;
  margin: 12px 0 8px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-weight: bold; font-size: 15px; }
.field small { color: #888898; font-size: 11px; }
.row { display: flex; align-items: center; gap: 8px; }
.boss-thumb { width: 48px; height: 48px; object-fit: contain; }
.boss-label { color: #c8c8d8; font-size: 13px; min-width: 150px; white-space: pre-line; line-height: 1.35; }
.slots { display: flex; gap: 6px; }
.slot {
  width: 52px; height: 52px;
  background: var(--cell);
  border: 2px solid transparent;
  border-radius: 4px;
  display: grid; place-items: center;
}
.slot img { width: 48px; height: 48px; object-fit: contain; pointer-events: none; }
.slot.filled { cursor: grab; }
.slot.r5 { background: var(--r5); }
.slot.r4 { background: var(--r4); }
.slot.dragging { opacity: 0.4; }
.slot.over { border-color: var(--accent); }
.actions { margin-left: auto; display: flex; gap: 8px; align-self: center; }

.texts { display: grid; grid-template-columns: 2fr 3fr; gap: 12px; }
.text-box { display: flex; flex-direction: column; gap: 4px; }
.head { display: flex; justify-content: space-between; align-items: center; }
textarea { width: 100%; resize: vertical; padding: 6px 8px; font-size: 13px; }
.text-box.title textarea { flex: 1; }

.status {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #0c0c10; color: var(--muted);
  font-size: 12px; padding: 4px 16px;
}
.status.ok { color: #90e090; }
.status.err { color: #ff8080; }

dialog {
  background: #1e1e26; color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0; max-height: 86vh;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg-head, .dlg-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.dlg-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.dlg-foot { border-top: 1px solid var(--line); }
.spacer { flex: 1; }

#bossDialog { width: min(660px, calc(100vw - 32px)); }
.boss-list { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.boss-item {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--cell); color: var(--fg); border: 0; padding: 4px 8px;
}
.boss-item:hover:not(:disabled) { background: #34344a; }
.boss-item.selected { background: #3a2d52; }
.boss-item img { width: 80px; height: 80px; object-fit: contain; flex: none; }
.boss-item .ko { font-weight: bold; font-size: 16px; }
.boss-item .en { color: #c8c8d8; font-size: 13px; }
.boss-item .ver { color: var(--gold); font-size: 12px; }

#charDialog { width: min(840px, calc(100vw - 32px)); }
.char-grid {
  overflow-y: auto; padding: 8px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px;
}
.char {
  background: var(--cell); color: var(--fg); border: 3px solid transparent;
  padding: 0 0 2px; display: flex; flex-direction: column; align-items: center;
}
.char:hover { background: #34344a; }
.char img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.char.r5 img { background: var(--r5); }
.char.r4 img { background: var(--r4); }
.char span { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px; }
.char.picked { border-color: var(--accent); }
.char.picked span { color: var(--accent); }
/* 커서를 올리면 배경이 흰색이 되므로 이름은 검정 */
.char:hover:not(:disabled) span { color: #000; }

@media (max-width: 760px) {
  .texts { grid-template-columns: 1fr; }
  .actions { margin-left: 0; }
}
