/*
 * Colours: FT-inspired (paper / oxblood light, warm charcoal / coral dark).
 * Layout and components match the pre-FT structure (spacing, tabs, buttons).
 */
:root {
  color-scheme: light dark;
  /* Dark: warm charcoal “evening” edition */
  --bg: #1c1b19;
  --surface: #252320;
  --border: #3d3935;
  --text: #f8f4ef;
  --muted: #a8a099;
  --accent: #ff8c61;
  --accent-dim: #e97245;
  --danger: #ff6b6b;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  --elevate: 0 1px 0 color-mix(in srgb, var(--border) 85%, transparent);
  --surface-subtle: color-mix(in srgb, var(--surface) 88%, var(--bg));
  --surface-deep: color-mix(in srgb, var(--surface) 72%, var(--bg));
  --surface-accent: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --surface-muted: color-mix(in srgb, var(--muted) 10%, var(--surface));
  --border-accent-soft: color-mix(in srgb, var(--accent) 35%, var(--border));
  --border-muted-soft: color-mix(in srgb, var(--muted) 25%, var(--border));
  --masthead-stripe: #990f3d;
}

@media (prefers-color-scheme: light) {
  :root {
    /* Light: FT “paper” and oxblood interactive */
    --bg: #fff1e5;
    --surface: #fffdf9;
    --border: #ccc1b7;
    --text: #33302e;
    --muted: #5c5856;
    --accent: #990f3d;
    --accent-dim: #7d0c32;
    --danger: #cc0000;
    --surface-subtle: color-mix(in srgb, var(--surface) 82%, var(--bg));
    --surface-deep: color-mix(in srgb, var(--surface) 65%, var(--bg));
    --surface-accent: color-mix(in srgb, var(--accent) 8%, var(--surface));
    --surface-muted: color-mix(in srgb, var(--muted) 9%, var(--surface));
    --border-accent-soft: color-mix(in srgb, var(--accent) 22%, var(--border));
    --border-muted-soft: color-mix(in srgb, var(--muted) 20%, var(--border));
    --masthead-stripe: #990f3d;
  }
}

html.theme-light {
  color-scheme: light;
  --bg: #fff1e5;
  --surface: #fffdf9;
  --border: #ccc1b7;
  --text: #33302e;
  --muted: #5c5856;
  --accent: #990f3d;
  --accent-dim: #7d0c32;
  --danger: #cc0000;
  --surface-subtle: color-mix(in srgb, var(--surface) 82%, var(--bg));
  --surface-deep: color-mix(in srgb, var(--surface) 65%, var(--bg));
  --surface-accent: color-mix(in srgb, var(--accent) 8%, var(--surface));
  --surface-muted: color-mix(in srgb, var(--muted) 9%, var(--surface));
  --border-accent-soft: color-mix(in srgb, var(--accent) 22%, var(--border));
  --border-muted-soft: color-mix(in srgb, var(--muted) 20%, var(--border));
  --masthead-stripe: #990f3d;
}

html.theme-dark {
  color-scheme: dark;
  --bg: #1c1b19;
  --surface: #252320;
  --border: #3d3935;
  --text: #f8f4ef;
  --muted: #a8a099;
  --accent: #ff8c61;
  --accent-dim: #e97245;
  --danger: #ff6b6b;
  --surface-subtle: color-mix(in srgb, var(--surface) 88%, var(--bg));
  --surface-deep: color-mix(in srgb, var(--surface) 72%, var(--bg));
  --surface-accent: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --surface-muted: color-mix(in srgb, var(--muted) 10%, var(--surface));
  --border-accent-soft: color-mix(in srgb, var(--accent) 35%, var(--border));
  --border-muted-soft: color-mix(in srgb, var(--muted) 25%, var(--border));
  --masthead-stripe: #990f3d;
}

* {
  box-sizing: border-box;
}

