:root {
  --vh: 100vh;
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --hover: #eceae6;
  --border: #e3e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #e3eefb;
  --accent-text: #fff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #008300;
  --warn: #b37a00;
  --crit: #d42f2f;
  --good-soft: #e3f3e3;
  --warn-soft: #fbf0d6;
  --crit-soft: #fbe3e3;
  --grid: #e8e6e1;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .06);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #222220; --hover: #2a2a28; --border: #2f2f2c;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #8e8d86;
    --accent: #3987e5; --accent-soft: #1b2b40; --series-1: #3987e5; --series-2: #d95926;
    --good: #3fb13f; --warn: #e0a400; --crit: #ef6060;
    --good-soft: #17301a; --warn-soft: #33290f; --crit-soft: #3a1b1b; --grid: #2a2a28;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #222220; --hover: #2a2a28; --border: #2f2f2c;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #8e8d86;
  --accent: #3987e5; --accent-soft: #1b2b40; --series-1: #3987e5; --series-2: #d95926;
  --good: #3fb13f; --warn: #e0a400; --crit: #ef6060;
  --good-soft: #17301a; --warn-soft: #33290f; --crit-soft: #3a1b1b; --grid: #2a2a28;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .3);
}

* { box-sizing: border-box; }
@supports (height: 100dvh) { :root { --vh: 100dvh; } }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.input {
  height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); outline: none; width: 100%;
}
.input:focus, .btn:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }

/* ---------- login */
.login-wrap { position: fixed; inset: 0; overflow-y: auto; display: grid; place-items: center; padding: 16px; }
.login {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow); display: grid; gap: 16px;
}
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 0; color: var(--text-2); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand .logo svg { width: 18px; height: 18px; }
.error { color: var(--crit); font-size: 13px; min-height: 1em; }

