:root[data-theme="dark"] {
  --bg:#0f0f14; --surface:#1a1a22; --surface-2:#23232e; --hover:#2c2c39;
  --text:#ececf0; --text-2:#b4b4c0; --muted:#8a8a99;
  --accent:#6366f1; --accent-hover:#4f46e5; --accent-dim:rgba(99,102,241,.18);
  --border:#2e2e3a; --danger:#ef4444; --success:#22c55e;
  --shadow:0 10px 40px rgba(0,0,0,.5);
}
:root[data-theme="light"] {
  --bg:#f4f4f7; --surface:#ffffff; --surface-2:#f0f0f4; --hover:#e9e9ef;
  --text:#14141a; --text-2:#3a3a46; --muted:#71717a;
  --accent:#6366f1; --accent-hover:#4f46e5; --accent-dim:rgba(99,102,241,.1);
  --border:#e2e2ea; --danger:#ef4444; --success:#16a34a;
  --shadow:0 10px 40px rgba(0,0,0,.12);
}
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { height:100%; }
body {
  margin:0; background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Apple SD Gothic Neo',sans-serif;
  overflow:hidden; overscroll-behavior:none;
}
.hidden { display:none !important; }
button { font-family:inherit; cursor:pointer; }

/* ── 공통 버튼/입력 ── */
.btn {
  width:100%; padding:12px 16px; border:none; border-radius:12px;
  background:var(--accent); color:#fff; font-size:15px; font-weight:700;
  transition:background .15s, opacity .15s;
}
.btn:hover { background:var(--accent-hover); }
.btn:disabled { opacity:.45; cursor:not-allowed; }
.btn-danger { background:var(--danger); }
.icon-btn {
  width:38px; height:38px; border:none; border-radius:10px; background:var(--surface-2);
  color:var(--text); font-size:17px; display:inline-flex; align-items:center; justify-content:center;
  transition:background .15s;
}
.icon-btn:hover { background:var(--hover); }
.icon-btn.lang { width:auto; padding:0 11px; font-size:13px; font-weight:700; }
input {
  width:100%; padding:11px 13px; border:1px solid var(--border); border-radius:10px;
  background:var(--surface-2); color:var(--text); font-size:15px; outline:none;
}
input:focus { border-color:var(--accent); }
.msg-err { color:var(--danger); font-size:13px; min-height:16px; margin:2px 0; }

/* ── 인증 화면 ── */
#auth-screen { height:100%; display:flex; align-items:center; justify-content:center; padding:18px; }
.auth-card {
  width:100%; max-width:400px; background:var(--surface); border:1px solid var(--border);
  border-radius:20px; padding:26px; box-shadow:var(--shadow);
}
.auth-top { display:flex; align-items:center; justify-content:space-between; }
.top-btns { display:flex; gap:6px; }
.brand { font-size:23px; font-weight:800; letter-spacing:-.5px; }
.brand span, .title span { color:var(--accent); }
.auth-sub { color:var(--text-2); font-size:13px; margin:12px 0 18px; line-height:1.5; }
.tabs { display:flex; gap:8px; margin-bottom:16px; }
.tabs button {
  flex:1; padding:10px; border:1px solid var(--border); border-radius:10px;
  background:transparent; color:var(--muted); font-weight:700; font-size:14px;
}
.tabs button.active { background:var(--accent-dim); color:var(--accent); border-color:var(--accent); }
.field { margin-bottom:12px; }
.field label { display:block; font-size:12px; color:var(--muted); margin-bottom:5px; font-weight:600; }
.foot-links { text-align:center; margin-top:14px; }
.foot-links a { color:var(--muted); font-size:13px; text-decoration:none; }
.foot-links a:hover { color:var(--accent); }

