/* Arus: Swiss/utilitarian desktop UI */

:root {
  --bg: #0b0b0c;
  --panel: #0f0f11;
  --panel-2: #141416;
  --hover: #17171a;
  --sel: #1b1b1f;
  --border: #222226;
  --border-strong: #34343a;
  --text: #f2f2f0;
  --muted: #a3a3a9;
  --faint: #7c7c84;
  --accent: #f2f2f0;
  --accent-hover: #d8d8d4;
  --accent-ink: #0b0b0c;
  --danger: #d06a62;
  --danger-solid: #9d3b34;
  --danger-on: #fafaf8;
  --focus: #9a9aa2;
  --track: #26262b;
  --field: #131315;
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
  --radius: 6px;
  --radius-sm: 4px;
  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f5f5f2;
  --panel: #fafaf8;
  --panel-2: #f0f0ed;
  --hover: #efefec;
  --sel: #e9e9e5;
  --border: #e2e2dc;
  --border-strong: #c9c9c2;
  --text: #141416;
  --muted: #5d5d64;
  --faint: #6e6e75;
  --accent: #141416;
  --accent-hover: #2b2b30;
  --accent-ink: #fafaf8;
  --danger: #a83a33;
  --danger-solid: #a83a33;
  --danger-on: #ffffff;
  --focus: #4a4a52;
  --track: #e3e3de;
  --field: #f2f2ef;
  --shadow: 0 20px 48px rgba(20, 20, 25, 0.16);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

::selection {
  background: var(--border-strong);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

svg.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

kbd {
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.01em;
  color: var(--faint);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.5;
  white-space: nowrap;
}

/* Title bar */

.titlebar {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  -webkit-app-region: drag;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: block;
}

.brand-name {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.window-controls {
  display: flex;
  -webkit-app-region: no-drag;
}

.window-btn {
  width: 46px;
  height: 37px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.window-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.window-btn.close:hover {
  background: var(--border-strong);
}

.window-btn .icon {
  width: 12px;
  height: 12px;
}

/* Layout */

.main {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  height: calc(100% - 38px);
  min-height: 0;
}

body.inspector-open .main {
  grid-template-columns: 232px minmax(0, 1fr) 340px;
}

/* Sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 10px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.new-download {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  transition: background 0.14s ease;
}

.new-download:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.new-icon {
  display: grid;
  place-items: center;
  flex: none;
}

.new-download .icon {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

.new-download .new-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-download kbd {
  margin-left: auto;
  border-color: currentColor;
  color: inherit;
  opacity: 0.5;
}

.nav-label {
  margin: 16px 8px 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.nav-label:first-of-type {
  margin-top: 16px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item .icon {
  width: 15px;
  height: 15px;
  color: var(--faint);
}

.nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item .count {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item:hover .icon {
  color: var(--muted);
}

.nav-item.is-active {
  background: var(--sel);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--text);
}

.nav-item.is-active .icon {
  color: var(--text);
}

.nav-item.is-active .count {
  color: var(--muted);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.live-speed {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.live-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.live-dot.is-live {
  background: var(--text);
  animation: live-pulse 1.8s ease-in-out infinite;
}

@keyframes live-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* Workspace */

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}

.workspace-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px 14px;
  flex: none;
}

.head-copy {
  min-width: 156px;
}

.head-copy h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.head-copy p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.head-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
}

.searchbox {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 1 auto;
  width: 240px;
  min-width: 150px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--faint);
  transition: border-color 0.14s ease;
}

.searchbox:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
}

.searchbox .icon {
  width: 14px;
  height: 14px;
}

.searchbox input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  user-select: text;
}

.searchbox input::placeholder {
  color: var(--faint);
}

.searchbox input::-webkit-search-cancel-button {
  display: none;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  flex: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.4;
}

.icon-btn.framed {
  width: 32px;
  height: 32px;
  border-color: var(--border);
  background: var(--field);
}

.icon-btn.framed:hover {
  border-color: var(--border-strong);
  background: var(--hover);
}

.icon-btn .icon {
  width: 15px;
  height: 15px;
}

.add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.add-btn:hover {
  background: var(--hover);
  border-color: var(--faint);
}

.add-btn .icon {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

/* Library stage */

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px 8px;
  flex: none;
}

.stage-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.stage-sep {
  width: 1px;
  height: 10px;
  background: var(--border-strong);
}

.stage-actions {
  display: flex;
  gap: 2px;
}

