/* d2o: mobile-first, no external assets (spec §20.7, §21.6). */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5b6470;
  --border: #d8dce2;
  --accent: #2557c7;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-text: #ffffff;
  --warning-bg: #fff6db;
  --warning-border: #e2b93b;
  --ok: #1a7f37;
  --focus: #f0a500;
  --radius: 10px;
  --space: 1rem;
  --touch: 44px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1b2027;
    --text: #e8ebef;
    --muted: #a0a9b5;
    --border: #2f3640;
    --accent: #7aa2ff;
    --accent-text: #0b1220;
    --danger: #ff7b72;
    --danger-text: #1b0a08;
    --warning-bg: #2d2615;
    --warning-border: #8a6d1a;
    --ok: #56d364;
  }
}

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

/* An element marked hidden stays hidden, whatever display its class gives it. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
}

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

h1 {
  font-size: 1.5rem;
  margin: 0 0 var(--space);
}

h2 {
  font-size: 1.125rem;
  margin: 0 0 0.5rem;
}

code {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.skip-link {
  position: absolute;
  left: -999px;
}

.skip-link:focus {
  left: var(--space);
  top: var(--space);
  z-index: 10;
  background: var(--surface);
  padding: 0.5rem 1rem;
}

/* ---- top bar and navigation ---------------------------------------------------------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem var(--space);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--touch);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
}

.menu > summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;
}

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

.menu > nav {
  position: absolute;
  right: var(--space);
  left: var(--space);
  z-index: 5;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}

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

.menu a {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 0.75rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.menu a[aria-current="page"] {
  background: var(--bg);
  font-weight: 600;
}

.signout {
  margin: 0.25rem 0 0;
}

.signout .button {
  width: 100%;
}

@media (min-width: 768px) {
  .menu > summary {
    display: none;
  }

  .menu > nav {
    position: static;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  .menu ul {
    display: flex;
    gap: 0.25rem;
  }

  .signout .button {
    width: auto;
  }
}

/* ---- layout ---------------------------------------------------------------------------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space);
}

.page-narrow {
  max-width: 440px;
  padding-top: 12vh;
}

.footer {
  padding: var(--space);
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.grid {
  display: grid;
  gap: var(--space);
  margin-bottom: var(--space);
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stack {
  display: grid;
  gap: var(--space);
  margin: 0 0 var(--space);
  padding: 0;
  list-style: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  margin-bottom: var(--space);
}

.grid > .card,
.stack > .card {
  margin-bottom: 0;
}

.card-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

.muted {
  color: var(--muted);
}

.stat {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

/* ---- forms and buttons ----------------------------------------------------------------- */

.form {
  display: grid;
  gap: 0.5rem;
}

.form label {
  font-weight: 600;
  margin-top: 0.5rem;
}

