/* =====================================================
   GIẢI TRÍ TRÊN XE — giao diện màn hình đầu xe
   Chủ đề: than chì + hổ phách. Sáng/tối dùng chung biến màu.
   ===================================================== */

:root {
  color-scheme: dark;

  --bg:        #0b0d10;
  --panel:     #12151a;
  --surface:   #1a1e25;
  --surface-2: #232832;
  --surface-3: #2d3340;
  --line:      #2a303a;
  --text:      #f3f5f8;
  --muted:     #8e97a6;
  --accent:    #ffb224;
  --accent-ink:#241600;
  --yt:        #ff3030;
  --tv:        #f36f21;
  --radio:     #14b8a6;
  --links:     #6366f1;
  --danger:    #ff5a5f;

  --radius:    1rem;
  --bar-h:     3.875rem;
  --dock-h:    5.5rem;
  --handle-w:  0.75rem;
  --shadow:    0 0.75rem 2.125rem rgba(0, 0, 0, .5);

  font-family: "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", system-ui, -apple-system, Arial, sans-serif;
}

body.light {
  color-scheme: light;

  --bg:        #e8e5dd;
  --panel:     #f7f5f0;
  --surface:   #ffffff;
  --surface-2: #eeebe3;
  --surface-3: #e0dcd1;
  --line:      #d8d3c7;
  --text:      #17191e;
  --muted:     #686f7d;
  --accent:    #d97706;
  --accent-ink:#ffffff;
  --shadow:    0 0.75rem 1.875rem rgba(60, 50, 30, .18);
}

/* ---------- Cỡ giao diện (tối ưu cho màn hình xe 15,6 inch như VF9) ----------
   Mọi kích thước dùng rem, nên chỉ cần đổi cỡ chữ gốc là cả giao diện co giãn.
   --auto: tự phóng to theo độ rộng màn hình.
   --user: người dùng chọn bằng nút "Cỡ giao diện" (Nhỏ / Vừa / Lớn / Rất lớn). */
:root { --auto: 1; --user: 1; }
@media (min-width: 1500px) { :root { --auto: 1.125; } }
@media (min-width: 1900px) { :root { --auto: 1.25; } }
@media (min-width: 2400px) { :root { --auto: 1.5; } }

:root[data-size="nho"]    { --user: .9; }
:root[data-size="vua"]    { --user: 1; }
:root[data-size="lon"]    { --user: 1.15; }
:root[data-size="ratlon"] { --user: 1.3; }

html { font-size: calc(16px * var(--auto) * var(--user)); }

/* ---------- Nền tảng ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input { -webkit-user-select: text; user-select: text; }

.i { width: 1.625rem; height: 1.625rem; flex: none; display: block; }

.app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- Bố cục chính ---------- */
.screen {
  --main-w: calc(70% - var(--handle-w) / 2);
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 0;
  padding: 0.625rem 0.625rem 0;
  overflow: hidden;
}

.panel {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  overflow: hidden;
}

.main-panel { flex: 0 0 var(--main-w); }
.side-panel { flex: 1 1 0; padding: 0.625rem; gap: 0.625rem; background: transparent; border: 0; border-radius: 0; overflow: auto; }

.resize {
  flex: 0 0 var(--handle-w);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  touch-action: none;
}
.grip {
  width: 0.25rem;
  height: 3.5rem;
  border-radius: 0.25rem;
  background: var(--surface-3);
  transition: background .15s, height .15s;
}
.resize:hover .grip,
.resize.dragging .grip { background: var(--accent); height: 4.75rem; }

.screen.swapped .side-panel { order: 1; }
.screen.swapped .resize     { order: 2; }
.screen.swapped .main-panel { order: 3; }

.screen.solo { --main-w: 100%; padding-right: 0.625rem; }
.screen.solo .side-panel,
.screen.solo .resize { display: none; }

/* ---------- Thanh công cụ của khung ---------- */
.toolbar {
  height: var(--bar-h);
  min-height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.75rem 0 0.875rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.625rem; font-weight: 700; font-size: 1rem; white-space: nowrap; }
