:root {
  --bg: #fdfcfc;
  --surface: #ffffff;
  --subtle: #f6f5f4;
  --fg: #211e1e;
  --muted: #636060;
  --line: #e7e4e3;
  --line-strong: #c9c5c4;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --success: #17663a;
  --success-bg: #f0f8f2;
  --warn: #87470a;
  --warn-bg: #fdf6ec;
  --focus: #1f5fd6;
  --btn-hover: #000;
  --on-danger: #fff;
  --danger-hover: #8f1c13;
  --danger-line: #f1c4bf;
  --danger-fg: #7a1a12;
  --success-line: #bfdfca;
  --success-fg: #0f4a29;
  --warn-line: #efd8b5;
  --warn-fg: #5f3306;
  --radius: 4px;
  --pad: 40px;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace;
  color-scheme: light;
}

/* Follow the operating system's color scheme, including live changes. */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151313;
    --surface: #1c1a1a;
    --subtle: #252222;
    --fg: #eeeae9;
    --muted: #a8a2a1;
    --line: #312d2d;
    --line-strong: #4f4949;
    --danger: #f97b70;
    --danger-bg: #2a1715;
    --success: #6fd39a;
    --success-bg: #132519;
    --warn: #f0b660;
    --warn-bg: #2a2011;
    --focus: #7aaeff;
    --btn-hover: #fff;
    --on-danger: #1d0b09;
    --danger-hover: #fc9c93;
    --danger-line: #6a2a24;
    --danger-fg: #fed2ce;
    --success-line: #255238;
    --success-fg: #bfeccf;
    --warn-line: #66491f;
    --warn-fg: #f8e0b8;
    color-scheme: dark;
  }
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.65 var(--mono);
}