/* ---------- layout */
/* App shell: pinned to the screen; only .main scrolls, so the sidebar never moves. */
.shell { position: fixed; inset: 0; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side {
  background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px; height: 100%; overflow-y: auto; overscroll-behavior: contain;
}
.side .brand { padding: 0 8px 18px; }
.side .sec { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 14px 10px 6px; }
.nav {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2);
  cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.nav:hover { background: var(--hover); color: var(--text); }
.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .meta { margin-left: auto; font-size: 12px; color: var(--text-3); font-weight: 400; }
.nav-share { display: block; }
.nav-share .bar { margin: 6px 0 0 28px; }
.side .foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.account { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 10px; background: none; cursor: pointer; text-align: left; }
.account:hover, .account[aria-expanded="true"] { background: var(--hover); }
.account svg.i { color: var(--text-3); width: 16px; height: 16px; }
.nav .live { color: var(--good); }
.acc-menu { width: 280px; padding: 0; }
.acc-head { display: flex; gap: 10px; align-items: center; padding: 14px 14px 12px; }
.acc-sec { border-top: 1px solid var(--border); padding: 6px; }
.acc-title { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 6px 8px 2px; }
.acc-row { display: flex; align-items: center; gap: 6px; padding: 6px 4px 6px 8px; }
.acc-row .grow { flex: 1; min-width: 0; }
.acc-row code { font: 13px/1.4 var(--mono); color: var(--text); overflow-wrap: anywhere; }
.term-page { display: flex; flex-direction: column; height: 100%; min-height: 360px; }
.term-wrap { flex: 1; min-height: 0; background: #111110; border-radius: var(--radius); padding: 10px 6px 6px 12px; box-shadow: var(--shadow); }
.term-host { width: 100%; height: 100%; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--text-2); }
.side .foot .who { flex: 1; min-width: 0; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.side .foot .who small { color: var(--text-3); display: block; }
.main { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 24px 28px 60px; }
.scrim { display: none; }
.main:has(.term-page) { padding-bottom: 24px; }
.topbar { display: none; }

.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.warn > i { background: var(--warn); }
.bar.crit > i { background: var(--crit); }
.muted { color: var(--text-3); }
.small { font-size: 12px; }

/* ---------- file browser */
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head h2 { margin: 0; font-size: 22px; font-weight: 650; }
.head .grow { flex: 1; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 14px; color: var(--text-2); }
.crumbs button { border: 0; background: none; padding: 4px 6px; border-radius: 6px; cursor: pointer; color: inherit; }
.crumbs button:hover { background: var(--hover); color: var(--text); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--text-3); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.search svg { position: absolute; left: 10px; top: 9px; color: var(--text-3); }
.search .input { padding-left: 34px; }
.selbar { display: flex; gap: 8px; align-items: center; padding: 6px 8px 6px 14px; background: var(--accent-soft); border-radius: 10px; margin-bottom: 12px; }
.selbar b { margin-right: auto; color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.files { overflow: hidden; }
.frow {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 110px 150px 44px; align-items: center;
  padding: 0 8px; min-height: 48px; border-bottom: 1px solid var(--border); cursor: default;
}
.frow:last-child { border-bottom: 0; }
.frow.hd { min-height: 38px; font-size: 12px; color: var(--text-3); font-weight: 600; background: var(--surface-2); }
.frow.hd button { border: 0; background: none; color: inherit; font-weight: inherit; cursor: pointer; padding: 0; text-align: left; }
.frow:not(.hd):hover { background: var(--hover); }
.frow.sel { background: var(--accent-soft); }
.frow .nm { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.frow .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .nm small { display: block; color: var(--text-3); font-size: 12px; }
.frow .sz, .frow .dt { color: var(--text-2); font-size: 13px; }
.ficon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }
.ficon.dir { background: var(--accent-soft); color: var(--accent); }
.ficon.img { color: #1baf7a; } .ficon.vid { color: #d55181; } .ficon.aud { color: #6250d6; }
.ficon.doc { color: #eb6834; } .ficon.zip { color: #b37a00; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.empty { padding: 56px 16px; text-align: center; color: var(--text-3); }
.empty svg { width: 40px; height: 40px; margin-bottom: 8px; }

.drop {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); z-index: 50;
  display: none; place-items: center; pointer-events: none;
}
.drop.on { display: grid; }
.drop > div { background: var(--surface); padding: 28px 36px; border-radius: 16px; border: 2px dashed var(--accent); font-size: 16px; font-weight: 600; box-shadow: var(--shadow); }

.uploads { position: fixed; right: 20px; bottom: 20px; width: min(360px, calc(100vw - 32px)); z-index: 40; overflow: hidden; }
.uploads .uh { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.uploads .uh span { margin-right: auto; }
.uploads .ul { max-height: 260px; overflow: auto; }
.uitem { padding: 8px 14px; display: grid; gap: 4px; font-size: 13px; }
.uitem .r { display: flex; gap: 8px; } .uitem .r span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* menu & modal */
.menu { position: fixed; z-index: 68; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 170px; }
.menu button { display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--crit); }
.modal-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 70; display: grid; place-items: center; padding: 16px; }
.modal { width: min(420px, 100%); background: var(--surface); border-radius: 14px; padding: 22px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal h3 { margin: 0; font-size: 17px; }
.modal p { margin: 0; color: var(--text-2); word-break: break-word; }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; }
.preview { position: fixed; inset: 0; z-index: 80; background: rgb(10 10 10 / .92); display: grid; grid-template-rows: auto 1fr; color: #f0efec; }
.preview .ph { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.preview .ph b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview .ph .btn { background: rgb(255 255 255 / .08); border-color: transparent; color: inherit; }
.preview .pb { display: grid; place-items: center; min-height: 0; padding: 0 16px 16px; }
.preview img, .preview video { max-width: 100%; max-height: calc(var(--vh) - 90px); border-radius: 8px; }
.preview iframe { width: min(1000px, 100%); height: calc(var(--vh) - 90px); border: 0; border-radius: 8px; background: #fff; }
.preview pre { width: min(1000px, 100%); max-height: calc(var(--vh) - 90px); overflow: auto; background: #1a1a19; padding: 16px; border-radius: 8px; font: 13px/1.5 var(--mono); white-space: pre-wrap; margin: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 90; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

/* ---------- dashboard */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile { padding: 16px 18px; display: grid; gap: 6px; align-content: start; }
.tile .lbl { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tile .val { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .val small { font-size: 14px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.tile .sub { font-size: 12px; color: var(--text-3); }
.panel { padding: 16px 18px; }
.panel h4 { margin: 0 0 12px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel h4 .r { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--text-3); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 150px; overflow: visible; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 2;
}
.chart .tip .k { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.cores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.cores div { font-size: 11px; color: var(--text-3); display: grid; gap: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.pill svg { width: 13px; height: 13px; stroke-width: 2.4; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.mute { background: var(--surface-2); color: var(--text-2); }
.list { display: grid; }
.list > div { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.list > div:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.storage-row { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.storage-row:last-child { border: 0; }
.storage-row .t { display: flex; justify-content: space-between; font-size: 13px; }
.term { background: #111110; color: #d8d7d0; font: 12px/1.5 var(--mono); padding: 12px 14px; border-radius: 10px; max-height: 340px; overflow: auto; white-space: pre-wrap; margin: 12px 0 0; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; color: var(--text-3); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.scroll { overflow-x: auto; }
.notice { padding: 14px 16px; border-radius: 10px; background: var(--warn-soft); color: var(--text); font-size: 13px; display: flex; gap: 10px; }
.notice code { font-family: var(--mono); background: rgb(0 0 0 / .06); padding: 1px 5px; border-radius: 4px; }

/* ---------- responsive */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 65; left: 0; top: 0; bottom: 0; height: auto; width: 260px; padding-bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 64; background: rgb(0 0 0 / .35); }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; padding-top: max(10px, env(safe-area-inset-top)); }
  .main { padding: 16px 16px 60px; }
  .main:has(.term-page) { padding-bottom: 16px; }
  .input, select.input { font-size: 16px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .frow { grid-template-columns: 32px minmax(0, 1fr) 40px; }
  .frow .sz, .frow .dt { display: none; }
  .frow .nm small.m { display: block; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar .btn span { display: none; }
}
@media (min-width: 801px) { .frow .nm small.m { display: none; } }
@media (max-width: 480px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tile .val { font-size: 22px; } }