input[type="text"],
input[type="password"],
input:not([type]),
input[type="date"],
input[type="search"],
textarea,
select {
  width: 100%;
  min-height: var(--touch);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: max(16px, 1rem); /* prevents iOS zoom on focus */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 1.25rem;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.button-primary {
  margin-top: 0.75rem;
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.button-danger {
  color: var(--danger-text);
  background: var(--danger);
  border-color: var(--danger);
}

.button-quiet {
  background: transparent;
}

.button[aria-disabled="true"] {
  opacity: 0.6;
  cursor: progress;
}

.auth-card h1 {
  font-size: 1.375rem;
}

.disclosure {
  margin-top: var(--space);
}

.disclosure > summary {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--accent);
}

/* ---- messages, badges, lists ------------------------------------------------------------ */

.alert,
.notice {
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.alert {
  border-color: var(--danger);
  color: var(--danger);
}

.notice {
  border-color: var(--ok);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success,
.badge-ready {
  color: var(--ok);
  border-color: var(--ok);
}

.badge-failure,
.badge-denied {
  color: var(--danger);
  border-color: var(--danger);
}

.code-list {
  padding-left: 1.25rem;
}

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

.event {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.event:last-child {
  border-bottom: 0;
}

.event-action {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

.event time {
  color: var(--muted);
  font-size: 0.875rem;
}

.session {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .session {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

.session-device {
  margin: 0 0 0.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.meta {
  display: grid;
  gap: 0.25rem 1rem;
  margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.meta dt {
  color: var(--muted);
  font-size: 0.8rem;
}

.meta dd {
  margin: 0;
}

/* ---- folders ------------------------------------------------------------------------- */

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 0 var(--space);
  padding: 0;
  list-style: none;
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 0.25rem;
  color: var(--muted);
}

.breadcrumb a,
.breadcrumb span {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.toolbar form {
  margin: 0;
}

.folder-list {
  margin: 0 0 var(--space);
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.folder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--touch);
  padding: 0.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.folder:last-child {
  border-bottom: 0;
}

.folder-name {
  flex: 1 1 12rem;
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
}

a.folder-name {
  text-decoration: none;
  font-weight: 600;
}

a.folder-name::before {
  content: "";
  width: 1.1rem;
  height: 0.85rem;
  margin-right: 0.6rem;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.8;
}

.badge-warning {
  color: var(--danger);
  border-color: var(--warning-border);
}

/* ---------------------------------------------------------------- jobs (spec §21.4, §21.6) */
.heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tabs ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 0 var(--space);
  padding: 0;
  list-style: none;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--touch);
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.count {
  color: var(--muted);
  font-size: 0.85rem;
}

.job-list,
.file-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.job {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.job-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}

.job-name {
  font-weight: 600;
}

.job .muted,
.job .meta {
  margin: 0.25rem 0 0;
}

.progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin-top: 0.4rem;
}

.progress progress {
  flex: 1 1 12rem;
  height: 0.6rem;
  accent-color: var(--accent);
}

.progress-text {
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

p.progress-text {
  margin: 0.25rem 0 0;
}

.progress-text:empty {
  display: none;
}

.stale {
  color: var(--danger);
}

.live-stats {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.notice-stale {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

/* ---------------------------------------------------------------- system page (ADR-0007) */
.syscheck-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.syscheck {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.syscheck:last-child {
  border-bottom: 0;
}

.syscheck-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.syscheck-name {
  font-size: 0.85rem;
}

.syscheck-summary {
  margin: 0.25rem 0 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.card-table {
  padding: 0;
  overflow-x: auto;
}

.checks {
  width: 100%;
  border-collapse: collapse;
}

.checks th,
.checks td {
  padding: 0.7rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  /* Words break only when they must, so that no column is squeezed to a few letters. */
  overflow-wrap: break-word;
}

.checks .check-summary {
  min-width: 12rem;
}

.checks thead th {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
}

.checks tbody tr:last-child > * {
  border-bottom: 0;
}

.checks .check-name {
  font-weight: normal;
  white-space: nowrap;
}

.checks .check-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.checks details {
  margin-top: 0.25rem;
}

.checks details > summary {
  cursor: pointer;
  color: var(--muted);
  width: max-content;
}

/* Phones keep the columns: narrower cells, the time on two lines, and the table scrolls
   within its card when it still does not fit, never the page (spec §21.6). */
@media (max-width: 720px) {
  .checks th,
  .checks td {
    padding: 0.55rem 0.6rem;
  }

  .checks thead th {
    font-size: 0.7rem;
  }

  .checks .check-time {
    white-space: normal;
    min-width: 5.5rem;
  }
}

.log {
  max-height: 22rem;
  overflow: auto;
  margin: 0.5rem 0 0;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.phases {
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.phases dt {
  font-weight: 600;
}

.phases dd {
  margin: 0;
}

.state {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.wrap {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hash {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-size: 0.8rem;
  color: var(--muted);
}

.file-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: var(--touch);
}

.check input {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.15rem;
  flex: none;
}

/* Options in a form or a choice list: one per line, in normal weight. */
.disclosure .check,
.choice-list .check {
  display: flex;
  font-weight: normal;
}

.choice-list {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  max-height: 28rem;
  overflow-y: auto;
}

.choice-list li {
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------- audit log and archive (spec §21.1, §23.4) */
.filter-grid {
  display: grid;
  gap: 0.5rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}

.filter-grid label,
label.inline {
  display: grid;
  gap: 0.25rem;
  font-weight: 600;
}

label.inline {
  grid-template-columns: auto minmax(8rem, 1fr);
  align-items: center;
}

.filters .toolbar {
  margin: 0.75rem 0 0;
}

.filters .button-primary {
  margin-top: 0;
}

.audit-list {
  margin: 0 0 var(--space);
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.audit-list > li {
  padding: 0.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.audit-list > li:last-child {
  border-bottom: 0;
}

.audit-event summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  min-height: var(--touch);
  cursor: pointer;
}

.audit-event summary time {
  color: var(--muted);
  font-size: 0.875rem;
}

.audit-event .meta {
  margin: 0.25rem 0 0.5rem;
}

.audit-event .log {
  margin-bottom: 0.75rem;
}

.pager {
  justify-content: space-between;
}

.archive-paths {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

/* ------------------------------------------------- job icons: source and format (kinds.py) */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.job-with-icons {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 0.85rem;
  align-items: start;
}

.job-icons {
  display: flex;
  gap: 0.4rem;
}

.icon {
  display: block;
  flex: none;
  width: 40px;
  height: 40px;
}

.icon-label {
  fill: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 8.6px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-anchor: middle;
}

/* A long title wraps beside its status, which stays at the top right. */
.job-with-icons .job-head {
  flex-wrap: nowrap;
  align-items: flex-start;
}

.job-with-icons .job-name {
  flex: 1 1 auto;
  min-width: 0;
}

.job-with-icons .job-head .badge {
  flex: none;
}

@media (max-width: 480px) {
  .job-with-icons {
    gap: 0 0.6rem;
  }

  .job-icons {
    flex-direction: column;
  }

  .icon {
    width: 34px;
    height: 34px;
  }
}

/* ------------------------------------------------- folders: list and tree views (spec §5.4) */
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.segmented a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 1rem;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.segmented a[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-text);
}

.explorer-split {
  display: grid;
  grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.tree-pane {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 0.5rem;
}

@media (max-width: 860px) {
  .explorer-split {
    grid-template-columns: minmax(0, 1fr);
  }

  .tree-pane {
    position: static;
    max-height: 18rem;
  }
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
  font-size: 1.3rem;
}

.crumbs li + li::before {
  content: "›";
  margin: 0 0.45rem;
  color: var(--muted);
}

.crumbs a {
  color: var(--muted);
  text-decoration: none;
}

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

.crumbs [aria-current="page"] {
  font-weight: 700;
}

.folder-actions {
  align-items: center;
}

.button-static {
  gap: 0.4rem;
  cursor: default;
}

.button-icon {
  width: 18px;
  height: 18px;
  margin-right: 0.4rem;
}

.popover {
  position: relative;
}

.popover > summary {
  list-style: none;
  margin-top: 0;
}

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

.popover-body {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.4rem);
  left: 0;
  width: min(20rem, calc(100vw - 2rem));
  padding: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.28);
}

.popover-end .popover-body {
  left: auto;
  right: 0;
}

.popover-body .button {
  margin-top: 0.5rem;
}

.sync-note {
  margin: 0 0 0.6rem;
}

.files {
  width: 100%;
  border-collapse: collapse;
}

.files th,
.files td {
  padding: 0.5rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  overflow-wrap: break-word;
}

.files thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
}

.files tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.files tbody tr:last-child > * {
  border-bottom: 0;
}

.files td:nth-child(n + 2) {
  white-space: nowrap;
  color: var(--muted);
}

.file-name {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 14rem;
}

.file-name a {
  font-weight: 600;
  text-decoration: none;
}

.file-name a:hover {
  text-decoration: underline;
}

.file-icon {
  display: block;
  flex: none;
  width: 30px;
  height: 30px;
}

.source-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.source-icon {
  width: 20px;
  height: 20px;
}

.empty-row {
  padding: 2rem 1rem;
  text-align: center;
}

.tree,
.tree-group {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree-group {
  margin-left: 0.85rem;
  padding-left: 0.6rem;
  border-left: 1px dashed var(--border);
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 38px;
  padding: 0 0.3rem;
  border-radius: 8px;
}

.tree-row:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.tree-current,
.tree-row:has(.tree-radio:checked) {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

.tree-caret,
.tree-caret-space {
  flex: none;
  width: 26px;
  height: 26px;
}

.tree-caret {
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.tree-caret::before {
  content: "▸";
  font-size: 1rem;
  display: inline-block;
  transition: transform 0.15s;
}

.tree-caret[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.tree-label {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.3rem 0.15rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.tree-label .icon-folder {
  flex: none;
  width: 22px;
  height: 22px;
}

.tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-current .tree-name,
.tree-row:has(.tree-radio:checked) .tree-name {
  font-weight: 600;
}

/* The row shows the choice; the radio button stays for keyboards and screen readers. */
.tree-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.tree-row:has(.tree-radio:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.tree-row:has(.tree-radio:disabled) .tree-label {
  opacity: 0.6;
  cursor: not-allowed;
}

.tree-pending {
  opacity: 0.75;
}

.mark {
  flex: none;
  font-size: 0.72rem;
}

.mark-default {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.mark-favorite {
  color: #e8b32a;
  font-size: 1rem;
}

/* ------------------------------------------------------- new download (spec §21.1, §21.4) */
.new-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.new-grid > .card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 0;
}

.new-grid h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.85rem;
}

.source-input {
  min-height: 10rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  resize: vertical;
}

.new-source {
  transition: border-color 0.15s, background-color 0.15s;
}

.new-source.drag-over {
  border-style: dashed;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

.source-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  padding: 0.2rem 0.3rem 0.2rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.file-chip [data-file-name] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-clear {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.drop-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.flow-arrow {
  display: grid;
  place-items: center;
}

.flow-arrow svg {
  width: 46px;
  height: 46px;
  padding: 11px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tree-picker {
  flex: 1 1 auto;
  min-height: 10rem;
  max-height: 24rem;
  margin: 0;
  padding: 0.4rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
}

.tree-legend {
  margin: 0;
  font-size: 0.85rem;
}

.options {
  margin-top: 1rem;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 0.6rem 1rem;
  margin-top: 0.6rem;
}

.option {
  display: grid;
  align-content: start;
  gap: 0.35rem;
}

.option label:not(.check) {
  font-weight: 600;
}

.option-wide {
  grid-column: 1 / -1;
}

.start-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.button-start {
  width: 100%;
  min-height: 52px;
  margin-top: 0;
  font-size: 1.15rem;
}

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

  .flow-arrow svg {
    transform: rotate(90deg);
  }
}

/* Pop-up forms: Create and Cancel side by side; Up beside the folder path. */
.popover-actions {
  display: flex;
  gap: 0.5rem;
}

.popover-actions .button {
  flex: 1 1 0;
}

.crumbs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.crumbs-row .crumbs ol {
  margin: 0;
}

.button-up {
  min-height: 40px;
  padding: 0 0.9rem;
}

.button-up .button-icon {
  margin-right: 0;
}

/* Audit log as a table: number, result, action or event, time (spec §23.4). */
.audit-table .audit-seq {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.audit-table .check-status .badge + .badge {
  margin-left: 0.25rem;
}

.audit-table .event-action {
  font-size: 0.9rem;
}

.audit-table .meta {
  margin: 0.4rem 0;
}

.audit-table .audit-subject {
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-table .audit-actor {
  white-space: nowrap;
}

.audit-table .audit-subject code {
  font-size: 0.8rem;
}

/* The language switch in the footer (spec §21.1). */
.footer .languages {
  display: inline-flex;
  gap: 0.75rem;
  margin-left: 1rem;
}

.footer .languages a[aria-current] {
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

/* Pairing a phone on the Sessions page (docs/adr/0004-android-client.md). */
.pairing .qr {
  display: inline-block;
  padding: 8px;
  margin: 0.5rem 0;
  background: #fff;
  border-radius: 8px;
}

.pairing .qr svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.pairing-code {
  font-size: 1.25rem;
  letter-spacing: 0.08em;
}