h1,
h2,
p,
dl,
dd,
ul {
  margin: 0;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

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

main:focus,
h1:focus,
.queue-item:focus {
  outline: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 8px 12px;
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* --- Frame --------------------------------------------------------------- */

.frame {
  display: flex;
  flex-direction: column;
  max-width: 1120px;
  min-height: 100vh;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 20px var(--pad);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-bracket {
  color: var(--muted);
  font-weight: 400;
}

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

.header-nav,
.header-meta {
  margin-left: auto;
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.header-nav a:hover {
  text-decoration: underline;
}

.footer-link {
  color: var(--muted);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--fg);
  text-decoration: underline;
}

.tabs {
  display: flex;
  gap: 28px;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--line);
}

.tabs a {
  padding: 14px 0 12px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

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

.tabs a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.site-main {
  flex: 1;
  width: 100%;
  padding: 48px var(--pad) 72px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 20px var(--pad);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* --- Type ---------------------------------------------------------------- */

.eyebrow {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}

.lead {
  max-width: 68ch;
  margin-top: 14px;
  color: var(--muted);
}

.section-lead {
  max-width: 72ch;
  margin-bottom: 14px;
  color: var(--muted);
}

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

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.message {
  max-width: 72ch;
  margin-top: 16px;
  padding: 14px 16px;
  border-left: 2px solid var(--fg);
  background: var(--subtle);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Buttons ------------------------------------------------------------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 16px;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
  font: inherit;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: var(--subtle);
  border-color: var(--fg);
}

.btn-small {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

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

.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

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

.btn:disabled:hover {
  background: var(--fg);
  border-color: var(--fg);
}

.btn-secondary:disabled:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.btn-danger:disabled:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-danger-outline:disabled:hover {
  background: var(--surface);
  border-color: var(--danger);
}

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

.page-head {
  margin-bottom: 36px;
}

.page-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-head .notice {
  margin-top: 20px;
}

.back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--fg);
  text-decoration: underline;
}

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

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin-bottom: 0;
}

.section-danger h2 {
  color: var(--danger);
}

.section-danger > .btn {
  margin-top: 16px;
}

/* --- States & notices ---------------------------------------------------- */

.state {
  padding: 36px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
}

.state-title {
  font-weight: 700;
}

.state-title::before {
  content: "[ ";
  color: var(--muted);
  font-weight: 400;
}

.state-title::after {
  content: " ]";
  color: var(--muted);
  font-weight: 400;
}

.state-text {
  max-width: 64ch;
  margin: 8px auto 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.state .actions {
  justify-content: center;
  margin-top: 20px;
}

.state[aria-busy="true"] .state-title {
  color: var(--muted);
}

.state-error {
  border-style: solid;
  border-color: var(--danger-line);
  background: var(--danger-bg);
}

.state-error .state-title {
  color: var(--danger);
}

.state-warn {
  border-style: solid;
  border-color: var(--warn-line);
  background: var(--warn-bg);
}

.notice {
  margin: 16px 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--subtle);
  overflow-wrap: anywhere;
}

.notice-error {
  border-color: var(--danger-line);
  border-left-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger-fg);
}

.notice-success {
  border-color: var(--success-line);
  border-left-color: var(--success);
  background: var(--success-bg);
  color: var(--success-fg);
}

.notice-warn {
  border-color: var(--warn-line);
  border-left-color: var(--warn);
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.notice-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.plain-list {
  padding-left: 18px;
}

.file-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* --- Badges -------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  vertical-align: middle;
  white-space: nowrap;
}

.badge::before {
  content: "[";
  margin-right: 3px;
}

.badge::after {
  content: "]";
  margin-left: 3px;
}

.badge-active {
  color: var(--success);
}

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

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

/* --- Facts --------------------------------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.fact {
  padding: 12px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.fact dt {
  color: var(--muted);
  font-size: 12px;
}

.fact dd {
  overflow-wrap: anywhere;
}

.message + .facts {
  margin-top: 20px;
}

/* --- Tables -------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.table th,
.table td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  background: var(--subtle);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--subtle);
}

.table .cell-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 14ch;
}

.table .num {
  font-variant-numeric: tabular-nums;
}

.table .cell-action {
  text-align: right;
}

.row-link {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  white-space: normal;
  overflow-wrap: anywhere;
}

.row-link:hover {
  text-decoration-color: currentColor;
}

.more-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

/* --- Forms --------------------------------------------------------------- */

.form-section {
  margin: 0 0 28px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.form-section legend {
  width: 100%;
  margin-bottom: 18px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 24px;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.field > label {
  margin-bottom: 6px;
  font-weight: 500;
}

.optional {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--muted);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}

::placeholder {
  color: var(--muted);
  opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--subtle);
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

[aria-invalid="true"] {
  border-color: var(--danger) !important;
}

.input-group {
  display: flex;
}

.input-group input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group select {
  width: auto;
  margin-left: -1px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background: var(--subtle);
}

.field-error {
  margin-top: 6px;
  color: var(--danger);
  font-size: 13px;
}

.form-footer {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.form-footer .notice {
  margin-top: 0;
}

.form-status {
  color: var(--muted);
  font-size: 13px;
}

.section .form-footer {
  margin-top: 24px;
}

.section .form-status:not(:empty) {
  margin-top: 10px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  accent-color: var(--danger);
}

/* --- Link & revoke ------------------------------------------------------- */

.copy-row {
  display: flex;
  gap: 10px;
}

.link-input {
  flex: 1;
  min-width: 0;
  background: var(--subtle) !important;
}

.copy-status {
  display: block;
  min-height: 1.65em;
  margin-top: 6px;
  font-size: 13px;
}

.confirm-panel {
  max-width: 560px;
  margin-top: 16px;
  padding: 18px 20px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-bg);
}

.confirm-title {
  font-weight: 700;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.confirm-panel .notice {
  margin-bottom: 0;
}

/* --- Dropzone ------------------------------------------------------------ */

.dropzone {
  position: relative;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--fg);
  background: var(--subtle);
}

.dropzone:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.dropzone.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.dropzone-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
}

.dropzone-title {
  font-weight: 700;
}

.dropzone-title::before {
  content: "[ ";
  color: var(--muted);
  font-weight: 400;
}

.dropzone-title::after {
  content: " ]";
  color: var(--muted);
  font-weight: 400;
}

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

.link-like {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- Queue --------------------------------------------------------------- */

.queue {
  list-style: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.queue-item {
  padding: 12px 14px;
}

.queue-item + .queue-item {
  border-top: 1px solid var(--line);
}

.queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 16px;
}

.queue-file {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
  min-width: 0;
}

.queue-name {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.queue-size {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.queue-status {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.queue-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.queue-item[data-state="done"] .queue-status {
  color: var(--success);
}

.queue-item[data-state="failed"] .queue-status {
  color: var(--danger);
}

.queue-item[data-state="cancelled"] .queue-status {
  color: var(--warn);
}

.queue-detail {
  margin-top: 6px;
  color: var(--danger);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.queue-item[data-state="paused"] .queue-status {
  color: var(--warn);
}

.queue-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

progress {
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 10px;
  border: 0;
  border-radius: 0;
  background: var(--line);
  color: var(--fg);
  -webkit-appearance: none;
  appearance: none;
}

progress::-webkit-progress-bar {
  background: var(--line);
}

progress::-webkit-progress-value {
  background: var(--fg);
}

progress::-moz-progress-bar {
  background: var(--fg);
}

.queue-footer {
  margin-top: 16px;
}

/* --- Responsive ---------------------------------------------------------- */

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

@media (max-width: 640px) {
  :root {
    --pad: 20px;
  }

  .site-main {
    padding-top: 32px;
  }

  h1 {
    font-size: 24px;
  }

  .header-nav,
  .header-meta {
    margin-left: 0;
    width: 100%;
  }

  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .copy-row {
    flex-direction: column;
  }

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

  .queue-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .dropzone-label {
    padding: 36px 16px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .tabs a,
  .dropzone {
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  }
}