.quiet {
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  transition: background 0.12s ease, color 0.12s ease;
}

.quiet:hover {
  background: var(--hover);
  color: var(--text);
}

.quiet:disabled {
  opacity: 0.4;
}

.stage {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 20px;
  scrollbar-gutter: stable;
}

.list {
  display: flex;
  flex-direction: column;
}

/* Table header */

.list-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 112px 28px;
  align-items: center;
  gap: 12px;
  padding: 0 12px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.list-head span:nth-child(3) {
  text-align: right;
}

/* Download rows */

.row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 112px 28px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: default;
  transition: background 0.12s ease;
}

.row:hover {
  background: var(--hover);
}

.row.is-selected {
  background: var(--sel);
  box-shadow: inset 2px 0 0 var(--text);
}

.row:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.row-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--faint);
}

.row-icon .icon {
  width: 16px;
  height: 16px;
}

.row-main {
  min-width: 0;
}

.row-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.row-name {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-tag {
  flex: none;
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

.row-tag::before {
  content: "·";
  margin-right: 6px;
  color: var(--border-strong);
}

.row-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-bar {
  position: relative;
  height: 2px;
  margin-top: 8px;
  background: var(--track);
  overflow: hidden;
}

.row-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.25s ease;
}

.row[data-status="paused"] .row-fill,
.row[data-status="completed"] .row-fill {
  background: var(--faint);
}

.row[data-status="failed"] .row-fill {
  background: var(--danger);
}

.row[data-status="completed"] .row-bar,
.row[data-status="failed"] .row-bar,
.row[data-status="queued"] .row-bar {
  visibility: hidden;
}

.row[data-indeterminate="true"] .row-fill {
  width: 34% !important;
  animation: row-indeterminate 1.5s ease-in-out infinite;
}

@keyframes row-indeterminate {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(330%);
  }
}