html.modal-open,
body.modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  padding-bottom: 2.85rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.top {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-top: 3px solid var(--masthead-stripe);
  box-shadow: 0 2px 12px color-mix(in srgb, var(--bg) 35%, transparent);
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.muted {
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.small {
  font-size: 0.875rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.35rem 1.5rem 2.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

#view-report {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.landing-heading {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.landing-lead {
  margin: 0;
}

.report-cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  margin-top: 1.1rem;
}

.report-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1.05rem 1.2rem 1.05rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 3px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  background: linear-gradient(145deg, var(--surface-subtle) 0%, var(--surface-accent) 120%);
  box-shadow: var(--elevate);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, background 0.12s ease, border-left-color 0.12s ease, filter 0.12s ease;
}

.report-card:hover {
  border-color: var(--border-accent-soft);
  border-left-color: color-mix(in srgb, var(--accent) 72%, var(--border));
  filter: brightness(1.04);
}

.report-card-title {
  font-weight: 650;
  font-size: 1.06rem;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.report-card-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

.report-meta {
  margin-bottom: 1.1rem;
  padding: 0.75rem 0.95rem;
  border-radius: 8px;
  border: 1px solid var(--border-accent-soft);
  background: linear-gradient(180deg, var(--surface-accent) 0%, var(--surface-subtle) 100%);
  line-height: 1.5;
  color: var(--text);
}

.report-meta-line--emphasis {
  font-size: 0.9375rem;
  color: var(--text);
  margin: 0;
}

.report-meta-criteria {
  margin: 0.65rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

.report-meta--compact {
  font-size: 0.9375rem;
}

.epic-section {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--surface) 70%, transparent);
}

.epic-section:last-of-type {
  margin-bottom: 0;
}

.epic-section-title {
  margin: 0 0 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.epic-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.epic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  font-size: 0.92rem;
  line-height: 1.45;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.epic-row.epic-row--leaving {
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
}

.epic-row:last-child {
  border-bottom: none;
}

.epic-row-emoji {
  flex-shrink: 0;
}

.epic-row-key {
  flex-shrink: 0;
}

.epic-row-summary {
  flex: 1 1 10rem;
  min-width: 6rem;
}

.epic-row-dash {
  color: var(--muted);
  flex-shrink: 0;
}

.epic-row-aux {
  flex-shrink: 0;
  white-space: nowrap;
}

.epic-row-aux-sep {
  color: var(--muted);
}

.epic-row-pct {
  white-space: nowrap;
}

.epic-row-count {
  flex-basis: 100%;
  margin-left: 1.75rem;
}

@media (min-width: 640px) {
  .epic-row-count {
    flex-basis: auto;
    margin-left: 0;
  }
}

.epic-row-actions {
  flex-shrink: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
}

.epic-mute-btn {
  padding: 0.28rem 0.55rem;
  font-size: 0.78rem;
}

.mute-tooltip {
  position: fixed;
  z-index: 35;
  left: -9999px;
  top: 0;
  max-width: min(17.5rem, calc(100vw - 1.5rem));
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  /* Inverted chip: dark panel, light type — reads clearly on the cream page */
  background: var(--text);
  color: var(--bg);
  border: 1px solid color-mix(in srgb, var(--bg) 22%, transparent);
  font-size: 0.8125rem;
  line-height: 1.45;
  font-weight: 500;
  box-shadow: 0 12px 36px color-mix(in srgb, var(--text) 28%, transparent);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(2px);
  transition: opacity 0.1s ease, transform 0.1s ease, visibility 0.1s;
}

@media (prefers-color-scheme: dark) {
  .mute-tooltip {
    background: color-mix(in srgb, var(--bg) 58%, black);
    color: var(--text);
    border: 1px solid color-mix(in srgb, var(--muted) 40%, var(--border));
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  }
}

.mute-tooltip.mute-tooltip--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.muted-epics-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.muted-epic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border-muted-soft);
  background: var(--surface-deep);
}

.muted-epic-row .muted-epic-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  min-width: 0;
  flex: 1 1 12rem;
}

