:root {
  --bg: #14161a;
  --panel: #1d2026;
  --panel-2: #262a32;
  --line: #333844;
  --text: #e6e8ec;
  --muted: #9097a3;
  --accent: #6aa84f;
  --accent-2: #8fd16c;
  --danger: #e05252;
  --warn: #e0b252;
  --slot: #8b8b8b;
  --slot-dark: #373737;
  --slot-light: #ffffff;
  --slot-bg: #8b8b8b;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 700; }
h2 { font-size: 16px; }
h3 { font-size: 14px; margin: 0; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; margin: 6px 0 0; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.mt { margin-top: 18px; }
.error { color: var(--danger); min-height: 1.5em; margin: 8px 0 0; }
.warn { color: var(--warn); font-size: 13px; }
.label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }

input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; width: 100%; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
label > input, label > select, label > textarea { color: var(--text); font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text); cursor: pointer; }
.w60 { width: 64px; flex: none; }
.w100 { width: 110px; flex: none; }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 14px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d1a07; font-weight: 700; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: #3a1e1e; border-color: #6b2c2c; color: #ffb3b3; }
.btn.danger.ghost, .btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.on { background: var(--accent); color: #0d1a07; border-color: var(--accent); }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.row > input:not(.w60):not(.w100) { flex: 1; }

/* ---------------- 로그인 ---------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 22px; margin: 0; }
.login-card p { margin: 0; }

/* ---------------- 상단바 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button {
  background: none; border: none; color: var(--muted); font: inherit;
  padding: 8px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--panel-2); color: var(--text); }
.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.dot.ok { background: var(--accent-2); box-shadow: 0 0 8px var(--accent); }
.dot.bad { background: var(--danger); }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 16px; }
.cards .card { margin: 0; }
.stat .value { font-size: 26px; font-weight: 800; margin: 2px 0; }
.stat .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .label { margin: 0; }
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.good { color: var(--accent-2); }
.mid { color: var(--warn); }
.badv { color: var(--danger); }

.badge { background: var(--panel-2); border-radius: 10px; padding: 1px 8px; font-size: 12px; color: var(--muted); margin-left: 4px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel-2); }
.table .name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.table .name img { width: 24px; height: 24px; border-radius: 4px; image-rendering: pixelated; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); margin-right: 4px; }
.tag.op { background: #3b3218; color: #f1d27a; }
.tag.ban { background: #3a1e1e; color: #ffb3b3; }
.tag.wl { background: #1e3320; color: #a9e09b; }
.empty { margin: 10px 0 0; }

/* ---------------- 플레이어 상세 ---------------- */
.live { font-size: 12px; color: var(--accent-2); }
.live::before { content: "●"; margin-right: 6px; animation: pulse 1.6s infinite; }
.live.off { color: var(--muted); }
.live.off::before { animation: none; }
@keyframes pulse { 50% { opacity: .3; } }
.pd-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.pd-head h2 { margin: 0; font-size: 20px; }
.face { width: 48px; height: 48px; border-radius: 6px; image-rendering: pixelated; background: var(--panel-2); }
.pd-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pd-actions select, .pd-actions input { padding: 4px 8px; font-size: 12px; }

.inv-layout { display: grid; grid-template-columns: auto minmax(300px, 1fr); gap: 16px; align-items: start; }
.inv-card { width: fit-content; max-width: 100%; overflow-x: auto; }
.side-col { min-width: 0; }
.inv-player { display: flex; gap: 14px; }
.armor-col { display: grid; grid-template-columns: auto 44px; gap: 4px 8px; align-items: center; align-content: start; }
.slot-label { font-size: 11px; color: var(--muted); text-align: right; }
.grid9 { display: grid; grid-template-columns: repeat(9, 44px); gap: 4px; }
.grid9.hotbar { margin-top: 12px; }

.slot {
  width: 44px; height: 44px; position: relative;
  background: var(--slot-bg);
  border: 2px solid; border-color: var(--slot-dark) var(--slot-light) var(--slot-light) var(--slot-dark);
  display: grid; place-items: center; cursor: pointer; user-select: none;
}
.slot:hover { background: #a5a5a5; }
.slot.selected { outline: 3px solid var(--accent-2); outline-offset: 0; z-index: 1; }
.slot.drop-target { background: #c6e6b4; }
.slot.flash { animation: flash .6s; }
@keyframes flash { from { background: #f7e27a; } }
.slot img { width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.slot .txt { font-size: 9px; color: #222; text-align: center; line-height: 1.05; word-break: break-all; padding: 1px; pointer-events: none; }
.slot .cnt {
  position: absolute; right: 1px; bottom: -1px; font-size: 13px; font-weight: 700; color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f; pointer-events: none; font-family: ui-monospace, Consolas, monospace;
}
.slot .dur { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 3px; background: #000; pointer-events: none; }
.slot .dur > i { display: block; height: 100%; }
.slot.ench::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(120deg, transparent 30%, rgba(190, 120, 255, .35) 50%, transparent 70%);
}
.slot.big { width: 56px; height: 56px; cursor: default; }
.slot.big img { width: 40px; height: 40px; }

.trash {
  margin-top: 14px; border: 2px dashed #6b2c2c; color: #ffb3b3; border-radius: 8px;
  text-align: center; padding: 10px; font-size: 12px;
}
.trash.drop-target { background: #3a1e1e; }
.offline-note { color: var(--warn); }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  background: #100010f0; border: 2px solid #2a0a5e; border-radius: 4px;
  padding: 6px 9px; font-size: 13px; max-width: 280px; white-space: pre-line;
}
.tooltip .t-name { font-weight: 700; }
.tooltip .t-id { color: #777; font-size: 11px; }
.tooltip .t-ench { color: #a8a8ff; }
.tooltip .t-lore { color: #aa77dd; font-style: italic; }

.editor label { margin-bottom: 10px; }
.ed-preview { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.ench { margin: 4px 0 12px; }
.ench-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.ench-item input { width: 64px; padding: 3px 6px; }
.ench .row { margin-top: 8px; }
.ench select { flex: 1; }

.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 4px; margin-top: 10px; max-height: 420px; overflow-y: auto; }

/* ---------------- 콘솔 ---------------- */
.console-card { display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 400px; }
.console {
  flex: 1; overflow: auto; margin: 0 0 10px; background: #0b0c0e; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font: 12.5px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
.console .WARN { color: #e8c35a; }
.console .ERROR, .console .FATAL { color: #ff7a7a; }
.console .cmd { color: #8fd16c; }
.prompt { font-family: ui-monospace, Consolas, monospace; color: var(--accent-2); }

/* ---------------- 설정 ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.gamerules { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 16px; margin-top: 10px; }
.gr-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.gr-item .gr-name { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.gr-item input[type=number] { width: 90px; padding: 3px 6px; }
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 6px 16px; }
.prop { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); }
.prop span { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.prop input { padding: 4px 8px; }
.prop.changed input { border-color: var(--warn); }

/* switch */
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; cursor: pointer; transition: .2s; }
.switch i::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::before { transform: translateX(16px); background: #fff; }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; max-width: 340px; box-shadow: 0 6px 20px #0008; }
.toast.err { border-left-color: var(--danger); }

@media (max-width: 1000px) {
  .inv-layout { grid-template-columns: 1fr; }
  .inv-card { width: auto; }
}
@media (max-width: 640px) {
  main { padding: 12px 16px; }
  .topbar { padding: 10px 16px; }
  .grid9 { grid-template-columns: repeat(9, 34px); }
  .armor-col { grid-template-columns: auto 34px; }
  .slot { width: 34px; height: 34px; }
  .slot img { width: 24px; height: 24px; }
  .table th:nth-child(n+5), .table td:nth-child(n+5) { display: none; }
  .table td:last-child { display: table-cell; }
}