/* ── 앱 레이아웃 ── */
#app-screen { height:100%; display:flex; flex-direction:column; }
.topbar {
  display:flex; align-items:center; gap:8px; padding:9px 12px;
  background:var(--surface); border-bottom:1px solid var(--border); flex:0 0 auto;
}
.topbar .title { font-size:17px; font-weight:800; }
.topbar .me { font-size:12px; color:var(--muted); max-width:36vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.topbar .spacer { flex:1; }
.ban-banner {
  flex:0 0 auto; background:var(--danger); color:#fff; text-align:center;
  padding:7px 12px; font-size:13px; font-weight:600;
}

#board-wrap { position:relative; flex:1 1 auto; overflow:hidden; background:var(--surface-2); touch-action:none; }
#board { display:block; width:100%; height:100%; cursor:crosshair; }
.loading {
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  color:var(--muted); font-size:14px; pointer-events:none;
}

/* ── 툴바(정보 + 팔레트 + 찍기) ── */
.toolbar { flex:0 0 auto; background:var(--surface); border-top:1px solid var(--border); padding:8px 10px 10px; }
.info-row { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.pixel-info { flex:1; font-size:13px; color:var(--text-2); line-height:1.4; min-height:18px;
  overflow:hidden; text-overflow:ellipsis; }
.pixel-info b { color:var(--text); }
.place-btn { width:auto; min-width:96px; padding:10px 18px; }
.palette {
  display:grid; grid-template-columns:repeat(16, 1fr); gap:5px;
}
.swatch { width:100%; aspect-ratio:1; border-radius:6px; border:2px solid transparent; cursor:pointer;
  box-shadow:inset 0 0 0 1px rgba(128,128,128,.25); }
.swatch.sel { border-color:var(--text); transform:scale(1.08); }

/* ── 모달 공통 ── */
.modal { position:fixed; inset:0; background:rgba(0,0,0,.55); display:flex; align-items:center; justify-content:center;
  padding:16px; z-index:50; }
.modal-card { width:100%; max-width:440px; background:var(--surface); border:1px solid var(--border);
  border-radius:18px; padding:20px; box-shadow:var(--shadow); max-height:88vh; overflow-y:auto; }
.modal-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.modal-head h2 { margin:0; font-size:18px; }
.section { padding:14px 0; border-top:1px solid var(--border); }
.section:first-of-type { border-top:none; padding-top:0; }
.section h3 { margin:0 0 12px; font-size:14px; }
.row { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.seg { display:flex; gap:4px; background:var(--surface-2); padding:3px; border-radius:10px; }
.seg button { border:none; background:transparent; color:var(--muted); padding:6px 12px; border-radius:8px; font-size:13px; font-weight:600; }
.seg button.active { background:var(--accent); color:#fff; }
.inline-form { display:flex; flex-direction:column; gap:8px; }
.small { font-size:12px; color:var(--muted); margin:0 0 10px; line-height:1.5; }

/* ── 관리자 테이블 ── */
.utable { width:100%; border-collapse:collapse; font-size:13px; }
.utable td { padding:8px 4px; border-bottom:1px solid var(--border); vertical-align:middle; }
.utable .uemail { max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.utable .badge { font-size:10px; padding:1px 6px; border-radius:999px; font-weight:700; }
.badge.admin { background:var(--accent-dim); color:var(--accent); }
.badge.banned { background:rgba(239,68,68,.15); color:var(--danger); }
.uact { display:flex; gap:5px; flex-wrap:wrap; justify-content:flex-end; }
.uact button { border:1px solid var(--border); background:var(--surface-2); color:var(--text);
  font-size:11px; padding:5px 8px; border-radius:7px; font-weight:600; }
.uact button:hover { background:var(--hover); }
.uact button.danger { color:var(--danger); }

/* ── 계산기 ── */
.calc-card { max-width:320px; }
.calc-disp { background:var(--surface-2); border-radius:12px; padding:16px; text-align:right;
  font-size:30px; font-weight:700; margin-bottom:12px; overflow:hidden; }
.calc-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.calc-grid button { padding:16px 0; border:none; border-radius:12px; background:var(--surface-2);
  color:var(--text); font-size:18px; font-weight:600; }
.calc-grid button:hover { background:var(--hover); }
.calc-grid button.op { background:var(--accent-dim); color:var(--accent); }
.calc-grid button.wide { grid-column:span 2; }

@media (max-width:480px) {
  .palette { grid-template-columns:repeat(8, 1fr); }
  .topbar .me { display:none; }
}