.muted-epic-row .muted-epic-dash {
  color: var(--muted);
  user-select: none;
}

.muted-epic-row .muted-epic-summary {
  min-width: 0;
  flex: 1 1 8rem;
  line-height: 1.35;
}

.muted-epic-row .muted-epic-unmute {
  flex-shrink: 0;
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
}

.muted-epics-empty {
  margin: 0;
}

.stale-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--surface) 65%, transparent);
}

.stale-days-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.stale-days-slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.stale-days-slider-row input[type="range"] {
  flex: 1;
  min-width: 6.5rem;
  max-width: 14rem;
  height: 1.25rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.stale-days-value {
  flex-shrink: 0;
  min-width: 1.5rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  background: var(--surface-deep);
  color: var(--text);
}

.stale-toolbar-hint {
  align-self: center;
}

.stale-sections {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.stale-status-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-subtle);
  box-shadow: var(--elevate);
}

.stale-status-head {
  margin: 0;
  padding: 0.55rem 0.85rem;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, var(--surface-deep) 0%, var(--surface-subtle) 100%);
  border-bottom: 1px solid var(--border);
}

.stale-card {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  font-size: 0.875rem;
  line-height: 1.35;
  background: var(--surface);
}

.stale-status-group .stale-card:nth-child(even) {
  background: color-mix(in srgb, var(--surface-subtle) 65%, var(--surface));
}

.stale-card:last-child {
  border-bottom: none;
}

.stale-card-key {
  flex: 0 0 auto;
  margin: 0;
}

.stale-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.45rem;
  margin-bottom: 0.1rem;
}

.stale-card-title-link {
  display: flex;
  flex: 1 1 16rem;
  min-width: 12rem;
  align-items: baseline;
  gap: 0.2rem 0.45rem;
  color: inherit;
  text-decoration: none;
}

.stale-card-title-link:hover .stale-card-summary {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.stale-card-dash {
  color: var(--muted);
  user-select: none;
}

.stale-card-assignee {
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text);
  font-weight: 700;
}

.stale-card-summary {
  min-width: 8rem;
  flex: 1 1 16rem;
  margin: 0;
  font-weight: 500;
  color: color-mix(in srgb, var(--text) 94%, var(--muted));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.24;
}

.stale-card-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.32;
}

.stale-card-stale {
  margin: 0 0 0 auto;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
}

.banner {
  padding: 0.8rem 1.05rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-muted-soft);
  background: linear-gradient(180deg, var(--surface-muted) 0%, var(--surface-subtle) 100%);
  line-height: 1.5;
  box-shadow: var(--elevate);
}

.banner.error {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
}

.banner.warning {
  border-color: color-mix(in srgb, var(--danger) 58%, var(--border));
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--danger) 14%, var(--surface)) 0%,
    color-mix(in srgb, var(--danger) 7%, var(--surface-subtle)) 100%
  );
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 22%, transparent), var(--elevate);
  font-weight: 560;
}

.hidden {
  display: none !important;
}

.panel {
  background: linear-gradient(165deg, var(--surface) 0%, var(--surface-subtle) 160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.3rem;
  box-shadow: var(--elevate);
}


.panel-report {
  position: relative;
}

.panel-report--loading .report-tabs .tab {
  pointer-events: none;
  opacity: 0.72;
}

.panel-report--loading .stale-days-label input {
  opacity: 0.72;
  pointer-events: none;
}

.report-loading-host {
  position: relative;
}

.panel-report--loading .report-loading-host {
  min-height: 14rem;
}

.report-snapshot-root {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.report-snapshot-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.report-snapshot-top .report-main-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

/* Report title duplicates selected tab label; keep it for semantics but hide visually. */
.report-main-title {
  display: none;
}

.report-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background: color-mix(in srgb, var(--surface-subtle) 88%, transparent);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-radius: 10px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.report-loading.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.report-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  max-width: 22rem;
  text-align: center;
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border-accent-soft);
  background: linear-gradient(180deg, var(--surface-accent) 0%, var(--surface) 100%);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--bg) 55%, transparent), var(--elevate);
}