.row-error {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-error:empty {
  display: none;
}

.row-state {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-state strong {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.row-state small {
  max-width: 108px;
  font-size: 10.5px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.row:hover .row-actions,
.row.is-selected .row-actions,
.row:focus-within .row-actions {
  opacity: 1;
}

.row-actions .icon-btn {
  width: 26px;
  height: 26px;
}

.row-actions .icon {
  width: 14px;
  height: 14px;
}

/* Empty state */

.empty {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.empty-inner {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.empty-glyph {
  margin-bottom: 12px;
  color: var(--faint);
}

.empty-glyph .icon {
  width: 26px;
  height: 26px;
  stroke-width: 1.4;
}

.empty h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.empty p {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.empty .primary {
  margin-top: 16px;
}

.empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 14px !important;
  font-size: 11px !important;
  color: var(--faint) !important;
}

/* Buttons */

.ghost,
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.ghost:hover {
  background: var(--hover);
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.primary.is-danger {
  border-color: var(--danger-solid);
  background: var(--danger-solid);
  color: var(--danger-on);
}

.primary.is-danger:hover {
  border-color: #8f342e;
  background: #8f342e;
}

.ghost:disabled,
.primary:disabled {
  opacity: 0.4;
}

.ghost .icon,
.primary .icon {
  width: 14px;
  height: 14px;
}

/* Inspector */

.inspector {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.inspector[hidden] {
  display: none;
}

.inspector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.inspector-title {
  flex: 1;
  min-width: 0;
}

.inspector-ident {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.detail-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}

.detail-icon .icon {
  width: 18px;
  height: 18px;
}

.ident-copy {
  flex: 1;
  min-width: 0;
}

.inspector-head h2 {
  margin: 0;
  max-width: 100%;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#detail-host {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-head .icon-btn {
  margin: -3px -3px 0 0;
  width: 28px;
  height: 28px;
}

.inspector-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
}

.detail-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-summary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-percent {
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.detail-percent[data-empty="true"] {
  color: var(--faint);
  font-weight: 400;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.status-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.status-chip[data-status="downloading"] {
  color: var(--text);
}

.status-chip[data-status="downloading"]::before {
  background: var(--text);
  animation: live-pulse 1.8s ease-in-out infinite;
}

.status-chip[data-status="completed"]::before {
  background: var(--text);
}

.status-chip[data-status="failed"] {
  color: var(--text);
}

.status-chip[data-status="failed"]::before {
  background: var(--danger);
}

.detail-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.detail-meter {
  position: relative;
  height: 3px;
  background: var(--track);
  overflow: hidden;
}

.detail-meter-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.3s ease;
}

.detail-meter[data-status="paused"] .detail-meter-fill,
.detail-meter[data-status="queued"] .detail-meter-fill {
  background: var(--faint);
}

.detail-meter[data-status="failed"] .detail-meter-fill {
  background: var(--danger);
}

.detail-meter[data-unknown="true"] .detail-meter-fill {
  width: 28% !important;
  animation: meter-slide 1.5s ease-in-out infinite;
}

@keyframes meter-slide {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(370%);
  }
}

.spark {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.spark-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.spark-value {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#detail-spark {
  width: 100%;
  height: 48px;
  display: block;
}

.detail-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
}

.detail-actions .primary,
.detail-actions .ghost {
  min-width: 0;
  height: 32px;
  padding: 0 6px;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-grid {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.detail-grid > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.detail-grid dt {
  flex: none;
  font-size: 11px;
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 500;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.detail-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.segment-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6px, 1fr));
  gap: 2px;
  max-height: 88px;
  overflow-y: auto;
}

.segment {
  height: 6px;
  background: var(--track);
}

.segment.is-partial {
  background: var(--faint);
}

.segment.is-done {
  background: var(--text);
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0 6px;
  border-bottom: 1px solid var(--border);
}

.copy-row .mono {
  flex: 1;
  min-width: 0;
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: text;
}

.copy-row .icon-btn {
  width: 24px;
  height: 24px;
}

.hash-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 2px 0 6px;
  border-bottom: 1px solid var(--border);
}

.hash-row .hash-value {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted);
  word-break: break-all;
  user-select: text;
}

.hash-row button {
  flex: none;
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.detail-block-inner {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 2px;
}

.detail-block-inner .mono {
  min-width: 0;
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: text;
}

.detail-block-inner .section-label {
  flex: none;
}

.detail-error {
  margin: 4px 0 0;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--danger);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.danger-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0 2px;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--faint);
  font-size: 11.5px;
  text-align: left;
  transition: color 0.12s ease;
}

.danger-link:hover {
  color: var(--danger);
}

.danger-link .icon {
  width: 13px;
  height: 13px;
}

/* Dialogs */

dialog.modal {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}

dialog.modal.small {
  width: min(400px, calc(100vw - 32px));
}

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

[data-theme="light"] dialog.modal::backdrop {
  background: rgba(20, 20, 24, 0.32);
}

.modal-card {
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 760px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: modal-in 0.16s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  flex: none;
}

.modal-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-head p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.modal-head .icon-btn {
  margin: -3px -3px 0 0;
}

.modal-head.compact {
  padding-bottom: 6px;
}

.tabs {
  display: flex;
  gap: 0;
  margin: 0 20px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.tab {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: -1px;
  transition: color 0.12s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--text);
}

.tab-panel {
  padding: 0 20px 2px;
  min-height: 0;
  overflow-y: auto;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
}

.field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.field em {
  font-style: normal;
  font-weight: 400;
  font-size: 11px;
  color: var(--faint);
}

.field input,
.field select {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text);
  font-size: 12px;
  outline: none;
  user-select: text;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.field textarea {
  width: 100%;
  min-height: 96px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  user-select: text;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.searchbox input:focus-visible {
  outline: none;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--faint);
}

.field-hint {
  font-size: 11px;
  line-height: 1.4;
  color: var(--faint);
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237c7c84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 28px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-row input {
  flex: 1;
  min-width: 0;
}

.input-row .ghost {
  height: 32px;
  padding: 0 10px;
}

.form-note {
  margin: 2px 0 14px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--faint);
}

.batch-status {
  margin-top: -6px;
  color: var(--muted);
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 14px 20px 16px;
  border-top: 1px solid var(--border);
  flex: none;
}

.hint {
  font-size: 11px;
  line-height: 1.4;
  color: var(--faint);
}

.foot-actions {
  display: flex;
  gap: 6px;
}

/* Page scanner */

.scan-status {
  margin: 2px 0 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.scan-results {
  display: flex;
  flex-direction: column;
  max-height: 248px;
  overflow-y: auto;
}

.scan-results:empty {
  display: none;
}

.scan-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.scan-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--faint);
}

.scan-icon .icon {
  width: 15px;
  height: 15px;
}

.scan-main {
  min-width: 0;
}

.scan-name {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-meta {
  display: flex;
  gap: 6px;
  margin-top: 1px;
  font-size: 10.5px;
  color: var(--faint);
  overflow: hidden;
}

.scan-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-item .ghost {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
}

/* Settings */

.settings-scroll {
  padding: 0 20px 2px;
  min-height: 0;
  overflow-y: auto;
}

.settings-section {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.settings-section:first-child {
  padding-top: 2px;
  border-top: 0;
}

.settings-section h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.section-copy {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  cursor: pointer;
}

.toggle-row > span {
  flex: 1;
  min-width: 0;
}

.toggle-row strong {
  display: block;
  font-size: 12px;
  font-weight: 500;
}

.toggle-row small {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--faint);
}

.toggle-row input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.switch {
  position: relative;
  width: 32px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: var(--track);
  flex: none;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s ease, background 0.16s ease;
}

.toggle-row input:checked + .switch {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle-row input:checked + .switch::after {
  transform: translateX(14px);
  background: var(--accent-ink);
}

.toggle-row input:focus-visible + .switch {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.toggle-row.compact {
  padding: 2px 20px 16px;
}

.theme-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.theme-option:hover {
  background: var(--hover);
}

.theme-option.is-active {
  border-color: var(--text);
  background: var(--sel);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--text);
}

.theme-option .icon {
  width: 14px;
  height: 14px;
}

.path-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field);
}

.path-box .mono {
  flex: 1;
  min-width: 0;
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-box .ghost {
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
}

.steps {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--muted);
}

.steps strong {
  color: var(--text);
  font-weight: 500;
}

/* Toasts */

.toasts {
  position: fixed;
  inset: auto 16px 16px auto;
  margin: 0;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 120;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  width: 320px;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  animation: toast-in 0.16s ease;
}

.toast.is-leaving {
  animation: toast-out 0.14s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(4px);
  }
}

.toast-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-head > .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.toast-title {
  font-size: 12px;
  font-weight: 600;
}

.toast-body {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.toast-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.toast-actions .ghost,
.toast-actions .primary {
  height: 26px;
  padding: 0 9px;
  font-size: 11px;
}

.toast-close {
  margin-left: auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--faint);
}

.toast-close:hover {
  background: var(--hover);
  color: var(--text);
}

/* Drop overlay */

.drop {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 6, 0.78);
}

.drop[hidden] {
  display: none;
}

.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 52px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
}

