:root {
  --side-bg: #161c28;
  --side-fg: #c9d1e0;
  --side-active: #26324a;
  --bg: #f4f5f8;
  --panel: #fff;
  --line: #dfe2ea;
  --fg: #1d2330;
  --muted: #6a7385;
  --accent: #2563eb;
  --accent-fg: #fff;
  --danger: #c0392b;
  --ok: #1e8e4e;
  --warn-bg: #fff6df;
  --warn-fg: #7a5200;
  --err-bg: #fdecea;
  --sel: #dbe7ff;
  --radius: 6px;
  --font: "Pretendard", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "D2Coding", "Consolas", "Menlo", "Noto Sans Mono CJK KR", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--fg); background: var(--bg); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.boot, .noscript { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 34px; padding: 4px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #eef1f7; }
.btn.sm { min-height: 28px; padding: 2px 9px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover:not(:disabled) { background: #1d4fd0; }
.btn.danger { color: var(--danger); border-color: #e2b4ae; }
.btn.ghost { background: transparent; border-color: #3a4560; color: var(--side-fg); }
.btn.ghost:hover:not(:disabled) { background: var(--side-active); }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; font-size: 18px; line-height: 1; }
.icon-btn:hover { background: rgba(0, 0, 0, .08); }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 34px; padding: 4px 8px; border: 1px solid #c5cad6; border-radius: var(--radius); background: #fff;
}
textarea { font-family: var(--mono); resize: vertical; }
input[readonly] { background: #eef0f5; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field > label { font-weight: 600; font-size: 13px; }
.field.check { flex-direction: row; align-items: flex-start; gap: 8px; }
.field.check label { font-weight: 400; }
.field.inline { flex-direction: row; align-items: center; margin: 0; gap: 6px; }
.field.inline input { width: 90px; }
.hint { color: var(--muted); font-size: 12.5px; }
.form-error { color: var(--danger); min-height: 1.4em; margin: 4px 0; font-weight: 600; word-break: break-word; }
.form-error:empty { min-height: 0; margin: 0; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; align-items: end; }
.form-row .full { grid-column: 1 / -1; }
.form-row > .btn { margin-bottom: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; background: var(--side-bg); }
.login-card { width: min(380px, 100%); padding: 28px 24px; border-radius: 10px; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.login-card h1 { font-size: 22px; }
.login-card .sub { margin: 4px 0 18px; color: var(--muted); }
.login-card .foot { margin: 14px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 270px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--side-bg); color: var(--side-fg); overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; font-size: 16px; font-weight: 700; color: #fff; }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); font-weight: 800; }
.nav { display: flex; flex-direction: column; padding: 4px 8px; }
.nav a { padding: 8px 12px; border-radius: var(--radius); color: var(--side-fg); text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a[aria-current=page] { background: var(--side-active); color: #fff; font-weight: 600; }
.sidebar :focus-visible { outline-color: #8fb4ff; }
.tree-wrap { flex: 1; min-height: 0; overflow: auto; padding: 8px 8px 12px; border-top: 1px solid #263046; margin-top: 8px; }
.side-h { padding: 4px 8px; font-size: 11.5px; letter-spacing: .04em; color: #8591aa; font-weight: 600; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 14px; }
.tn { display: flex; align-items: center; }
.tt { width: 22px; height: 26px; flex: none; border: 0; background: none; color: #8591aa; cursor: pointer; padding: 0; }
.tt:disabled { cursor: default; opacity: .4; }
.tl { flex: 1; min-width: 0; padding: 3px 6px; border: 0; border-radius: 4px; background: none; color: var(--side-fg); text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl:hover { background: rgba(255, 255, 255, .07); }
.tl.current { background: var(--side-active); color: #fff; font-weight: 600; }
.tmsg { padding: 2px 8px 2px 22px; font-size: 12.5px; color: #8591aa; }
.tmsg.err { color: #ff9c92; }
.tmore { margin-left: 22px; border: 0; background: none; color: #8fb4ff; cursor: pointer; padding: 2px 6px; }
.side-foot { padding: 12px 14px; border-top: 1px solid #263046; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.side-foot .who { font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; }
.side-foot .ver { grid-column: 1 / -1; font-size: 12px; color: #8591aa; }
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); flex: none; }
.title { font-size: 17px; }
.hamburger { display: none; }
.scrim { display: none; }
.main { flex: 1; min-height: 0; overflow: auto; padding: 0; outline: none; }

/* ---------- explorer ---------- */
.explorer { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.toolbar { flex: none; padding: 10px 14px 6px; background: #fff; border-bottom: 1px solid var(--line); }
.tb-row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.tb-field, .rev-form { display: flex; align-items: center; gap: 6px; }
.tb-field label, .rev-form label { font-size: 13px; color: var(--muted); }
.tb-field select { width: 160px; }
.rev-form input { width: 88px; }
.tb-search { margin-left: auto; min-width: 160px; flex: 0 1 260px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 0 2px; min-height: 32px; }
.crumb { border: 0; background: none; padding: 2px 6px; border-radius: 4px; cursor: pointer; color: var(--accent); font-weight: 500; }
.crumb:hover { background: #eef2ff; }
.crumb[aria-current=page] { color: var(--fg); font-weight: 700; }
.crumbs .sep { color: var(--muted); }
.chip { display: inline-block; padding: 0 8px; margin: 0 4px 2px 0; border-radius: 10px; background: #e8ecf5; font-size: 12.5px; }
.rev-chip { background: #fff1c9; color: var(--warn-fg); }
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 10px; padding: 10px 14px 14px; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; min-width: 0; }
.pane-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pane-head .muted { margin-left: auto; white-space: nowrap; }
.table-scroll { flex: 1; min-height: 0; overflow: auto; }
.table-pane .table-scroll { -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
table.files th, table.files td, table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid #eceef4; text-align: left; vertical-align: top; }
table.files td { vertical-align: middle; white-space: nowrap; }
table.files th { position: sticky; top: 0; z-index: 1; background: #f3f5fa; font-weight: 600; white-space: nowrap; }
table.files th.num, table.files td.num { text-align: right; }
.th-btn { border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; }
.th-btn:hover { color: var(--accent); }
table.files tr.row { cursor: default; outline-offset: -2px; }
table.files tr.row:hover { background: #f4f7ff; }
table.files tr.row.selected { background: var(--sel); }
table.files .c-name { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
table.files .c-act { width: 40px; padding: 2px; text-align: center; }
.nm { overflow: hidden; text-overflow: ellipsis; }
.ico { display: inline-block; width: 16px; height: 13px; margin-right: 8px; vertical-align: -2px; border-radius: 2px; }
.ico.dir { background: #f0b23e; border-top-left-radius: 5px 4px; }
.ico.file { width: 12px; height: 15px; margin: 0 10px 0 2px; background: #fff; border: 1.5px solid #8a94a8; border-radius: 2px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: #fafbfd; flex-wrap: wrap; }
.pager select { width: auto; min-height: 28px; margin-left: auto; }
.pg-info { color: var(--muted); font-size: 13px; }
.loading { padding: 24px; text-align: center; color: var(--muted); }
.error-box { margin: 12px; padding: 12px 14px; border: 1px solid #f0b6af; border-radius: var(--radius); background: var(--err-bg); color: #8a2a20; word-break: break-word; }
.error-box .btn { margin-top: 6px; }
.note { margin: 8px 12px; color: var(--muted); }
.note.warn { color: var(--warn-fg); background: var(--warn-bg); padding: 8px 12px; border-radius: var(--radius); }
.note.empty { text-align: center; padding: 28px 8px; }
.detail-pane .tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); }
.tab { padding: 6px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; background: none; cursor: pointer; color: var(--muted); }
.tab[aria-selected=true] { background: #fff; border-color: var(--line); color: var(--fg); font-weight: 600; margin-bottom: -1px; }
.tabpanel { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; outline: none; }
.tabpanel .note { margin-left: 0; margin-right: 0; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0 0 10px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-all; }
.meta.wide { padding: 10px 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
pre.code { margin: 6px 0; padding: 10px; max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fbfbfd; font: 12.5px/1.5 var(--mono); tab-size: 4; white-space: pre; }
pre.code.wrap { white-space: pre-wrap; word-break: break-all; }
pre.diff { background: #fff; }
.dl { display: block; }
.dl.add { background: #e6f6ea; color: #14602f; }
.dl.del { background: #fdeceb; color: #8d231a; }
.dl.hunk { background: #eaf0ff; color: #274a9c; }
.dl.dmeta { color: var(--muted); font-weight: 600; }
.diff-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.hist { list-style: none; margin: 8px 0; padding: 0; }
.hist-item { padding: 8px 0; border-bottom: 1px solid #eceef4; }
.hist-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hist .rev { color: var(--accent); font-family: var(--mono); }
.hist .msg { margin: 4px 0 2px 26px; white-space: pre-wrap; word-break: break-word; }
.hist .actions { margin: 4px 0 0 26px; }

/* ---------- pages ---------- */
.page { max-width: 1200px; padding: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.page-head h2 { font-size: 18px; }
.page-head .btn { margin-left: auto; }
.card { margin: 12px 0; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.card.table-scroll { padding: 0; overflow: auto; flex: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.card h2, .card h3 { margin-bottom: 8px; font-size: 16px; }
.card-head h2, .card-head h3 { margin-bottom: 0; }
table.data th { background: #f3f5fa; font-weight: 600; }
table.data tbody th { background: none; font-weight: 600; }
table.data tr.inherited td { color: var(--muted); }
.row-actions { white-space: nowrap; display: flex; gap: 6px; flex-wrap: wrap; }
.wrap-cell { word-break: break-word; min-width: 160px; }
.badge { display: inline-block; padding: 0 8px; border-radius: 10px; background: #e8ecf5; font-size: 12.5px; }
.badge.ok { background: #dcf3e4; color: #14602f; }
.badge.off { background: #f1e1df; color: #8d231a; }
.defaults { margin: 0 0 12px; padding-left: 20px; color: var(--muted); }
.banner { padding: 10px 14px; border-radius: var(--radius); margin: 10px 0; word-break: break-word; }
.banner.ok { background: #e4f5ea; color: #14602f; }
.banner.warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid #ecd49b; }
.banner.err { background: var(--err-bg); color: #8a2a20; border: 1px solid #f0b6af; }
.warn-list { margin: 8px 0; padding: 8px 12px 8px 30px; background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 14px; }
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: grid; grid-template-columns: minmax(80px, auto) 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid #eceef4; }
.members { color: var(--muted); }

/* ---------- dialogs ---------- */
.dlg { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); color: var(--fg); overflow: hidden; }
.dlg.wide { width: min(860px, calc(100vw - 24px)); }
.dlg[open] { display: flex; flex-direction: column; }
.dlg::backdrop { background: rgba(10, 14, 24, .55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 16px; }
.dlg-body { padding: 16px 18px; overflow: auto; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.preview .pv-summary { margin: 0 0 10px; font-weight: 600; white-space: pre-wrap; word-break: break-word; }
.ba { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ba > div { min-width: 0; }
.ba h3 { font-size: 13px; color: var(--muted); }
.ba pre.code { max-height: 38vh; white-space: pre-wrap; word-break: break-word; }

/* ---------- context menu ---------- */
.ctx-menu {
  position: fixed; z-index: 1000; min-width: 190px; max-width: calc(100vw - 16px); padding: 4px 0; overflow-y: auto;
  background: #fff; border: 1px solid #c7ccd8; border-radius: 8px; box-shadow: 0 8px 28px rgba(15, 20, 35, .28); outline: none;
}
.ctx-item { display: flex; align-items: center; gap: 16px; padding: 7px 14px; cursor: default; user-select: none; -webkit-user-select: none; white-space: nowrap; }
.ctx-item .lbl { flex: 1; }
.ctx-item .kbd { color: var(--muted); font-size: 12px; }
.ctx-item .arrow { color: var(--muted); }
.ctx-item.active, .ctx-item:focus { background: var(--accent); color: #fff; outline: none; }
.ctx-item.active .kbd, .ctx-item.active .arrow, .ctx-item:focus .kbd, .ctx-item:focus .arrow { color: #dbe6ff; }
.ctx-item.disabled { opacity: .45; }
.ctx-sep { height: 1px; margin: 4px 0; background: var(--line); }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 2000; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 28px)); }
.toast { padding: 10px 14px; border-radius: var(--radius); background: #263046; color: #fff; box-shadow: 0 4px 16px rgba(0, 0, 0, .3); cursor: pointer; word-break: break-word; }
.toast.ok { background: #1b6b3d; }
.toast.err { background: #a53226; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 1.2fr) minmax(260px, 1fr); overflow: auto; }
  .hide-md { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 500; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .18s ease; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; z-index: 400; inset: 0; background: rgba(10, 14, 24, .5); }
  .hamburger { display: inline-block; }
  .hide-sm { display: none; }
  .tb-search { margin-left: 0; flex: 1 1 100%; }
  .tb-field select { width: 130px; }
  .ba { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr; }
  .meta dt { margin-top: 4px; font-size: 12.5px; }
  .kv li { grid-template-columns: 1fr auto; }
  .kv li .members { grid-column: 1 / -1; grid-row: 2; }
  .icon-btn { width: 40px; height: 40px; }
  .btn { min-height: 38px; }
  .btn.sm { min-height: 34px; }
  table.files td.c-act { width: 46px; }
  .ctx-item { padding: 11px 16px; }
}
@media (max-width: 520px) {
  .page { padding: 10px; }
  .split { padding: 8px; }
  .toolbar { padding: 8px 8px 4px; }
  .dlg-body { padding: 14px; }
}
@media (hover: none) and (pointer: coarse) {
  .tl, .crumb { min-height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.timezone { margin-left: auto; font-size: 11px; white-space: nowrap; }