.report-loading-spinner {
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: report-loading-spin 0.72s linear infinite;
}

.report-loading-message {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
}

@keyframes report-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .report-loading {
    transition-duration: 0.05s;
  }

  .report-loading-spinner {
    animation-duration: 1.35s;
  }
}

.landing-panel {
  background: linear-gradient(165deg, var(--surface) 0%, var(--surface-accent) 200%);
  border-color: var(--border-accent-soft);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.panel-head--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.panel-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
  justify-content: flex-end;
}

.report-tabs {
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
  margin: -0.15rem 0 0.85rem;
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.report-tabs .tab {
  appearance: none;
  font: inherit;
  cursor: pointer;
  padding: 0.55rem 1rem;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.report-tabs .tab:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.report-tabs .tab.active {
  color: var(--text);
  font-weight: 650;
  border-color: var(--border);
  border-bottom: 1px solid transparent;
  background: linear-gradient(180deg, var(--surface-accent) 0%, var(--surface-subtle) 100%);
  box-shadow: 0 -1px 0 color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font: inherit;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-dim);
}

.btn.secondary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn.danger {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  color: var(--danger);
}

.issue-key-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.issue-key-link:hover {
  text-decoration: underline;
}

.issue-key-link code {
  color: inherit;
  font-size: 0.92em;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
}

.modal.modal-wide {
  width: min(860px, calc(100vw - 1rem));
}

.settings-dialog-header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.settings-dialog-lead {
  margin: 0.35rem 0 0;
  line-height: 1.45;
  max-width: 40rem;
}

.settings-section {
  margin-bottom: 0;
  padding: 0.72rem 0.88rem;
  border: 1px solid var(--border-accent-soft);
  border-radius: 10px;
  background: linear-gradient(165deg, var(--surface-accent) 0%, var(--surface-subtle) 100%);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--surface) 55%, transparent);
}

.settings-section--optional {
  border-color: var(--border-muted-soft);
  background: linear-gradient(165deg, var(--surface-muted) 0%, var(--surface-subtle) 100%);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--surface) 50%, transparent);
}

.settings-details {
  width: 100%;
}

.settings-details > summary {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  cursor: pointer;
  list-style: none;
}

.settings-details > summary::-webkit-details-marker {
  display: none;
}

.settings-details > summary::before {
  content: "";
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  margin-top: 0.42rem;
  border-right: 2px solid color-mix(in srgb, var(--muted) 85%, var(--text));
  border-bottom: 2px solid color-mix(in srgb, var(--muted) 85%, var(--text));
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.settings-details[open] > summary::before {
  margin-top: 0.52rem;
  transform: rotate(45deg);
}

.settings-details > summary:focus {
  outline: none;
}

.settings-details > summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--border) 72%, var(--text));
  border-radius: 6px;
}

.settings-details-summary-head {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.settings-details:not([open]) > summary .settings-details-summary-head {
  padding-bottom: 0;
  border-bottom: none;
}

.settings-details[open] > summary .settings-details-summary-head {
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

.settings-details-body {
  padding-top: 0.05rem;
}

.settings-section-head {
  margin-bottom: 0.55rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

.settings-section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
}

.settings-section-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
}

.settings-optional-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--border) 80%, var(--muted));
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
}

.settings-section-lead {
  margin: 0.35rem 0 0;
  line-height: 1.4;
  max-width: 42rem;
}

.settings-hint {
  margin: 0.45rem 0 0;
  line-height: 1.45;
  max-width: 42rem;
}

.settings-hint a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.settings-hint a:hover {
  text-decoration: underline;
}

.settings-section-body--grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem 0.9rem;
  align-items: start;
}

