/* ============================================================
   ABKO 드라이버 테마 — driver.abko.co.kr 기존 ODM 드라이버의 UI 톤을 따름
   (레드 액센트 · 좌측 흰색 사이드바 · 연회색 작업 영역 · 흰 패널 카드)
   style.css 뒤에 로드되어 색상 토큰과 레이아웃만 덮어쓴다. 컴포넌트 규칙은 style.css 그대로.
   ============================================================ */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #e53935;
  --accent-soft: #fee2e2;
  --accent-border: #fecaca;
  --accent-glow: rgba(239, 68, 68, 0.22);
  --hover: #f3f4f6;
  --surface2: #f1f1f1;
  --surface3: #fafafa;
  --track: #e0e0e0;
  --topbar-bg: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
  --sidebar-w: 260px;
  --topbar-h: 56px;
}
:root[data-theme="dark"] {
  --accent: #f05252;
  --accent-soft: #3b1d1f;
  --accent-border: #6b2b2f;
  --accent-glow: rgba(240, 82, 82, 0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

/* 파란 계열로 하드코딩된 강조색 → 레드 */
.btn.primary:hover { background: #c62828; border-color: #c62828; }
:root[data-theme="dark"] .btn.primary:hover { background: #d94040; border-color: #d94040; }
.sw-gauge-fill { background: linear-gradient(to bottom, var(--accent), #ff8a80); }
.flash-fill { background: linear-gradient(to right, var(--accent), #ff8a80); }
.mds-slot.active { box-shadow: 0 0 0 2px var(--accent-glow); }

/* ============ 상단 바: 좌측 ABKO 로고 · 우측 언어/연결 ============ */
.topbar {
  height: var(--topbar-h); padding: 0 24px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: none;
}
.brand-mark, .brand-name { display: none; }
.brand-logo { height: 24px; width: auto; display: block; }
:root[data-theme="dark"] .brand-logo { filter: brightness(1.15); }
.dev-badge { display: none !important; } /* 기기 정보는 사이드바 카드로 이동 */
.lang-sel {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 12.5px; color: var(--muted);
  padding: 6px 22px 6px 8px; border-radius: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.lang-sel:hover { background-color: var(--hover); color: var(--text); }
.lang-sel:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }

/* ============ 시작(연결) 화면 — 기존 드라이버 첫 화면 ============ */
#app { max-width: none; padding: 0; }
.welcome {
  position: relative; min-height: calc(100vh - var(--topbar-h));
  padding: 0 24px; align-items: center;
  background: var(--card) url("../assets/brand/connect-bg.png") center / cover no-repeat;
}
:root[data-theme="dark"] .welcome { background-image: none; }
.welcome-inner {
  background: transparent; border: 0; box-shadow: none;
  max-width: 680px; padding: 0 0 140px;
}
.welcome-kb-art { display: none; }
.welcome h1 { margin: 0 0 24px; font-size: 30px; font-weight: 700; letter-spacing: 0; color: var(--text); }
.welcome-logo { width: 300px; max-width: 70vw; height: auto; display: block; margin: 0 auto 24px; }
.welcome p { color: var(--text); opacity: .8; font-size: 16px; margin: 0 0 32px; }
.welcome .btn.lg {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 200px; padding: 16px 48px; font-size: 18px; font-weight: 600;
  border-radius: 8px; background: #ff0000; border-color: #ff0000; color: #fff;
  transition: all .3s;
}
.welcome .btn.lg::before { content: "+"; font-size: 24px; font-weight: 300; line-height: 1; }
.welcome .btn.lg:hover { background: #cc0000; border-color: #cc0000; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255, 0, 0, .3); }
.welcome .hint {
  display: inline-block; margin-top: 22px; min-height: 1em;
  font-size: 13.5px; color: var(--text); opacity: .75;
}
.welcome .hint:not(:empty) {
  padding: 10px 18px; border-radius: 12px; background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(6px); opacity: 1; color: #333;
}
:root[data-theme="dark"] .welcome .hint:not(:empty) { background: rgba(255, 255, 255, .08); color: var(--text); }
.notice { margin: 60px auto; max-width: 640px; }

/* ============ 작업 공간: 좌측 사이드바 + 우측 작업 영역 ============ */
#workspace, #workspace.hidden { }
#workspace {
  display: grid !important;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0; align-items: start;
}
#workspace.hidden { display: none !important; }
.sidebar {
  position: sticky; top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  background: var(--card); border-right: 1px solid var(--border);
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.ws-main { min-width: 0; padding: 20px 24px 48px; }

/* 사이드바: 현재 장치 카드 */
.device-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  margin-bottom: 12px;
}
.device-card .dc-thumb {
  width: 64px; height: 36px; flex-shrink: 0; object-fit: contain;
  border-radius: 6px; background: var(--surface3);
}
.device-card .dc-thumb--generic { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; color: var(--faint); }
.device-card .dc-text { min-width: 0; display: flex; flex-direction: column; }
.device-card .dc-label { font-size: 11px; color: var(--faint); }
.device-card .dc-name { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-card .dc-fw { font-size: 11px; color: var(--muted); }
.device-card .dc-dot {
  margin-left: auto; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
}
.side-label { font-size: 11.5px; color: var(--faint); margin: 10px 2px 6px; }

/* 사이드바: 설정 전환(프로필) */
.sidebar .profile-bar {
  width: auto; max-width: none; margin: 0; overflow: visible;
  flex-wrap: wrap; gap: 6px; padding: 10px;
  border-radius: 8px; border: 0; box-shadow: none; background: var(--surface2);
}
.sidebar .pb-label { display: none; }
.sidebar .pb-slot { padding: 5px 0; flex: 1 1 calc(25% - 6px); text-align: center; border-radius: 6px; font-size: 12px; }
.sidebar .profile-bar .grow { display: none; }
.sidebar .profile-bar .btn { flex: 1 1 auto; font-size: 12px; padding: 6px 8px; border-radius: 6px; }

/* 사이드바: 메뉴 (탭) */
.sidebar .tabs {
  flex-direction: column; gap: 4px; width: auto; margin: 0;
  background: transparent; border: 0; border-radius: 0; padding: 0; box-shadow: none; overflow: visible;
}
.sidebar .tabs button {
  position: relative; justify-content: flex-start;
  height: 40px; padding: 0 12px 0 14px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--text);
}
.sidebar .tabs button svg { width: 16px; height: 16px; color: var(--muted); }
.sidebar .tabs button:hover { background: var(--hover); color: var(--text); }
.sidebar .tabs button.active {
  background: var(--accent-soft); color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}
.sidebar .tabs button.active svg { color: var(--accent); }
.sidebar .tabs button.active::after {
  content: ""; position: absolute; right: -17px; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 2px;
}

/* 작업 영역: 키보드 (카드 없이 회색 바탕 위에) */
.kb-card { background: transparent; border: 0; box-shadow: none; padding: 4px 0 8px; margin-bottom: 12px; }
.kb-toolbar { margin-bottom: 12px; }
.layer-toggle { background: transparent; padding: 0; gap: 6px; border: 0; }
.layer-toggle button {
  border-radius: 5px; padding: 7px 16px; font-weight: 600; font-size: 13px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
}
.layer-toggle button.active { background: #111; border-color: #111; color: #fff; }
:root[data-theme="dark"] .layer-toggle button.active { background: #fff; border-color: #fff; color: #111; }
.kb-tools .btn.ghost { background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 6px; }
.kb-tools .btn.ghost:hover { background: var(--hover); }
.kb { margin: 0 auto; }

/* 작업 영역: 패널 */
.panel { padding: 22px 24px; border-radius: 12px; }
.panel h3 { font-size: 15px; }
.rapid-dock, .pad-dock { margin-bottom: 12px; }
.sub-pills button { border-radius: 8px; padding: 8px 18px; }
.sub-pills button.active { font-weight: 700; }
.palette-tabs button { border-radius: 8px; }
.pal-key { border-color: #dedede; box-shadow: none; color: #686868; font-weight: 500; }
:root[data-theme="dark"] .pal-key { border-color: var(--border-strong); color: var(--key-text); }
.pal-key:hover { color: var(--accent); }
.item-row, .duo-card, .setting-card { border-radius: 10px; }
.foot { padding: 14px 0 22px; }

/* 좁은 화면: 사이드바를 위로 */
@media (max-width: 900px) {
  #workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar .tabs { flex-direction: row; flex-wrap: wrap; }
  .sidebar .tabs button { height: 36px; padding: 0 12px; font-size: 13px; }
  .sidebar .tabs button.active::after { display: none; }
  .ws-main { padding: 14px 12px 30px; }
}

/* 구형 모델 드라이버로 돌아가는 링크 (하위 폴더 배포 시에만 표시) */
.legacy-link { display: block; margin-top: 18px; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.legacy-link:hover { color: var(--accent); }
