/* 개발연구소 — sql-detective와 같은 색·글꼴 토큰 */
:root {
  --paper: #E8ECF0; --sheet: #FBFCFD; --ink: #18243A; --muted: #5B6779; --rule: #CBD3DD;
  --accent: #2350A0; --accent-soft: #DCE5F5; --stamp: #C2362B;
  --bar: #18243A; --bar-ink: #E8ECF0; --scrim: rgba(10, 16, 26, .45);
  --grid: #E3E8EE; --area: rgba(35, 80, 160, .10);
  --good: #0ca30c; --warning: #fab219; --critical: #d03b3b; /* 상태 색: 아이콘·글자와 같이만 쓴다 */
  /* 본문 폭: 창 너비를 따라가되 아주 넓은 화면에서는 1600px에서 멈춘다. 양옆 여백도 창에 비례 */
  --page-max: 1600px; --gutter: clamp(16px, 3vw, 48px);
  --f-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E141E; --sheet: #161F2D; --ink: #E2E8F1; --muted: #93A0B4; --rule: #2A3649;
    --accent: #84A8EC; --accent-soft: #1F2E4A; --stamp: #E8695E; --bar: #161F2D; --bar-ink: #E2E8F1;
    --scrim: rgba(0, 0, 0, .6); --grid: #223044; --area: rgba(132, 168, 236, .12); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E141E; --sheet: #161F2D; --ink: #E2E8F1; --muted: #93A0B4; --rule: #2A3649;
  --accent: #84A8EC; --accent-soft: #1F2E4A; --stamp: #E8695E; --bar: #161F2D; --bar-ink: #E2E8F1;
  --scrim: rgba(0, 0, 0, .6); --grid: #223044; --area: rgba(132, 168, 236, .12); color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.6; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 상단: 로고 + 햄버거 ── */
.top { position: sticky; top: 0; z-index: 10; background: var(--bar); color: var(--bar-ink); border-bottom: 1px solid var(--rule); }
.top-inner { max-width: var(--page-max); margin: 0 auto; padding: 10px var(--gutter); display: flex; align-items: center; gap: 8px; }
.top a { color: var(--bar-ink); text-decoration: none; }
.brand { flex: none; display: flex; align-items: center; gap: 10px; }
.brand svg { flex: none; }
.brand b { font-size: 19px; letter-spacing: -.01em; white-space: nowrap; }
.menu-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--bar-ink); cursor: pointer; }
.menu-btn:hover { border-color: color-mix(in srgb, var(--bar-ink) 30%, transparent); }
.spacer { flex: 1; }
.account { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; }
.account .me { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.top .login-btn { flex: none; padding: 5px 14px; border: 1px solid color-mix(in srgb, var(--bar-ink) 45%, transparent); border-radius: 6px; background: none; color: var(--bar-ink); font-size: 14px; text-decoration: none; cursor: pointer; }
.top .login-btn:hover { background: color-mix(in srgb, var(--bar-ink) 12%, transparent); }

/* ── 햄버거 메뉴(왼쪽 서랍). 닫혀 있을 때는 visibility로 키보드 초점도 막는다 ── */
.scrim { position: fixed; inset: 0; z-index: 20; background: var(--scrim); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: min(300px, 86vw); padding: 16px; overflow-y: auto; background: var(--sheet); border-right: 1px solid var(--rule); transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility .2s; }
/* 열 때는 visibility를 바로 바꿔야 서랍 안으로 초점을 옮길 수 있다 */
body.menu-open .scrim { opacity: 1; visibility: visible; transition: opacity .2s; }
body.menu-open .drawer { transform: none; visibility: visible; transition: transform .2s; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.drawer-head b { font-size: 17px; }
.drawer .close { width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; font-size: 22px; cursor: pointer; }
.drawer h3 { margin: 16px 0 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.drawer ul { list-style: none; margin: 0; padding: 0; }
.drawer li a { display: flex; justify-content: space-between; padding: 9px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.drawer li a:hover, .drawer li a[aria-current] { background: var(--accent-soft); color: var(--accent); }
.drawer .count { color: var(--muted); font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .scrim, .drawer { transition: none; } }

/* ── 공통 ── */
main { max-width: var(--page-max); margin: 0 auto; padding: 24px var(--gutter) 48px; }
.foot { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter) 32px; color: var(--muted); font-size: 13px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h2 a { color: inherit; text-decoration: none; }
.muted, .meta, .num, .date { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; white-space: nowrap; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.button { display: inline-block; padding: 8px 16px; border: 0; border-radius: 6px; background: var(--accent); color: var(--sheet); text-decoration: none; font-weight: 500; cursor: pointer; }
.actions { display: flex; align-items: center; gap: 12px; }
.empty { color: var(--muted); }
.panel, .post, .comments, .message, form.write { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 16px; }

/* ── 메인: 최신글 | 게임게시판, 아래 공지 ── */
.home { display: grid; gap: 16px; }
.panel { min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.panel-head > a { font-size: 13px; text-decoration: none; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.tag { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 500; white-space: nowrap; vertical-align: 1px; }
.tag.notice { background: color-mix(in srgb, var(--stamp) 14%, transparent); color: var(--stamp); }
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 4px 4px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.post-list li:last-child { border-bottom: 0; }
.post-list .title { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-list .title:hover { text-decoration: underline; }
.post-list .c { color: var(--accent); font-size: 13px; }
.post-list .meta { margin-left: 8px; white-space: nowrap; }
.games { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 16px; }
.game { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--rule); border-radius: 8px; }
.game .icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; }
.game .txt { flex: 1; min-width: 0; }
.game .txt b { display: block; }
.game .txt span { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game .button { flex: none; padding: 6px 14px; font-size: 14px; }
.sub { margin: 4px 0; font-size: 14px; font-weight: 500; color: var(--muted); }

/* ── 게시판 ── */
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.board-head h1 { margin: 0; }
table.posts { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--rule); }
.posts th, .posts td { padding: 8px 10px; border-bottom: 1px solid var(--rule); text-align: left; }
.posts th { font-size: 13px; font-weight: 500; color: var(--muted); }
.posts td:not(.title) { white-space: nowrap; }
.posts .title { width: 100%; overflow-wrap: anywhere; }
.posts .title a { color: var(--ink); text-decoration: none; }
.posts .count { color: var(--accent); font-size: 13px; }
.pager { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.crumb { margin: 0 0 8px; font-size: 14px; }
.post .body { margin: 16px 0; overflow-wrap: anywhere; }
.comments { margin-top: 16px; }
.comments ul { list-style: none; margin: 0 0 16px; padding: 0; }
.comments li { padding: 10px 0; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.comments li p { margin: 4px 0; }

/* ── 폼 ── */
form.write, .comment-form { display: grid; gap: 10px; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
input, textarea, select { width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
textarea { resize: vertical; }
.field-error { margin: -4px 0 0; color: var(--stamp); font-size: 13px; }
details.delete { margin-top: 8px; font-size: 13px; }
details.delete summary { width: max-content; color: var(--muted); cursor: pointer; }
details.delete form { display: flex; gap: 8px; max-width: 320px; margin-top: 6px; }
details.delete button { padding: 6px 12px; border: 1px solid var(--stamp); border-radius: 6px; background: none; color: var(--stamp); cursor: pointer; }
.message, .login { max-width: 560px; }

/* ── 서버 상태(관리자) ── */
.monitor { display: grid; gap: 16px; }
.monitor .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.monitor .head h1 { margin: 0; }
.live { display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.live.stale::before { background: var(--warning); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile { min-width: 0; padding: 14px 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 15px; font-weight: 500; color: var(--muted); }
.tile .sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tile.na .value { font-size: 16px; font-weight: 500; color: var(--muted); }
.meter { height: 6px; margin: 8px 0 4px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.meter[hidden] { display: none; }
.meter i { display: block; width: 0; height: 100%; border-radius: 3px; background: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--ink); }
.status svg { flex: none; }
.range { display: inline-flex; justify-self: start; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: var(--sheet); }
.range button { padding: 4px 12px; border: 0; background: none; font-size: 13px; cursor: pointer; }
.range button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; transition: opacity .15s; }
.charts.loading { opacity: .5; }
.battery-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart-head h2 { margin: 0 0 8px; font-size: 16px; }
.chart-head .now { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.chart-head .now b { color: var(--ink); font-size: 15px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 180px; overflow: visible; outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--f-body); }
.tip { position: absolute; top: 0; padding: 4px 8px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); font-size: 12px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); opacity: 0; pointer-events: none; }
.tip b { font-size: 14px; }
.tip span { color: var(--muted); }
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.two h2 { font-size: 16px; }
.two h2.gap { margin-top: 16px; }
table.cores { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cores th, .cores td { padding: 7px 8px; border-bottom: 1px solid var(--rule); text-align: left; white-space: nowrap; }
.cores th { font-size: 13px; font-weight: 500; color: var(--muted); }
.cores .num { text-align: right; }
.cores tr.off td { color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-variant-numeric: tabular-nums; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; text-align: right; }
.rules { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
/* ── 관리자 로그·이용자 로그 ── */
.logs .board-head { flex-wrap: wrap; }
.log-filter { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 0 0 12px; }
.log-filter label { width: auto; }
.log-filter select { width: 9em; }
.log-filter input { width: 16em; max-width: 60vw; }
table.log { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--rule); font-size: 14px; }
.log th, .log td { padding: 7px 10px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.log th { font-size: 13px; font-weight: 500; color: var(--muted); }
.log td { white-space: nowrap; }
.log .at, .log .ip { font-variant-numeric: tabular-nums; color: var(--muted); }
.log.users td:last-child { width: 100%; }
.log .geo .tag { margin: 0; }
.geo-note { margin-top: 14px; font-size: 13px; }
.blocks-page h2 { margin: 22px 0 8px; font-size: 17px; }
.blocks-page .shell { overflow-x: auto; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); font-size: 13px; }
.allow-list { margin: 0; padding-left: 18px; }
.log td.detail { width: 100%; white-space: normal; overflow-wrap: anywhere; }
.tag.ok { background: color-mix(in srgb, var(--good) 14%, transparent); color: light-dark(#006300, #0ca30c); }
.tag.warn { background: color-mix(in srgb, var(--warning) 22%, transparent); color: light-dark(#7a5200, #fab219); }
.tag.fail { background: color-mix(in srgb, var(--critical) 14%, transparent); color: light-dark(#b02a2a, #e66767); }
.logs .pager strong { color: var(--muted); font-weight: 500; }
/* 휴대폰: 한 줄 = 시각 | IP, 그 아래 지역(IP 밑), 그 아래 종류 | 상세 */
@media (max-width: 640px) {
  table.log thead { display: none; }
  table.log, .log tbody { display: block; }
  .log tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
  .log td { padding: 0; border: 0; white-space: normal; }
  .log .ip, .log .geo { text-align: right; }
  .log .geo { grid-column: 2; }
  .log td.detail, .log.users td:last-child { width: auto; }
}

@media (max-width: 1100px) { .charts, .two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .value { font-size: 22px; }
  .table-wrap { overflow-x: auto; }
}

/* ── 큰 화면(1920px 이상): 폭을 넓히고 최신글 | 게임게시판 | 공지사항 3단 ── */
@media (min-width: 1920px) {
  :root { --page-max: 2400px; }
  body { font-size: 16px; }
  .home { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  .home > .split { display: contents; }
}

/* ── 휴대폰 ── */
@media (max-width: 760px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .post-list li { grid-template-columns: auto 1fr; }
  .post-list .meta { grid-column: 2; margin-left: 0; }
}
@media (max-width: 640px) {
  .brand svg { width: 28px; height: 28px; }
  .brand b { font-size: 17px; }
  .account .badge { display: none; }
  .posts thead, .posts .num, .posts .date { display: none; }
}
