/* =====================================================================
   DESIGN SYSTEM — Glass UI (반투명 유리)
   · 면: 반투명 흰색 + 배경 블러, 얇은 하이라이트 선과 부드러운 그림자로 유리 질감을 표현한다.
   · 주 버튼·선택 상태: 옅은 파란색 유리 (#96b2e8 → #7496da), 글자는 짙은 색
   · 보조 버튼·카드·메뉴: 투명한 흰색 유리, 입력창·스위치 트랙·배지: 안쪽이 살짝 눌린 유리
   · 포커스 링은 항상 보이는 2px 파란색
   ===================================================================== */
:root {
  /* 색상 */
  --text: #1c1d21;
  --muted: #6a6e78;
  --line: rgba(100, 110, 130, .18);
  --accent: #5f87d6;
  --accent-text: #3a60b6;
  --focus: #4a74cc;
  --danger: #c4372d;
  --warn: #8a5a00;
  --btn-text: #ffffff;

  /* 배경: 연한 청회색 + 은은한 빛 번짐 */
  --bg: linear-gradient(180deg, #eef0f4, #e1e4ea);
  --bg-glow: radial-gradient(900px 520px at 8% -8%, rgba(176, 198, 240, .55), transparent 62%), radial-gradient(800px 520px at 100% 2%, rgba(226, 214, 242, .5), transparent 62%);

  /* 유리 면 */
  --glass: rgba(255, 255, 255, .5);
  --glass-strong: rgba(255, 255, 255, .72);
  --glass-modal: rgba(255, 255, 255, .84);
  --field-solid: #ffffff; --option-sel-bg: #dbe5fb; --option-sel-text: #1c1d21;
  /* Form fields: one background for text inputs and selects so both read the same in every theme */
  --field-bg: rgba(255, 255, 255, .62); --field-bg-hover: rgba(255, 255, 255, .8);
  --field-edge-hover: rgba(80, 100, 140, .4); --placeholder: #6a6e78;
  --sunken: rgba(255, 255, 255, .3);
  --logo-bg: rgba(255, 255, 255, .6);
  --glass-edge: rgba(110, 120, 142, .22);
  --hl: rgba(255, 255, 255, .88);
  --blur: blur(14px) saturate(150%);
  --blue-from: #4a73c9; --blue-to: #355aaf;
  --blue-from-h: #3f68be; --blue-to-h: #2c4e9c;
  --blue-tint: rgba(126, 160, 228, .32);
  --danger-from: #d9645b; --danger-to: #c4483f;

  /* 그림자 단계: 유리 1~3 / 눌림(inset) */
  --sh-c: rgba(60, 70, 92, .13);
  --g-1: 0 0 0 1px var(--glass-edge), 0 3px 10px var(--sh-c), inset 0 1px 0 var(--hl);
  --g-2: 0 0 0 1px var(--glass-edge), 0 8px 22px var(--sh-c), inset 0 1px 0 var(--hl);
  --g-3: 0 0 0 1px var(--glass-edge), 0 18px 46px rgba(60, 70, 92, .2), inset 0 1px 0 var(--hl);
  --g-in: 0 0 0 1px var(--glass-edge), inset 0 2px 6px var(--sh-c), inset 0 -1px 0 var(--hl);
  --g-blue: 0 0 0 1px rgba(255, 255, 255, .55), 0 10px 22px rgba(53, 90, 175, .34), inset 0 1px 0 rgba(255, 255, 255, .35);

  /* 선 두께 / 모서리 / 간격 / 아이콘 / 글꼴 */
  --bw-1: 1px; --bw-2: 1.5px; --bw-3: 2px;
  --r-sm: 12px; --r-md: 18px; --r-lg: 28px; --r-xl: 32px; --r-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --icon-sm: 16px; --icon-md: 20px; --icon-lg: 24px;
  --font: "Noto Sans", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text: #eef0f5; --muted: #9da3b0; --line: rgba(255, 255, 255, .1);
    --accent: #7c9fe8; --accent-text: #a3bcff; --focus: #8fb0ff; --danger: #f0776e; --warn: #f2c15a; --btn-text: #ffffff;
    --bg: linear-gradient(180deg, #1d2027, #14161b);
    --bg-glow: radial-gradient(900px 520px at 8% -8%, rgba(80, 110, 190, .35), transparent 62%), radial-gradient(800px 520px at 100% 2%, rgba(120, 90, 170, .28), transparent 62%);
    --glass: rgba(255, 255, 255, .07); --glass-strong: rgba(255, 255, 255, .12); --glass-modal: rgba(34, 38, 48, .92);
    --field-solid: #262a33; --option-sel-bg: #3a5294; --option-sel-text: #ffffff;
    --field-bg: #1b1e25; --field-bg-hover: #20242c; --field-edge-hover: rgba(255, 255, 255, .28); --placeholder: #a2a8b5;
    --sunken: rgba(0, 0, 0, .18); --logo-bg: rgba(244, 245, 248, .94);
    --glass-edge: rgba(255, 255, 255, .14); --hl: rgba(255, 255, 255, .12);
    --blue-from: #4a6fc4; --blue-to: #35529f;
    --blue-from-h: #3f64b8; --blue-to-h: #2d4891; --blue-tint: rgba(110, 146, 230, .34);
    --sh-c: rgba(0, 0, 0, .4);
    --g-3: 0 0 0 1px var(--glass-edge), 0 18px 46px rgba(0, 0, 0, .5), inset 0 1px 0 var(--hl);
    --g-blue: 0 0 0 1px rgba(255, 255, 255, .2), 0 10px 22px rgba(40, 70, 150, .45), inset 0 1px 0 rgba(255, 255, 255, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --text: #eef0f5; --muted: #9da3b0; --line: rgba(255, 255, 255, .1);
  --accent: #7c9fe8; --accent-text: #a3bcff; --focus: #8fb0ff; --danger: #f0776e; --warn: #f2c15a; --btn-text: #ffffff;
  --bg: linear-gradient(180deg, #1d2027, #14161b);
  --bg-glow: radial-gradient(900px 520px at 8% -8%, rgba(80, 110, 190, .35), transparent 62%), radial-gradient(800px 520px at 100% 2%, rgba(120, 90, 170, .28), transparent 62%);
  --glass: rgba(255, 255, 255, .07); --glass-strong: rgba(255, 255, 255, .12); --glass-modal: rgba(34, 38, 48, .92);
  --field-solid: #262a33; --option-sel-bg: #3a5294; --option-sel-text: #ffffff;
  --field-bg: #1b1e25; --field-bg-hover: #20242c; --field-edge-hover: rgba(255, 255, 255, .28); --placeholder: #a2a8b5;
  --sunken: rgba(0, 0, 0, .18); --logo-bg: rgba(244, 245, 248, .94);
  --glass-edge: rgba(255, 255, 255, .14); --hl: rgba(255, 255, 255, .12);
  --blue-from: #4a6fc4; --blue-to: #35529f;
  --blue-from-h: #3f64b8; --blue-to-h: #2d4891; --blue-tint: rgba(110, 146, 230, .34);
  --sh-c: rgba(0, 0, 0, .4);
  --g-3: 0 0 0 1px var(--glass-edge), 0 18px 46px rgba(0, 0, 0, .5), inset 0 1px 0 var(--hl);
  --g-blue: 0 0 0 1px rgba(255, 255, 255, .2), 0 10px 22px rgba(40, 70, 150, .45), inset 0 1px 0 rgba(255, 255, 255, .3);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); background: var(--bg-glow), var(--bg); background-attachment: fixed; color: var(--text); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: var(--bw-3) solid var(--focus); outline-offset: 2px; }

/* ===== 레이아웃 ===== */
.app { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.app-header { flex: none; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: var(--text); display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-5); height: 68px; position: relative; z-index: 20; box-shadow: 0 1px 0 var(--glass-edge), 0 10px 26px -12px var(--sh-c); }
.app-body { flex: 1; min-height: 0; position: relative; overflow: auto; }
.app-body.is-system { display: flex; overflow: hidden; background: #fff; }
/* P3: banner above the viewer row; the row keeps the iframe and the side panel side by side */
.app-body.is-system { flex-direction: column; }
.viewer-row { flex: 1; min-height: 0; display: flex; position: relative; }
.version-banner { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 10px 20px; background: var(--glass-modal); color: var(--text); font-size: 14px; box-shadow: inset 0 -3px 0 var(--warn); z-index: 3; }
.version-banner .vb-text { min-width: 0; overflow-wrap: anywhere; }
.version-banner .vb-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== 헤더 ===== */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; background: none; border: 0; color: inherit; padding: 0; border-radius: var(--r-pill); }
.brand-mark { width: 38px; height: 38px; border-radius: 13px; background: linear-gradient(180deg, var(--blue-from), var(--blue-to)); color: var(--btn-text); display: grid; place-items: center; flex: none; box-shadow: var(--g-blue); }
.brand-mark svg { width: var(--icon-md); height: var(--icon-md); }
.header-sys { display: flex; align-items: center; gap: 10px; min-width: 0; padding-left: var(--sp-4); margin-left: var(--sp-1); border-left: var(--bw-1) solid var(--line); }
.header-sys img { width: 38px; height: 38px; border-radius: 13px; object-fit: contain; background: #fff; flex: none; box-shadow: var(--g-1); }
.header-sys .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.header-ch { display: flex; align-items: center; gap: 10px; margin-left: var(--sp-1); min-width: 0; overflow-x: auto; padding: 8px 6px; }
/* Viewer toolbar: the PC/Mobile switch and screen list are never clipped; the system name shrinks instead */
.app-header.has-sys .header-ch { flex: none; }
.app-header.has-sys .header-sys { flex: 0 1 auto; }
@media (max-width: 1440px) { .app-header.has-sys .role-badge, .app-header.has-sys .brand span.t { display: none; } }
.app-header.has-sys .brand span.t { white-space: nowrap; }
@media (max-width: 1100px) {
  .app-header.has-sys .brand span.t, .app-header.has-sys .h-btn span.t { display: none; }
  .app-header.has-sys .h-btn { padding: 0 12px; }
}
@media (max-width: 640px) {
  .app-header.has-sys { flex-wrap: wrap; height: auto; row-gap: 2px; padding-top: 10px; padding-bottom: 6px; }
  .app-header.has-sys .header-sys { order: 1; flex: 1 1 0; padding-left: 10px; }
  .app-header.has-sys .header-sys img { width: 32px; height: 32px; border-radius: 10px; }
  .app-header.has-sys .header-sys .nm { max-width: none; }
  .app-header.has-sys .spacer { display: none; }
  .app-header.has-sys .brand { order: 0; }
  .app-header.has-sys .h-btn.primary, .app-header.has-sys .menu-wrap, .app-header.has-sys [data-act="logout"] { order: 2; }
  .app-header.has-sys .header-ch { order: 3; flex: 1 0 100%; justify-content: center; margin-left: 0; padding: 4px 0; }
}
/* 뷰어: PC/Mobile 전환은 클래스만 바꾸고 iframe 노드는 유지 (재로딩 없음) */
.viewer-wrap { flex: 1; min-width: 0; height: 100%; display: flex; justify-content: center; }
.viewer-stage { width: 100%; height: 100%; background: #fff; }
.app-body.is-system.is-mobile { background: transparent; }
.app-body.is-system.is-mobile .viewer-wrap { padding: 24px 16px; overflow: auto; }
.app-body.is-system.is-mobile .viewer-stage { flex: none; width: 390px; max-width: 100%; height: auto; max-height: 844px; align-self: stretch; border-radius: 36px; overflow: hidden; box-shadow: 0 0 0 9px #23262d, 0 24px 60px rgba(30, 36, 52, .35); }
.explorer { flex: none; width: 320px; max-width: 86vw; height: 100%; overflow: auto; padding: 16px; background: var(--glass-modal); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: var(--text); box-shadow: -1px 0 0 var(--glass-edge); }
.ex-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ex-head h2 { margin: 0; font-size: 16px; }
.ex-meta { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.ex-note { color: var(--muted); font-size: 13px; padding: 8px 2px; list-style: none; }
.ex-note.err { color: var(--danger); }
.explorer .ex-q { height: 38px; margin-bottom: 10px; }
.ex-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ex-item { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border: 0; border-radius: var(--r-md); background: none; }
.ex-item:hover { background: var(--glass-strong); }
.ex-item.on { background: var(--blue-tint); }
.ex-item b { font-weight: 500; font-size: 14px; overflow-wrap: anywhere; }
.ex-route { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.ex-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.ex-warn { margin: 12px 0 0; padding-left: 18px; color: var(--warn); font-size: 12.5px; }
/* P3: version history panel */
.ver-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.ver-tools .btn.sm svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.ver-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ver-item { padding: 10px 12px; border-radius: var(--r-md); background: var(--glass); box-shadow: var(--g-1); }
.ver-item.is-active { box-shadow: 0 0 0 2px var(--accent), var(--g-1); }
.ver-item.is-viewing { background: var(--blue-tint); }
.ver-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ver-no { font-size: 15px; margin-right: 2px; }
.ver-meta, .ver-files { margin-top: 4px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.ver-note { margin: 6px 0 0; font-size: 13px; overflow-wrap: anywhere; word-break: keep-all; }
.ver-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.wz-version-line { margin: 0 0 12px; }
.wz-version-hint { margin: 12px 0 0; }
.file-btn.dis { opacity: .5; cursor: not-allowed; box-shadow: none; }
@media (max-width: 760px) {
  .explorer { position: absolute; right: 0; top: 0; z-index: 5; box-shadow: var(--g-3); }
}
.spacer { flex: 1; }
.h-btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 20px; border-radius: var(--r-pill); border: 0; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: var(--text); font-weight: 500; white-space: nowrap; box-shadow: var(--g-1); transition: box-shadow .15s, background .15s, transform .15s; }
.h-btn:hover { background: var(--glass-strong); box-shadow: var(--g-2); }
.h-btn:active { box-shadow: var(--g-in); transform: translateY(1px); }
.h-btn.primary { background: linear-gradient(180deg, var(--blue-from), var(--blue-to)); color: var(--btn-text); box-shadow: var(--g-blue); }
.h-btn.primary:hover { background: linear-gradient(180deg, var(--blue-from-h), var(--blue-to-h)); }
.h-btn svg { width: var(--icon-md); height: var(--icon-md); flex: none; }
.role-badge { display: inline-flex; align-items: center; height: 34px; padding: 0 16px; border-radius: var(--r-pill); box-shadow: var(--g-in); font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.ch-seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--g-1); flex: none; }
.ch-btn { background: transparent; border: 0; border-radius: var(--r-pill); height: 36px; padding: 0 20px; font-weight: 500; color: var(--text); }
.ch-btn:hover { background: var(--glass); }
.ch-btn.on { background: var(--blue-tint); box-shadow: inset 0 1px 0 var(--hl), 0 3px 10px rgba(100, 130, 200, .22); }
.ch-btn small { font-size: 10px; opacity: .7; margin-left: 4px; }
.info-wrap, .menu-wrap { position: relative; }
.info-panel, .menu { position: absolute; right: 0; top: 54px; background: var(--glass-modal); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: var(--text); border-radius: var(--r-md); box-shadow: var(--g-3); }
.info-panel { width: 320px; max-width: calc(100vw - 24px); padding: 16px 18px; max-height: 70vh; overflow: auto; }
.info-panel h3 { margin: 0 0 10px; font-size: 14px; }
.info-panel dl { margin: 0; display: grid; grid-template-columns: 92px 1fr; row-gap: 8px; font-size: 13px; }
.info-panel dt { color: var(--muted); }
.info-panel dd { margin: 0; word-break: break-all; }
.menu { min-width: 184px; padding: 8px; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 14px; border-radius: var(--r-sm); }
.menu button:hover, .menu button[aria-current="page"] { background: var(--blue-tint); }

/* ===== 인트로 ===== */
.intro { max-width: 1080px; margin: 0 auto; padding: var(--sp-7) var(--sp-5) 72px; }
.intro-head { text-align: center; margin-bottom: 40px; }
.intro-head h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; }
.intro-head p { margin: 8px 0 0; color: var(--muted); }
.reorder-note { margin: 28px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.gallery-search { position: relative; max-width: 420px; margin: -14px auto 20px; }
.gallery-count { margin: 8px 0 22px; text-align: center; color: var(--muted); font-size: 13px; }
.gallery-search .input { padding-left: 46px; }
.gs-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); display: grid; pointer-events: none; }
.gs-icon svg { width: var(--icon-md); height: var(--icon-md); }
/* One-row category navigation: the saved category order is preserved. */
.cat-filter-bar { display: flex; align-items: center; gap: 6px; max-width: 100%; margin: 0 0 18px; padding: 6px; border-radius: var(--r-pill); background: var(--glass); box-shadow: var(--g-in); }
.cat-filter { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; gap: 8px; padding: 3px 2px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.cat-filter::-webkit-scrollbar { display: none; }
.cat-filter .chip, .cat-filter-bar > .chip { flex: 0 0 auto; height: 36px; max-width: 240px; padding: 0 14px; white-space: nowrap; }
.cat-filter .chip .chip-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-filter .chip .chip-count { font-size: 11px; font-weight: 600; opacity: .8; }
.cat-filter-bar .cat-all { background: var(--blue-tint); }
.cat-scroll-btn { flex: 0 0 30px; height: 34px; border: 0; border-radius: 50%; background: var(--glass-strong); color: var(--text); font-size: 24px; line-height: 1; display: grid; place-items: center; box-shadow: var(--g-1); cursor: pointer; }
.cat-scroll-btn:hover:not(:disabled) { background: var(--blue-tint); }
.cat-scroll-btn:disabled { cursor: default; opacity: .28; box-shadow: none; }
.cat-filter-bar :is(button, [tabindex]):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 20px; border-radius: var(--r-pill); border: 0; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--g-1); font-weight: 500; transition: box-shadow .15s, background .15s; }
.chip { max-width: 100%; }
.chip span { color: var(--muted); font-size: 12px; font-weight: 400; flex: none; }
.chip .chip-nm { color: inherit; font-size: inherit; font-weight: inherit; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { background: var(--glass-strong); box-shadow: var(--g-2); }
.chip.on { background: var(--blue-tint); box-shadow: inset 0 1px 0 var(--hl), 0 3px 10px rgba(100, 130, 200, .22); }
.chip.on span { color: var(--accent-text); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; }
.tile { position: relative; }
.tile-open { width: 100%; aspect-ratio: 1 / 1; container-type: size; display: grid; grid-template-areas: "cat" "logo" "name"; grid-template-rows: auto 1fr auto; gap: 10px; padding: 18px 18px 20px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 0; border-radius: var(--r-lg); text-align: left; box-shadow: var(--g-2); transition: box-shadow .15s, transform .15s, background .15s; }
.tile-open:hover { background: var(--glass-strong); box-shadow: var(--g-3); transform: translateY(-2px); }
.tile-open:active { box-shadow: var(--g-in); transform: none; }
.tile-logo { grid-area: logo; justify-self: center; align-self: center; width: 54%; width: min(52cqw, calc(100cqh - 116px)); height: auto; aspect-ratio: 1 / 1; border-radius: var(--r-md); object-fit: contain; padding: 6%; background: var(--logo-bg); box-shadow: 0 6px 16px var(--sh-c); }
.tile-logo.ph { display: grid; place-items: center; color: var(--muted); background: var(--sunken); box-shadow: var(--g-in); }
.tile-logo.ph svg { width: 40%; height: 40%; opacity: .6; }
.tile-name { grid-area: name; font-weight: 700; word-break: keep-all; overflow-wrap: anywhere; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-meta .badge { flex: none; }
.tile-meta { grid-area: cat; display: flex; align-items: center; gap: 6px; min-width: 0; padding-right: 4px; }
.tile-cat { flex: 0 1 auto; min-width: 0; margin-right: auto; display: block; line-height: 24px; height: 24px; padding: 0 12px; border-radius: var(--r-pill); box-shadow: var(--g-in); color: var(--muted); font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-cat.none { opacity: .7; }
.tile-tools { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-tools, .tile:focus-within .tile-tools { opacity: 1; }
@media (hover: none) { .tile-tools { opacity: 1; } }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); display: grid; place-items: center; color: var(--muted); box-shadow: var(--g-1); }
.icon-btn:hover { color: var(--text); box-shadow: var(--g-2); }
.icon-btn:active { box-shadow: var(--g-in); }
.icon-btn.del:hover { color: var(--danger); }
.icon-btn svg { width: var(--icon-sm); height: var(--icon-sm); }
.tile-add { aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: var(--r-lg); background: var(--sunken); box-shadow: var(--g-in); color: var(--muted); padding: 24px 12px; font-weight: 500; }
.tile-add:hover { color: var(--accent-text); background: var(--glass); }
.tile-add .plus { width: 48px; height: 48px; border-radius: 50%; background: var(--blue-tint); box-shadow: var(--g-1); color: var(--accent-text); display: grid; place-items: center; }
.tile-add svg { width: var(--icon-lg); height: var(--icon-lg); }
.tile[draggable="true"] .tile-open { cursor: grab; }
.tile.dragging { opacity: .4; }
.tile.is-hidden .tile-logo, .tile.is-hidden .tile-name { opacity: .55; }
/* F11: 최근 열람 카드 (1건) — 연한 파란 배경 + 파란 테두리 + 라벨 */
.tile.is-last .tile-open { background: rgba(110, 146, 230, .16); box-shadow: 0 0 0 2px var(--accent), var(--g-2); }
.last-badge { flex: none; display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: var(--r-pill); background: var(--blue-to); color: #fff; font-size: 11.5px; font-weight: 700; }
.h-btn.on { background: var(--blue-tint); }
.tile.drop-before::before, .tile.drop-after::after { content: ""; position: absolute; top: 0; bottom: 0; width: 4px; border-radius: 2px; background: var(--accent); z-index: 2; }
.tile.drop-before::before { left: -16px; }
.tile.drop-after::after { right: -16px; }
.sys-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 0 0 6px; font-size: 20px; }
.empty p { margin: 0 0 16px; }

/* ===== 관리 화면 (권한·카테고리) ===== */
.page { max-width: 1120px; margin: 0 auto; padding: 40px var(--sp-5) 72px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.split { display: grid; grid-template-columns: 340px 1fr; gap: 28px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.panel { background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-radius: var(--r-lg); box-shadow: var(--g-2); }
.acct-list { list-style: none; margin: 0; padding: 10px; }
.acct-list li + li { margin-top: 4px; }
.acct-item { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 12px 16px; border-radius: var(--r-md); border: 0; background: none; }
.acct-item:hover { background: var(--glass-strong); box-shadow: var(--g-1); }
.acct-item.sel { background: var(--blue-tint); box-shadow: inset 0 1px 0 var(--hl); }
.acct-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.acct-top b { margin-right: 2px; }
.acct-sub { color: var(--muted); font-size: 13px; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: var(--r-pill); box-shadow: var(--g-in); font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.badge.admin { color: var(--accent-text); }
.badge.lock { color: var(--danger); }
.badge.warn { color: var(--warn); }
.detail { padding: 28px 30px 32px; }
.detail-head { display: flex; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-start; margin-bottom: var(--sp-4); }
.detail h2 { margin: 0 0 6px; font-size: 20px; }
.detail-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.detail dl { display: grid; grid-template-columns: 96px 1fr; row-gap: 8px; margin: 0 0 22px; font-size: 14px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; word-break: break-all; }
.sec-title { font-weight: 700; font-size: 15px; margin: 0 0 10px; padding-top: 18px; border-top: var(--bw-1) solid var(--line); }
.chk { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--r-md); cursor: pointer; background: var(--glass); box-shadow: var(--g-1); }
.chk:hover { background: var(--glass-strong); box-shadow: var(--g-2); }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.chk.dis { opacity: .6; cursor: default; box-shadow: none; }
.chk img { width: 24px; height: 24px; border-radius: 6px; object-fit: contain; flex: none; }
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.perm-note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.perm-block { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.perm-h { margin: 0 0 10px; padding: 0; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.perm-count { font-size: 12.5px; font-weight: 500; color: var(--accent-text); }
.perm-role span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.perm-role small { color: var(--muted); font-size: 12.5px; }
.perm-override { margin: 0 0 4px; padding: 10px 14px; border-radius: var(--r-md); background: var(--blue-tint); color: var(--text); }
.chk.dis { position: relative; }
.chk input:disabled { cursor: not-allowed; }
.chk-t { min-width: 0; overflow-wrap: anywhere; }
.perm-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2); margin-top: 6px; padding-top: 16px; border-top: var(--bw-1) solid var(--line); }
.perm-state { margin-right: auto; color: var(--muted); font-size: 13px; }
.perm-state.dirty { color: var(--warn); font-weight: 700; }
.perm-state.dirty::before { content: "●"; margin-right: 6px; font-size: 10px; vertical-align: 1px; }
.perm-err { margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.self-note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.search-panel { padding: 20px 24px; margin-bottom: 24px; }
.search-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 14px 16px; align-items: end; }
.search-grid .field .lb { font-size: 13px; margin-bottom: 6px; }
.acct-count { padding: 14px 18px 4px; color: var(--muted); font-size: 13px; }
.acct-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
@media (max-width: 1000px) { .search-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .search-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; } }
.cat-list { overflow: hidden; }
.cat-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 120px 190px; align-items: center; gap: 10px 14px; padding: 14px 22px; border-top: var(--bw-1) solid var(--line); }
.cat-row:first-child { border-top: 0; }
.cat-row.head { font-size: 13px; font-weight: 700; color: #fff; background: linear-gradient(180deg, var(--blue-from), var(--blue-to)); border-top: 0; }
.cat-row.editing { background: var(--blue-tint); }
.cat-row.head .cat-count { color: inherit; }
.cat-name { font-weight: 500; word-break: break-all; }
.cat-count { color: var(--muted); font-size: 13px; text-align: center; }
.cat-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.cat-row .err { grid-column: 1 / -1; margin: -4px 0 0; color: var(--danger); font-size: 12.5px; }

/* Category order: grip controls mouse drag and keyboard arrow movement. */
.cat-order-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.cat-order-hint { margin: 0 0 12px; color: var(--accent-text); font-size: 13px; }
.cat-order { display: flex; align-items: center; justify-content: center; white-space: nowrap; }
.cat-number { min-width: 2ch; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.cat-handle { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--glass); color: var(--muted); font-size: 19px; cursor: grab; touch-action: none; }
.cat-handle:hover { color: var(--text); background: var(--blue-tint); }
.cat-handle:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.cat-handle:active { cursor: grabbing; }
.cat-handle:disabled { opacity: .45; cursor: not-allowed; }
.cat-row.cat-dragging { opacity: .5; }
.cat-row.cat-drop-target { background: var(--blue-tint); box-shadow: inset 0 2px var(--accent-text); }
@media (max-width: 640px) {
  .cat-row { grid-template-columns: 42px minmax(0, 1fr) 144px; padding: 12px; gap: 8px; }
  .cat-actions { gap: 4px; }
  .cat-actions .btn.sm { padding: 0 8px; height: 30px; font-size: 12px; }
  .cat-handle { width: 30px; height: 30px; flex: none; }
}

/* ===== 모달·폼 ===== */
.overlay.overlay-top { z-index: 70; }
.overlay { position: fixed; inset: 0; background: rgba(40, 48, 66, .3); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); display: grid; place-items: center; padding: var(--sp-4); z-index: 50; }
.modal { width: 100%; max-width: 520px; max-height: 100%; overflow: auto; background: var(--glass-modal); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-radius: var(--r-xl); box-shadow: var(--g-3); }
.modal-head { padding: 26px 30px 0; }
.modal-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.modal-body { padding: 20px 30px 8px; display: grid; gap: 20px; }
.modal-foot { padding: 16px 30px 28px; display: flex; justify-content: flex-end; gap: var(--sp-2); }
.field .lb { display: block; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.field .err { color: var(--danger); font-size: 12.5px; margin: 6px 0 0; }
.req { color: var(--danger); }
.opt { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.req-note { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.form-err { color: var(--danger); font-size: 13px; margin: 4px 30px 0; }
.alert-text { padding-top: 30px; }
.file-status { margin: 6px 0 0; font-size: 12.5px; color: var(--accent-text); overflow-wrap: anywhere; }
.cat-pick { display: flex; gap: 8px; align-items: center; }
.cat-pick .input { flex: 1; min-width: 0; }
.cat-pick .btn.sm { flex: none; white-space: nowrap; }
.cat-pick .btn.sm svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }
.quick-cat { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.quick-cat .input { flex: 1; min-width: 0; height: 38px; }
@media (max-width: 480px) {
  .cat-pick, .quick-cat { flex-wrap: wrap; }
  .cat-pick .btn.sm { width: 100%; }
}

/* ===== 시스템 등록·수정 마법사 (3단계) ===== */
.modal.wizard { max-width: 760px; display: flex; flex-direction: column; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: hidden; }
.modal.wizard > .modal-head, .modal.wizard > .modal-foot, .modal.wizard > .form-err { flex: none; }
.modal.wizard > .modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-top: 16px; }
.wz-head { position: relative; padding-right: 64px; }
.wz-close { position: absolute; top: 20px; right: 20px; font-size: 20px; line-height: 1; }
.wz-steps { list-style: none; display: flex; gap: 8px; margin: 16px 0 0; padding: 0; }
.wz-steps li { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: var(--r-pill); color: var(--muted); font-size: 13px; font-weight: 500; box-shadow: var(--g-in); }
.wz-steps .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--glass-strong); font-size: 12px; flex: none; }
.wz-steps .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wz-steps li[aria-current="step"] { color: var(--text); background: var(--blue-tint); font-weight: 700; }
.wz-steps li.done .n { background: var(--accent); color: #fff; }
.wz-step { display: grid; gap: 20px; }
.wz-title { margin: 0; font-size: 16px; }
.wz-title:focus { outline: none; }
.wz-foot { align-items: center; flex-wrap: wrap; }
.wz-progress { margin-right: auto; color: var(--muted); font-size: 13px; }
.wz-group { padding: 14px 16px; border-radius: var(--r-md); background: var(--sunken); box-shadow: var(--g-in); }
.wz-group + .wz-group { margin-top: 14px; }
.wz-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.wz-group-head h4 { margin: 0; font-size: 14px; }
.wz-review { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 14px; }
.wz-review dt { color: var(--muted); }
.wz-review dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.wz-logo { display: flex; align-items: center; gap: 12px; }
.wz-logo .logo-preview { width: 56px; height: 56px; }
.wz-att { margin: 0; padding-left: 18px; }
@media (max-width: 560px) {
  .wz-steps .t { display: none; }
  .wz-steps li[aria-current="step"] .t { display: inline; }
  .wz-steps li { flex: none; }
  .wz-steps li[aria-current="step"] { flex: 1; }
  .wz-review { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .wz-review dd + dt { margin-top: 8px; }
  .wz-progress { flex-basis: 100%; }
  .wz-foot .btn { flex: 1; }
}
.input { width: 100%; height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill); background: var(--field-bg); box-shadow: var(--g-in); color: var(--text); font: inherit; transition: box-shadow .15s, background-color .15s; }
.input::placeholder { color: var(--placeholder); opacity: 1; }
.input:hover:not(:disabled):not([readonly]) { background-color: var(--field-bg-hover); box-shadow: 0 0 0 1px var(--field-edge-hover), inset 0 2px 6px var(--sh-c); }
.input:focus { outline: var(--bw-3) solid var(--focus); outline-offset: 2px; }
.input[readonly] { opacity: .7; cursor: default; }
.input:disabled { opacity: .55; cursor: not-allowed; }
.input[aria-invalid="true"] { box-shadow: 0 0 0 1.5px var(--danger), inset 0 2px 6px var(--sh-c); }
/* 네이티브 select: 반투명 흰 배경 + 밝은 글자가 Windows 드롭다운 목록에서 흰 바탕/흰 글자로 보이던 문제 수정.
   목록(option)에 불투명 배경과 테마 글자색을 지정하고 color-scheme을 따라가도록 한다. */
select.input { background-color: var(--field-bg); color: var(--text); color-scheme: inherit; cursor: pointer; padding-right: 14px; text-overflow: ellipsis; }
select.input option, select.input optgroup { background-color: var(--field-solid); color: var(--text); }
select.input option:checked { background-color: var(--option-sel-bg); color: var(--option-sel-text); }
select.input option[value=""] { color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.file-row { display: flex; align-items: center; gap: var(--sp-3); }
.file-btn { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 18px; border: 0; border-radius: var(--r-pill); background: var(--glass-strong); box-shadow: var(--g-1); font-weight: 500; cursor: pointer; flex: none; }
.file-btn:hover { box-shadow: var(--g-2); }
.file-btn:active { box-shadow: var(--g-in); }
.file-btn svg { width: var(--icon-sm); height: var(--icon-sm); }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn:focus-within { outline: var(--bw-3) solid var(--focus); outline-offset: 2px; }
.file-btn.sm { height: 32px; padding: 0 14px; font-size: 13px; }
.file-name { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file-name.ok { color: var(--text); }
.logo-preview { width: 72px; height: 72px; border-radius: var(--r-md); box-shadow: var(--g-1); object-fit: contain; background: var(--logo-bg); flex: none; }
.btn { height: 42px; padding: 0 22px; border-radius: var(--r-pill); border: 0; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--g-1); font-weight: 500; transition: box-shadow .15s, background .15s, transform .15s; }
.btn:hover { box-shadow: var(--g-2); }
.btn:active { box-shadow: var(--g-in); transform: translateY(1px); }
.btn.sm { height: 34px; padding: 0 16px; font-size: 14px; }
.btn.primary { background: linear-gradient(180deg, var(--blue-from), var(--blue-to)); color: var(--btn-text); box-shadow: var(--g-blue); }
.btn.primary:hover { background: linear-gradient(180deg, var(--blue-from-h), var(--blue-to-h)); }
.btn.warning { background: linear-gradient(180deg, #e3a13a, #be7412); color: #fff; box-shadow: 0 8px 18px rgba(190, 116, 18, .32), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn.warning:hover { background: linear-gradient(180deg, #edaf4c, #ce8119); }
.btn.danger { background: linear-gradient(180deg, var(--danger-from), var(--danger-to)); color: #fff; box-shadow: 0 8px 18px rgba(196, 72, 63, .3), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn:disabled { opacity: .5; box-shadow: none; cursor: not-allowed; transform: none; }
.btn.primary:disabled, .btn.warning:disabled, .btn.danger:disabled { box-shadow: none; }
.h-btn:disabled, .icon-btn:disabled, .chip:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.sm svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.confirm-text { padding: 20px 30px 6px; margin: 0; word-break: keep-all; overflow-wrap: anywhere; }
.modal.modal-sm { max-width: 420px; }
/* Toast: below the header, above dialogs, never blocks clicks (does not hide footer buttons on mobile) */
.toast { position: fixed; left: 50%; top: calc(80px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; width: max-content; background: var(--glass-modal); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: var(--text); padding: 12px 22px 12px 14px; border-radius: var(--r-pill); font-size: 14px; line-height: 1.45; z-index: 90; box-shadow: var(--g-3); max-width: min(560px, calc(100vw - 32px)); pointer-events: none; word-break: keep-all; overflow-wrap: anywhere; }
.toast::before { content: "\2713"; flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--blue-to); }
.toast.error { color: var(--danger); box-shadow: 0 0 0 1.5px var(--danger), var(--g-3); }
.toast.error::before { content: "!"; background: var(--danger-to); }
.att-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.att-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 16px; border-radius: var(--r-md); background: var(--sunken); box-shadow: var(--g-in); font-size: 13px; }
.att-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-sz { color: var(--muted); font-size: 12px; flex: none; }
.att-list .icon-btn { width: 28px; height: 28px; flex: none; }

/* ===== 채널 설정 표·스위치 ===== */
.ch-wrap { overflow-x: auto; border-radius: var(--r-md); background: var(--sunken); box-shadow: var(--g-in); padding: 6px 10px; }
.ch-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.ch-table th { background: linear-gradient(180deg, var(--blue-from), var(--blue-to)); color: #fff; font-weight: 700; font-size: 13px; padding: 10px 12px; text-align: left; }
.ch-table td { padding: 10px 12px; border-top: var(--bw-1) solid var(--line); vertical-align: middle; }
.ch-table .ch-name { height: 38px; min-width: 120px; }
.ch-file { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-file.ok { color: var(--text); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw { width: 52px; height: 28px; border-radius: 14px; background: var(--sunken); box-shadow: var(--g-in); position: relative; transition: background .15s; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(180deg, #ffffff, #eceef3); box-shadow: 0 2px 6px rgba(60, 70, 92, .32); transition: transform .15s, background .15s; }
.switch input:checked + .sw { background: var(--blue-tint); }
.switch input:checked + .sw::after { transform: translateX(24px); background: linear-gradient(180deg, #9ab8ee, #6f95dc); }
.switch input:focus-visible + .sw { outline: var(--bw-3) solid var(--focus); outline-offset: 2px; }
.sw-t { font-size: 13px; font-weight: 500; min-width: 28px; }

@media (max-width: 640px) {
  .app-header { padding: 0 var(--sp-3); gap: 6px; }
  .brand span.t, .h-btn span.t { display: none; }
  .h-btn { padding: 0 12px; }
  .header-sys .nm { max-width: 26vw; }
  .ch-btn { padding: 0 14px; }
  .role-badge { display: none; }
  .intro { padding: 30px var(--sp-4) 48px; }
  .intro-head h1 { font-size: 24px; }
  .cat-filter-bar { gap: 4px; padding: 5px; }
  .cat-filter { gap: 6px; }
  .cat-filter .chip, .cat-filter-bar > .chip { max-width: 170px; height: 34px; padding: 0 11px; font-size: 12px; }
  .cat-scroll-btn { flex-basis: 26px; height: 30px; font-size: 21px; }
  .page { padding: 24px var(--sp-4) 48px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .tile-open { padding: 14px 14px 16px; gap: 6px; }
  .tile-name { font-size: 14px; line-height: 1.35; }
  .tile-logo { width: min(58cqw, calc(100cqh - 100px)); padding: 3px; }
  .tile-tools { right: 8px; gap: 4px; }
  .icon-btn { width: 30px; height: 30px; }
  .modal-head { padding: 22px 20px 0; } .modal-body { padding: 16px 20px 8px; } .modal-foot { padding: 14px 20px 22px; }
  .confirm-text { padding: 16px 20px 6px; } .form-err { margin: 4px 20px 0; }
  .toast { top: calc(76px + env(safe-area-inset-top, 0px)); }
  .cat-row { grid-template-columns: 42px minmax(0, 1fr) 144px; } .cat-row .cat-count { display: none; }
}
@media (min-width: 641px) and (max-width: 900px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.gallery-controls, .pagination { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin:14px 0; }
.gallery-controls label { display:flex; align-items:center; gap:6px; white-space:nowrap; }
.gallery-controls label select { width:auto; }
.pagination { justify-content:center; }
.perm-table-wrap { overflow-x:auto; }
.perm-table { width:100%; border-collapse:collapse; }
.perm-table th, .perm-table td { padding:10px; border-bottom:1px solid #ddd; text-align:center; }
.perm-table th:first-child, .perm-table td:first-child { text-align:left; overflow-wrap:anywhere; }


/* 번호 | 카테고리명 | 사용 시스템 | 관리 | 순서 */
.cat-list .cat-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 120px 160px 72px;
  align-items: center;
  column-gap: 12px;
}

/* Căn giữa toàn bộ tiêu đề */
.cat-list .cat-row.head > span {
  text-align: center;
  justify-content: center;
}

/* Căn giữa STT, số hệ thống, nút quản lý, kéo thả */
.cat-list .cat-row .cat-order,
.cat-list .cat-row .cat-count,
.cat-list .cat-row .cat-actions,
.cat-list .cat-row .cat-sort {
  text-align: center;
  justify-content: center;
}

.cat-list .cat-row .cat-sort {
  display: flex;
  align-items: center;
}

.cat-list .cat-row.editing > .err {
  grid-column: 2 / -1;
}