@media (min-width: 540px) {
  .settings-section-body--grid {
    grid-template-columns: 1fr 1fr;
  }

  .field--full {
    grid-column: 1 / -1;
  }

  .field--narrow {
    grid-column: 1;
    max-width: 14rem;
  }
}

.settings-section-body--grid .field {
  margin-top: 0;
}

.modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  margin: auto;
  width: min(520px, calc(100vw - 1.25rem));
  max-height: calc(100dvh - 0.6rem);
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 0.95rem;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-subtle) 100%);
  color: var(--text);
  box-shadow: 0 12px 48px color-mix(in srgb, var(--bg) 65%, transparent);
}

.settings-dialog-header h2,
.modal h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

#settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-height: 920px) {
  .modal {
    max-height: calc(100dvh - 0.35rem);
    padding: 0.7rem 0.85rem;
  }

  #settings-form {
    gap: 0.85rem;
  }

  .settings-section {
    padding: 0.62rem 0.78rem;
  }

  .settings-dialog-header {
    margin-bottom: 0.6rem;
    padding-bottom: 0.55rem;
  }

  .settings-section-head {
    margin-bottom: 0.45rem;
    padding-bottom: 0.4rem;
  }

  .modal-actions {
    margin-top: 0.2rem;
    padding-top: 0.65rem;
  }
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.45rem;
}

.field span {
  font-size: 0.875rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.55rem 0.65rem;
  font: inherit;
  background: var(--surface-deep);
  color: var(--text);
  box-shadow: inset 0 1px 2px color-mix(in srgb, var(--bg) 30%, transparent);
}

.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
}

.field--checkbox input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.secret-field-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.secret-field-wrap .secret-input {
  flex: 1 1 auto;
  min-width: 0;
}

.secret-input.secret-input--masked {
  -webkit-text-security: disc;
}

.secret-toggle {
  flex-shrink: 0;
  min-width: 4.25rem;
  padding: 0.45rem 0.55rem;
  font-size: 0.82rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
  margin-top: 0.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

#btn-clear-settings {
  margin-right: auto;
}

/* —— Developer console (API log) —— */
.dev-console {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  max-height: 45vh;
  border-top: 1px solid var(--border);
  background: var(--surface-deep);
  box-shadow: 0 -4px 24px color-mix(in srgb, var(--bg) 45%, transparent);
}

.dev-console--collapsed {
  max-height: fit-content;
}

.dev-console--collapsed .dev-console-body {
  display: none;
}

.dev-console-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, var(--surface-deep));
}

.dev-console-toggle {
  appearance: none;
  flex: 1;
  text-align: left;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  padding: 0.4rem 0.35rem;
  border: none;
  border-radius: 6px;
  background: transparent;
}

.dev-console-toggle:hover {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.dev-console-toggle::before {
  content: "+ ";
  display: inline-block;
  width: 1.15em;
  color: var(--muted);
}

.dev-console:not(.dev-console--collapsed) .dev-console-toggle::before {
  content: "- ";
}

.dev-console-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.dev-console-copy,
.dev-console-clear {
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

.dev-console-copy-status {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
  max-width: 11rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(1px);
  transition: opacity 0.2s ease, color 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.dev-console-copy-status.dev-console-copy-status--visible {
  opacity: 1;
  transform: translateY(0);
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
}

.dev-console-copy-status.dev-console-copy-status--error {
  color: var(--danger);
}

.dev-console-copy.dev-console-copy--done {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.dev-console-body {
  flex: 1;
  min-height: 8rem;
  max-height: 38vh;
  overflow: auto;
  margin: 0;
  padding: 0.5rem 0.65rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text);
}

.dev-console-entry {
  margin: 0 0 0.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border-left: 3px solid var(--border-muted-soft);
  white-space: pre-wrap;
  word-break: break-word;
  background: color-mix(in srgb, var(--surface) 40%, transparent);
}

.dev-console-entry--request {
  border-left-color: var(--muted);
}

.dev-console-entry--response {
  border-left-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.dev-console-entry--error {
  border-left-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface-deep));
}