.drop-card .icon {
  width: 24px;
  height: 24px;
  color: var(--muted);
}

.drop-card h2 {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 600;
}

.drop-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Scrollbars */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--faint);
  background-clip: padding-box;
}

/* Responsive */

@media (max-width: 1100px) {
  body.inspector-open .main {
    grid-template-columns: 232px minmax(0, 1fr) 320px;
  }
}

@media (max-width: 1024px) {
  .main,
  body.inspector-open .main {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .inspector {
    position: fixed;
    top: 38px;
    right: 0;
    bottom: 0;
    left: 232px;
    width: auto;
    z-index: 60;
    box-shadow: -1px 0 0 var(--border), var(--shadow);
  }
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 204px minmax(0, 1fr);
  }

  .sidebar {
    padding-left: 8px;
    padding-right: 8px;
  }

  .new-download kbd {
    display: none;
  }

  .workspace-head {
    padding: 18px 18px 12px;
  }

  .head-copy h1 {
    font-size: 19px;
  }

  .searchbox {
    width: 190px;
  }

  .stage-bar {
    padding: 0 18px 8px;
  }

  .stage {
    padding-left: 6px;
    padding-right: 6px;
  }

  .inspector {
    left: 204px;
  }

  .row,
  .list-head {
    grid-template-columns: 20px minmax(0, 1fr) 96px 28px;
    gap: 10px;
  }

  .row-state small {
    max-width: 96px;
  }
}

@media (max-width: 780px) {
  .searchbox {
    width: 150px;
  }

  .searchbox kbd {
    display: none;
  }

  .add-btn span {
    display: none;
  }

  .add-btn {
    width: 32px;
    padding: 0;
  }

  .head-tools {
    gap: 6px;
  }
}

@media (max-width: 760px) {
  .sidebar {
    display: none;
  }

  .main,
  body.inspector-open .main {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-head {
    padding: 16px 14px 12px;
  }

  .stage-bar {
    padding: 0 14px 8px;
  }

  .stage {
    padding: 0 4px 18px;
  }

  .inspector {
    left: 0;
    width: 100vw;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
