:root {
  --bg: #0f1419;
  --fg: #e7ecf1;
  --muted: #9aa7b5;
  --accent: #3d9a6a;
  --danger: #c45c5c;
  --warn: #c9a227;
  --surface: #1a222c;
  --border: #2a3542;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1c3a2c 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1a2838 0%, transparent 50%),
    var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.shell {
  max-width: 40rem;
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

.shell-narrow {
  max-width: 24rem;
}

h1 {
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}

.shell h1,
.shell .brand-heading {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.lede {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 1.75rem;
  font-size: 1.05rem;
}

.lede code,
code {
  color: var(--fg);
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.links a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  padding-bottom: 0.1rem;
}

.links a:hover {
  border-bottom-color: var(--accent);
}

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

.error {
  color: #f0b4b4;
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  padding: 0.75rem 1rem;
  border-radius: 0.35rem;
}

.warning {
  color: #f5e6a8;
  background: color-mix(in srgb, var(--warn) 22%, transparent);
  padding: 0.75rem 1rem;
  border-radius: 0.35rem;
}

.warning.banner {
  margin: 0;
  border-radius: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 45%, var(--border));
}

.ok {
  color: #b6e3c8;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  padding: 0.75rem 1rem;
  border-radius: 0.35rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}

.brand,
.brand-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand {
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  font-size: 1.05rem;
}

.brand-logo {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.35rem;
  object-fit: cover;
  flex-shrink: 0;
}

.brand-heading .brand-logo {
  width: 2.5rem;
  height: 2.5rem;
}

.nav {
  display: flex;
  gap: 1rem;
  flex: 1;
}

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

.nav a:hover {
  color: var(--fg);
}

.logout-form {
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.topbar-actions > a {
  color: var(--muted);
  text-decoration: none;
}

.topbar-actions > a:hover {
  color: var(--fg);
}

.ui-main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
  overflow-x: clip;
}

.ui-footer {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.panel-head {
  margin-bottom: 1.25rem;
}

.panel {
  display: block;
  min-width: 0;
}

.confirm-panel {
  position: relative;
}

.confirm-panel > summary {
  list-style: none;
  cursor: pointer;
}

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

.confirm-form {
  margin-top: 0.5rem;
  min-width: min(16rem, 100%);
  max-width: 100%;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.toolbar .inline-form {
  margin-left: auto;
}

.search-accordion,
.tip-panel {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface);
}

.search-accordion > summary,
.tip-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  user-select: none;
}

.search-accordion > summary::-webkit-details-marker,
.tip-panel > summary::-webkit-details-marker {
  display: none;
}

.search-accordion > summary::before,
.tip-panel > summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  margin-bottom: 0.15rem;
}

.search-accordion[open] > summary::before,
.tip-panel[open] > summary::before {
  transform: rotate(45deg);
  margin-bottom: -0.1rem;
}

.search-accordion > summary:focus-visible,
.tip-panel > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tip-panel-body {
  padding: 0 1rem 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.tip-panel-body p {
  margin: 0 0 0.65rem;
}

.tip-panel-body ul {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tip-panel-body code {
  color: var(--fg);
  font-size: 0.85em;
}

dialog.modal {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--fg);
  padding: 0;
  max-width: min(28rem, calc(100vw - 2rem));
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

dialog.modal::backdrop {
  background: rgba(8, 12, 16, 0.65);
}

.modal-body {
  padding: 1.25rem 1.35rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-body h2 {
  margin: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.modal-body .stack-form {
  margin: 0;
}

.signed-link-body input[readonly] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

dialog.modal.signed-link-wide,
#signed-link-dialog {
  max-width: min(40rem, calc(100vw - 2rem));
}

.signed-box {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.signed-box input[readonly] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 1rem;
  margin: 0 0 1.5rem;
  padding: 0;
}

.stat-grid > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.85rem 1rem;
  min-width: 0;
  overflow: hidden;
}

.stat-grid dt {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-grid dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}

.stat-grid .stat-primary {
  display: block;
}

.stat-grid .stat-secondary {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.size-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.num-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

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

.bucket-meta {
  margin: 0.35rem 0 0;
}

.stat-inline-secondary {
  color: var(--muted);
  font-size: 0.9em;
}

.stat-grid dd.path,
.stat-grid dd.stat-time {
  font-size: 0.95rem;
  font-weight: 500;
}

.stat-grid dd.path code {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: normal;
  background: transparent;
  padding: 0;
}

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

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

.crumb a {
  color: var(--accent);
  text-decoration: none;
}

.stack-form,
.inline-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  min-width: 0;
}

.ttl-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ttl-picker-fields {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ttl-picker-inputs {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  min-width: 0;
}

.ttl-picker-inputs input[type="number"] {
  flex: 1 1 6rem;
  min-width: 0;
}

.ttl-picker-inputs select {
  flex: 0 0 auto;
}

.ttl-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ttl-preset {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.attr-rows {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.attr-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 0.5rem;
  align-items: end;
}

.filter-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
}

.search-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  margin: 0;
  padding: 0 1rem 1rem;
  border: 0;
  background: transparent;
  max-width: none;
}

.search-form-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}

.search-form-key > label {
  flex: 1 1 12rem;
}

.attr-row-remove {
  margin-bottom: 0.1rem;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
}

.inline-form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  min-width: 0;
}

label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

input,
select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 0.3rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
  max-width: 100%;
  min-width: 0;
}

.btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #04140c;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 0.3rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font: inherit;
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}

.btn-icon:hover {
  color: var(--fg);
  background: color-mix(in srgb, var(--surface) 80%, var(--fg));
  border-color: var(--border);
}

.btn-icon-danger:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.btn-icon.is-copied {
  color: #052e16;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-icon svg {
  width: 1rem;
  height: 1rem;
  display: block;
  pointer-events: none;
}

.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 50;
  transform: translateX(-50%) translateY(0.5rem);
  padding: 0.55rem 0.9rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-size: 0.9rem;
  box-shadow: 0 0.4rem 1.2rem rgb(0 0 0 / 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.copy-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: fixed;
}

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

.data th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data th.num-cell,
.data td.num-cell,
.data th.size-cell,
.data td.size-cell {
  width: 5.5rem;
  text-align: right;
}

.data th.time-cell,
.data td.time-cell {
  width: 9.75rem;
}

.data th.actions-col,
.data td.actions {
  /* Up to 5 × 2rem icon buttons + gaps + cell padding (public bucket rows). */
  width: 11.5rem;
  white-space: nowrap;
  text-align: right;
  overflow: hidden;
}

.data a {
  color: var(--accent);
  text-decoration: none;
}

.data a:hover {
  text-decoration: underline;
}

.data td code {
  display: inline;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: normal;
  background: transparent;
  padding: 0;
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.actions {
  display: inline-flex;
  gap: 0.15rem;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
}

.inline {
  display: inline;
  margin: 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.75rem;
}

legend {
  padding: 0 0.35rem;
  color: var(--muted);
}

.radio-fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}

.progress {
  height: 0.65rem;
  background: color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 999px;
  overflow: hidden;
  max-width: 24rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.3s ease;
}

.demo-player {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.demo-video {
  display: block;
  width: 100%;
  max-width: 40rem;
  min-height: 12rem;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
}
