/* ── Settings → Top bar: look, side rails, notifications, each button ─────────
   The controls drawn by js/topbar-look-settings/topbar-look-settings.js and js/topbar/topbar-button-options.js.
   Same pieces as the rest of Settings (rows, segmented, toggles); what is new is
   the row of ready-made looks, each drawn as a small bar in that look. */

/* Rows built by script, inset like the other card bodies. */
.settings-group > .tbl-custom-rows,
.tbl-custom > .tbl-custom-rows {
  display: grid;
  gap: 12px;
  padding: 12px 16px 0;
}
.settings-group > .tbl-custom-rows:empty { display: none; }
.tbl-custom-rows > .settings-toggle-row { margin: 0 -7px; }
.settings-group > .settings-toggle-row + .tbl-custom-rows { padding-top: 4px; }
.tbl-seg[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tbl-seg[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* On a wide panel the name sits on the left and the control on the right, so a
   two-word choice is not stretched across the whole card. */
@media (min-width: 900px) {
  .tbl-custom-rows > .settings-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    align-items: center;
    column-gap: 20px;
  }
  .tbl-custom-rows > .settings-row > .settings-label-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  /* A range keeps its value next to the name. */
  .tbl-custom-rows > label.settings-row > .settings-label-line {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.tbl-note { color: var(--color-warn); line-height: 1.35; }
.tbl-note[hidden] { display: none; }
.tbl-custom-rows .settings-label-line { flex-wrap: wrap; }

/* ── Ready-made looks ───────────────────────────────────────────────────── */
.settings-group > .tbl-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
  padding: 12px 16px 0;
}
.tbl-preset {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.075);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  color: var(--muted-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.tbl-preset:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tbl-preset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tbl-preset.active {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--text);
}
.tbl-preset-name { font-size: 12px; font-weight: 900; }

/* The drawing: two buttons, the island, a button, on a strip of "dashboard". */
.tbl-prev {
  --p-bg: var(--floating-ui-bg);
  --p-border: 1px solid var(--floating-ui-border);
  --p-r: 5px;
  --p-gap: 4px;
  --p-size: 14px;
  display: flex;
  align-items: center;
  gap: var(--p-gap);
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  background: rgba(var(--accent-rgb), 0.1);
  overflow: hidden;
}
.tbl-prev > i {
  flex: 0 0 auto;
  width: var(--p-size);
  height: var(--p-size);
  border: var(--p-border);
  border-radius: var(--p-r);
  background: var(--p-bg);
}
.tbl-prev > .tbl-prev-island {
  flex: 1 1 auto;
  max-width: 52px;
  margin: 0 auto;
  border-radius: 999px;
}
.tbl-prev > .tbl-prev-btn:first-child { background: rgba(var(--accent-rgb), 0.85); border-color: transparent; }
[data-tb-preset="glass"] .tbl-prev { --p-bg: rgba(var(--panel-rgb), 0.45); --p-border: 1px solid rgba(255,255,255,0.2); }
[data-tb-preset="solid"] .tbl-prev { --p-bg: rgb(var(--panel-rgb)); --p-border: 1px solid transparent; }
[data-tb-preset="floating"] .tbl-prev { --p-bg: rgba(var(--panel-rgb), 0.6); --p-border: 1px solid transparent; --p-r: 999px; --p-gap: 7px; }
[data-tb-preset="line"] .tbl-prev { --p-bg: transparent; --p-border: 1px solid transparent; }
[data-tb-preset="line"] .tbl-prev > .tbl-prev-btn:not(:first-child)::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  margin: 3px auto;
  border-radius: 50%;
  background: var(--muted-text);
}
[data-tb-preset="line"] .tbl-prev > .tbl-prev-island { border: 1px dotted var(--floating-ui-border); }
[data-tb-preset="compact"] .tbl-prev { --p-size: 10px; --p-gap: 3px; }
[data-tb-preset="compact"] .tbl-prev > .tbl-prev-island { max-width: 36px; }

/* ── Customize (fine controls, folded) ──────────────────────────────────── */
.settings-group > .tbl-custom { margin: 12px 16px 0; }
.tbl-custom > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 850;
  cursor: pointer;
  list-style: none;
}
.tbl-custom > summary::-webkit-details-marker { display: none; }
.tbl-custom > summary::before {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}
.tbl-custom[open] > summary::before { transform: rotate(45deg); }
.tbl-custom > summary:hover { color: rgb(var(--accent-rgb)); }
.tbl-custom > summary .settings-hint[hidden] { display: none; }
.tbl-custom > .tbl-custom-rows { padding: 4px 0 0; }

/* ── Colour swatch + "back to the theme's" ──────────────────────────────── */
.tbl-color { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tbl-swatch {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 9px;
  background: var(--tbl-swatch, transparent);
  cursor: pointer;
}
.tbl-swatch.is-theme {
  /* The usual "no colour of its own" mark: one diagonal stroke. */
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), var(--muted-text) 50%, transparent calc(50% + 1px)),
    var(--floating-ui-bg);
  border: 1px dashed var(--floating-ui-border);
}
.tbl-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tbl-color > .settings-btn[hidden],
.tbl-color > .tbl-color-state[hidden] { display: none; }
.tbl-seg .settings-segment-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── One button's own options (under its chevron in "Bar buttons") ──────── */
/* Loaded before SettingsModal.css, so the selector carries the row to win over
   .island-edit-sub's full-width basis plus its 36px indent. */
.island-edit-row > .tbo-panel { display: grid; gap: 12px; padding-bottom: 6px; flex: 0 0 calc(100% - 36px); min-width: 0; }
.tbo-row { display: grid; gap: 6px; min-width: 0; }
/* Same measure as the look rows: a label field or a three-way choice does not
   need the whole card. */
.tbo-row > .settings-label-line,
.tbo-row > .settings-segmented,
.tbo-row > .settings-text-input,
.tbo-icon-grid { max-width: 420px; }
.tbo-row .settings-label-line { flex-wrap: wrap; }
.tbo-icon { display: grid; gap: 8px; }
.tbo-icon-head { display: flex; flex-wrap: wrap; gap: 8px; }
.tbo-icon-head > .settings-btn[hidden] { display: none; }
.tbo-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid rgba(255,255,255,0.075);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
}
.tbo-icon-grid[hidden] { display: none; }
.tbo-icon-cell {
  display: grid;
  place-items: center;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.tbo-icon-cell:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.tbo-icon-cell[aria-pressed="true"] {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--text);
}
.tbo-icon-cell svg { width: 20px; height: 20px; fill: currentColor; }
/* A group name spans the whole grid row. */
.tbo-icon-cat {
  grid-column: 1 / -1;
  padding: 6px 4px 2px;
  color: var(--muted-text);
  font-size: 11px;
  font-weight: 800;
}
.tbo-icon-cat:first-child { padding-top: 2px; }
.tbo-reset { justify-self: start; }

/* Touch targets on a phone-width panel. */
@media (max-width: 560px) {
  .settings-group > .tbl-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tbl-custom-rows .settings-segment-btn,
  .tbo-panel .settings-segment-btn { height: 44px; }
  .tbl-custom > summary,
  .tbl-color > .settings-btn,
  .tbo-icon-head > .settings-btn,
  .tbo-reset,
  .tbl-toast-test,
  .tbo-row > .settings-text-input { min-height: 44px; }
  .tbl-swatch { width: 44px; height: 44px; }
  .tbo-icon-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .tbo-icon-cell { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .tbl-preset,
  .tbl-custom > summary::before { transition: none; }
}