.badge {
  width: 2.375rem;
  height: 2.375rem;
  border-radius: 0.75rem;
  display: grid;
  place-items: center;
  color: #fff;
}
.badge .i { width: 1.5rem; height: 1.5rem; }
.badge.yt { background: var(--yt); }
.badge.tv { background: var(--tv); }
.badge.radio { background: var(--radio); }
.badge.links { background: var(--links); }
.grow { flex: 1; }

.search { flex: 1; min-width: 0; display: flex; gap: 0.5rem; margin: 0; }
.search input {
  flex: 1;
  min-width: 0;
  height: 2.875rem;
  padding: 0 1rem;
  border: 1.5px solid var(--line);
  border-radius: 0.875rem;
  outline: none;
  background: var(--panel);
  font-size: 0.9375rem;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); }

.tool {
  height: 2.875rem;
  min-width: 2.875rem;
  padding: 0 0.75rem;
  border-radius: 0.875rem;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background .15s, transform .1s;
}
.tool .i { width: 1.375rem; height: 1.375rem; }
.tool:hover { background: var(--surface-3); }
.tool:active { transform: scale(.94); }
.tool:disabled { opacity: .55; }
.tool.primary { background: var(--accent); color: var(--accent-ink); }
.tool.primary:hover { filter: brightness(1.08); }
.tool.listening { background: var(--danger); color: #fff; animation: pulse 1s ease-in-out infinite; }
.tool.wide { padding: 0 1rem; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 95, .55); }
  50%      { box-shadow: 0 0 0 0.5625rem rgba(255, 90, 95, 0); }
}

/* ---------- Sân khấu phát video ---------- */
.stage { position: relative; flex: 1; min-height: 0; background: #000; }
.stage iframe,
#player,
#player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 1.5rem;
  text-align: center;
  background:
    radial-gradient(56.25rem 26.25rem at 50% 0%, rgba(255, 178, 36, .10), transparent 70%),
    var(--panel);
}
.empty-badge {
  width: 4.75rem;
  height: 4.75rem;
  border-radius: 1.5rem;
  background: var(--yt);
  color: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 0.75rem;
  box-shadow: 0 0.875rem 2.125rem rgba(255, 48, 48, .32);
}
.empty-badge .i { width: 2.75rem; height: 2.75rem; }
.empty h1 { margin: 0; font-size: 1.625rem; letter-spacing: -.01em; }
.empty p { margin: 0; color: var(--muted); font-size: 0.9375rem; max-width: 26.25rem; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.625rem; margin-top: 1.25rem; max-width: 35rem; }
.chip {
  height: 2.875rem;
  padding: 0 1.25rem;
  border-radius: 62.4375rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: background .15s, border-color .15s, transform .1s;
}
.chip:hover { background: var(--surface-3); border-color: var(--accent); }
.chip:active { transform: scale(.95); }

/* ---------- Kết quả tìm kiếm / lịch sử ---------- */
.results {
  position: absolute;
  top: var(--bar-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  overflow: auto;
  padding: 0 0.625rem 0.75rem;
  background: var(--panel);
  overscroll-behavior: contain;
}
.results-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.375rem 0.625rem;
  background: var(--panel);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.results-close { width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; display: grid; place-items: center; background: var(--surface-2); color: var(--text); }
.results-close .i { width: 1.25rem; height: 1.25rem; }

.row {
  width: 100%;
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.875rem;
  align-items: center;
  padding: 0.5rem;
  border-radius: 0.875rem;
  text-align: left;
  transition: background .12s;
}
.row:hover { background: var(--surface); }
.row:active { background: var(--surface-2); }
.row .thumb { position: relative; width: 8.5rem; aspect-ratio: 16 / 9; border-radius: 0.625rem; overflow: hidden; background: var(--surface-2); }
.row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row .dur {
  position: absolute;
  right: 0.375rem;
  bottom: 0.375rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.375rem;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
}
.row .title { font-size: 0.9375rem; line-height: 1.35; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .channel { margin-top: 0.375rem; font-size: 0.7812rem; color: var(--muted); }

.message { padding: 2.5rem 1rem; text-align: center; color: var(--muted); font-size: 0.9375rem; line-height: 1.5; }

/* ---------- Bảng bên phải ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1rem 1.125rem;
}
.label {
  font-size: 0.7188rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.count { color: var(--accent); margin-left: 0.25rem; }

.clock-card {
  flex: none;
  padding: 1.125rem 1.25rem;
  background: linear-gradient(160deg, var(--surface), var(--panel));
}
.clock-time {
  font-size: clamp(2.75rem, 6.2vw, 5.25rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.clock-date { margin-top: 0.625rem; font-size: 0.9375rem; color: var(--muted); font-weight: 500; }

.now-card { flex: none; }
.now-title { font-size: 1.0625rem; line-height: 1.35; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.now-channel { margin-top: 0.375rem; color: var(--muted); font-size: 0.8438rem; }

.queue-card { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 0.5rem; }
.queue-list { flex: 1; min-height: 0; overflow: auto; margin: 0 -0.5rem; padding: 0 0.5rem; overscroll-behavior: contain; }
.queue-empty { margin: 0; padding: 0.875rem 0.25rem; color: var(--muted); font-size: 0.8438rem; line-height: 1.5; }

.q-item {
  width: 100%;
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 0.625rem;
  align-items: center;
  padding: 0.4375rem;
  margin-bottom: 0.25rem;
  border-radius: 0.75rem;
  text-align: left;
  border: 1.5px solid transparent;
}
.q-item:hover { background: var(--surface); }
.q-item.current { background: var(--surface-2); border-color: var(--accent); }
.q-item img { width: 4rem; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 0.4375rem; display: block; background: var(--surface-2); }
.q-item .q-title { font-size: 0.8125rem; line-height: 1.3; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q-item .q-channel { font-size: 0.7188rem; color: var(--muted); margin-top: 0.1875rem; }

/* ---------- Thanh điều khiển dưới ---------- */
.dock {
  height: var(--dock-h);
  min-height: var(--dock-h);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 0.75rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -0.5rem 1.5rem rgba(0, 0, 0, .18);
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }

.key {
  flex: none;
  height: 4.125rem;
  min-width: 4.125rem;
  padding: 0.375rem 0.5rem;
  border-radius: 1rem;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: background .15s, transform .1s;
}
.key:hover { background: var(--surface-3); }
.key:active { transform: scale(.93); }
.key .lbl { font-size: 0.7188rem; font-weight: 600; white-space: nowrap; color: var(--muted); }
.key.active { background: var(--accent); color: var(--accent-ink); }
.key.active .lbl { color: inherit; }
.key.main { min-width: 5rem; background: var(--accent); color: var(--accent-ink); }
.key.main .lbl { color: inherit; }
.key.main .i { width: 1.875rem; height: 1.875rem; }
.key.main:hover { filter: brightness(1.08); }

.sep { flex: none; width: 1px; height: 2.375rem; background: var(--line); margin: 0 0.125rem; }
.spacer { flex: 1 0 0.5rem; }

.volume {
  flex: none;
  height: 4.125rem;
  padding: 0 0.375rem;
  border-radius: 1rem;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.vol-btn { width: 2.5rem; height: 3.125rem; border-radius: 0.75rem; display: grid; place-items: center; background: var(--surface-3); transition: transform .1s; }
.vol-btn:active { transform: scale(.9); }
.vol-btn .i { width: 1.375rem; height: 1.375rem; }
.vol-value { min-width: 3rem; text-align: center; font-size: 1.1875rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.vol-value small { font-size: 0.6875rem; color: var(--muted); margin-left: 1px; }

.dock-clock { flex: none; padding: 0 0.25rem 0 0.375rem; font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Thông báo nhỏ ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 1.125rem);
  transform: translateX(-50%);
  max-width: min(32.5rem, 90vw);
  padding: 0.75rem 1.25rem;
  border-radius: 0.875rem;
  background: var(--text);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  z-index: 200;
}

/* ---------- Co giãn theo màn hình ---------- */
@media (max-width: 1400px) {
  .key { min-width: 3.75rem; padding: 0.375rem 0.5rem; }
  .key .lbl { display: none; }
  .key { height: 3.875rem; }
  .key.main { min-width: 4.5rem; }
  #layoutBtn .lbl { display: block; }
  .dock-clock { display: none; }   /* giờ đã có ở bảng bên phải */
}
@media (max-width: 1180px) {
  .brand-name { display: none; }
  .tool.wide span { display: none; }
  .tool.wide { padding: 0 0.75rem; }
}

@media (max-width: 900px) {
  :root { --bar-h: 3.625rem; --dock-h: 5rem; }
  .dock { gap: 0.375rem; padding: 0.5rem 0.625rem; }
  .key { height: 3.625rem; min-width: 3.5rem; }
  .volume { height: 3.625rem; }
  .vol-btn { width: 2.375rem; height: 2.75rem; }
  .row { grid-template-columns: 7rem 1fr; }
  .row .thumb { width: 7rem; }
  .dock-clock { display: none; }
}

@media (max-width: 760px) {
  .screen { --main-w: 100% !important; padding: 0.5rem 0.5rem 0; }
  .side-panel, .resize { display: none !important; }
  #layoutBtn, #swapBtn { display: none; }
  .chip { height: 2.625rem; padding: 0 1rem; font-size: 0.875rem; }
}

@media (max-height: 480px) {
  :root { --bar-h: 3.25rem; --dock-h: 4.5rem; }
  .key, .volume { height: 3.375rem; }
  .clock-time { font-size: 2.5rem; }
  .empty-badge { width: 3.5rem; height: 3.5rem; margin-bottom: 0.25rem; }
  .empty h1 { font-size: 1.25rem; }
  .chips { margin-top: 0.625rem; }
}

/* =====================================================
   TÍNH NĂNG MỚI
   ===================================================== */

/* ---------- Gợi ý từ khóa gần đây ---------- */
.toolbar { position: relative; }
.recent-box {
  position: absolute;
  top: calc(100% - 0.25rem);
  left: 4rem;
  right: 0.75rem;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.recent { margin-top: 1rem; max-width: 40rem; }
.recent-label { font-size: 0.7188rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.recent .chips { margin-top: 0.5rem; }
.chip.small { height: 2.5rem; padding: 0 1rem; font-size: 0.875rem; }

/* ---------- Thanh điều khiển video ---------- */
.pbar {
  flex: none;
  padding: 0.5rem 0.875rem 0.625rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.seek-row { display: flex; align-items: center; gap: 0.75rem; }
.seek-time { min-width: 3.25rem; font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.seek-time:last-child { text-align: right; }

.seek {
  --p: 0%;
  flex: 1;
  min-width: 0;
  height: 2.5rem;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: none;
}
.seek::-webkit-slider-runnable-track {
  height: 0.625rem;
  border-radius: 0.5rem;
  background: linear-gradient(to right, var(--accent) var(--p), var(--surface-3) var(--p));
}
.seek::-moz-range-track { height: 0.625rem; border-radius: 0.5rem; background: var(--surface-3); }
.seek::-moz-range-progress { height: 0.625rem; border-radius: 0.5rem; background: var(--accent); }
.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.75rem;
  height: 1.75rem;
  margin-top: -0.5625rem;
  border-radius: 50%;
  border: 0.1875rem solid var(--surface);
  background: var(--accent);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, .45);
}
.seek::-moz-range-thumb { width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 0.1875rem solid var(--surface); background: var(--accent); }
.seek:disabled { opacity: .45; cursor: default; }

.pkeys { display: flex; gap: 0.5rem; margin-top: 0.125rem; overflow-x: auto; scrollbar-width: none; }
.pkeys::-webkit-scrollbar { display: none; }
.pk {
  flex: 1 0 auto;
  min-width: 4.75rem;
  height: 3.25rem;
  padding: 0 0.875rem;
  border-radius: 0.875rem;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, transform .1s;
}
.pk .i { width: 1.5rem; height: 1.5rem; }
.pk:hover { background: var(--surface-3); }
.pk:active { transform: scale(.94); }
.pk.on { background: var(--accent); color: var(--accent-ink); }
.pk.fav-on { color: var(--danger); }
.pk.dim { opacity: .6; }

/* ---------- Khung nội dung có thể cuộn (Radio, Lối tắt) ---------- */
.sheet { flex: 1; min-height: 0; overflow: auto; padding: 1rem; overscroll-behavior: contain; }
.hint { margin: 0 0 1rem; color: var(--muted); font-size: 0.875rem; line-height: 1.5; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: 0.875rem; }
.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-height: 5.5rem;
  padding: 0.875rem 1rem;
  border-radius: 1.125rem;
  border: 1.5px solid var(--line);
  background: var(--surface);
  text-align: left;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.tile:hover { background: var(--surface-2); }
.tile:active { transform: scale(.96); }
.tile.playing { border-color: var(--accent); background: var(--surface-2); }
.tile-ico {
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.375rem;
  font-weight: 800;
}
.tile-name { font-size: 1rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.tile-sub { margin-top: 0.1875rem; font-size: 0.75rem; color: var(--muted); }
.tile-x {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, .4);
}
.tile-x .i { width: 1.125rem; height: 1.125rem; }

.add-form { display: flex; flex-wrap: wrap; gap: 0.625rem; margin-bottom: 1rem; }
.add-form input {
  flex: 1 1 12rem;
  min-width: 0;
  height: 2.875rem;
  padding: 0 1rem;
  border: 1.5px solid var(--line);
  border-radius: 0.875rem;
  outline: none;
  background: var(--panel);
  font-size: 0.9375rem;
}
.add-form input:focus { border-color: var(--accent); }

.radio-now {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.125rem;
  border-radius: 1.125rem;
  background: var(--surface);
  border: 1px solid var(--line);
}
.radio-now-title { flex: 1 1 100%; font-size: 1.25rem; font-weight: 700; }
.radio-now-status { flex: 1 1 14rem; color: var(--muted); font-size: 0.875rem; line-height: 1.45; }
.radio-now.error .radio-now-status { color: var(--danger); }

/* ---------- Hộp thoại ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, .6);
}
.modal-card {
  width: min(36rem, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 1.25rem 1.5rem 1.5rem;
  border-radius: 1.5rem;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.modal-card.wide { width: min(50rem, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.modal-head h2 { margin: 0; font-size: 1.375rem; }

.set-group { margin-top: 1.25rem; }
.set-label { margin-bottom: 0.625rem; font-size: 0.7188rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.seg { display: flex; gap: 0.5rem; }
.seg button {
  flex: 1;
  min-height: 3.5rem;
  padding: 0 0.75rem;
  border-radius: 0.875rem;
  background: var(--surface-2);
  font-size: 0.9375rem;
  font-weight: 600;
}
.seg button:hover { background: var(--surface-3); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 0.875rem; font-size: 0.9375rem; }
.stepper { display: flex; align-items: center; gap: 0.25rem; padding: 0.25rem; border-radius: 1rem; background: var(--surface-2); }
.stepper button { width: 2.875rem; height: 2.875rem; border-radius: 0.75rem; display: grid; place-items: center; background: var(--surface-3); }
.stepper button:active { transform: scale(.92); }
.stepper .i { width: 1.25rem; height: 1.25rem; }
.stepper b { min-width: 4rem; text-align: center; font-size: 1.125rem; font-variant-numeric: tabular-nums; }

.remote-body { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.qr-box { flex: none; padding: 0.875rem; border-radius: 1rem; background: #fff; }
.qr-box canvas { display: block; width: 14rem; height: 14rem; image-rendering: pixelated; }
.remote-info { flex: 1 1 16rem; min-width: 0; }
.remote-info ol { margin: 0 0 1rem; padding-left: 1.25rem; font-size: 0.9375rem; line-height: 1.55; color: var(--muted); }
.remote-info li { margin-bottom: 0.375rem; }
.remote-status { margin-bottom: 1rem; font-size: 1rem; font-weight: 700; }
.remote-status.ok { color: #22c55e; }
.remote-status.bad { color: var(--danger); }
.remote-actions { display: flex; flex-wrap: wrap; gap: 0.625rem; }

.pbar { container: pbar / inline-size; }
@container pbar (max-width: 980px) {
  .pk span { display: none; }
  .pk { min-width: 3.25rem; padding: 0 0.625rem; }
  .pk#repeatBtn span, .pk#speedBtn span, .pk#sleepBtn span { display: inline; }
}
@media (max-width: 760px) {
  .recent-box { left: 0.75rem; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); }
}
@media (max-height: 480px) {
  .pbar { padding: 0.25rem 0.625rem 0.375rem; }
  .pk { height: 2.75rem; }
  .seek { height: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
