:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.96 0 0);
  --ink: oklch(0.19 0.01 250);
  --muted: oklch(0.43 0.02 250);
  --line: oklch(0.73 0.03 240);
  --accent: oklch(0.44 0.12 235);
  --accent-soft: oklch(0.9 0.05 235);
}

* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page {
  width: min(760px, calc(100% - 24px));
  margin: 28px auto 16px;
  text-align: center;
}

.page--wide {
  width: min(1180px, calc(100% - 32px));
}

.page--admin,
.page--account {
  text-align: left;
}

.page--admin .site-head,
.page--account .site-head,
.page--admin .site-nav,
.page--account .site-nav {
  text-align: center;
}

.site-head {
  margin: 0 0 20px;
}

.brand {
  display: inline-block;
  color: var(--ink);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.brand img {
  max-width: 280px;
  max-height: 120px;
}

.site-head p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.site-nav,
.site-foot {
  margin: 16px 0;
  font-size: 14px;
}

.foot-links,
.admin-nav,
.action-list,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  justify-content: center;
}

.foot-links:empty {
  display: none;
}

.admin-nav {
  justify-content: flex-start;
  margin: 12px 0 20px;
}

.result-actions {
  justify-content: center;
}

.page--admin .result-actions,
.page--account .result-actions {
  justify-content: flex-start;
}

.inline {
  display: inline;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

main {
  margin-top: 22px;
}

.upload-box,
.plain-section,
.notice {
  margin: 18px auto;
}

.drop-zone {
  display: block;
  width: min(100%, 620px);
  margin: 20px auto 8px;
  padding: 30px 18px;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.drop-zone span {
  display: block;
  font-size: 22px;
}

.drop-zone.is-dragging {
  outline: 2px dotted var(--ink);
  outline-offset: 4px;
}

.drop-zone:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

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

button {
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--ink);
  padding: 5px 12px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-soft);
}

input,
textarea,
select {
  width: min(100%, 620px);
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 7px;
}

input[type="checkbox"],
input[type="radio"] {
  inline-size: auto;
  width: auto;
  margin: 0 0.4rem 0 0;
  padding: 0;
  vertical-align: middle;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.copy-field {
  text-align: center;
}

.notice {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px;
}

.notice p {
  margin: 0 0 8px;
}

.notice p:last-child {
  margin-bottom: 0;
}

.notice.error {
  border-color: oklch(0.5 0.17 30);
  color: oklch(0.42 0.16 30);
}

.field-note,
.muted {
  color: var(--muted);
  font-size: 14px;
}

.field-note.error {
  color: oklch(0.42 0.16 30);
}

.selected-file {
  margin: 4px 0 14px;
  overflow-wrap: anywhere;
}

.selected-file:not(.is-empty) {
  color: var(--ink);
}

button:disabled {
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

button:disabled:hover {
  background: var(--surface);
}

.htmx-request button,
button.is-loading {
  cursor: wait;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

.settings-section {
  border-block-start: 1px solid var(--line);
  padding: 10px 0;
  text-align: left;
}

.settings-section summary {
  color: var(--ink);
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  border-block-start: 1px solid var(--line);
  background: var(--bg);
  padding: 10px 0;
}

.secret-field,
.accent-field {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.accent-preview {
  display: inline-block;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  vertical-align: middle;
}

.scope-grid {
  width: min(100%, 620px);
  margin: 12px 0;
  border: 1px solid var(--line);
  padding: 8px 10px;
}

.scope-grid label {
  display: inline-block;
  margin: 3px 12px 3px 0;
}

.bulk-actions,
.moderation-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  margin: 16px 0;
  padding: 10px;
}

.moderation-panel h3 {
  margin-top: 0;
}

.homepage-blocks {
  margin: 24px 0;
  text-align: left;
}

.homepage-block {
  border-block-start: 1px solid var(--line);
  padding: 14px 0;
}

.homepage-block h3,
.homepage-block p {
  margin: 0 0 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  margin: 14px 0;
  table-layout: auto;
}

th,
td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  background: var(--surface);
}

.meta-table th {
  width: 30%;
}

.status-badge {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1px 6px;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
}

.status-badge--active,
.status-badge--public,
.status-badge--verified,
.status-badge--open {
  border-color: var(--accent);
}

.status-badge--danger,
.status-badge--deleted,
.status-badge--disabled,
.status-badge--takedown,
.status-badge--quarantined {
  border-color: oklch(0.5 0.17 30);
  color: oklch(0.42 0.16 30);
}

.status-badge--muted,
.status-badge--revoked,
.status-badge--dismissed,
.status-badge--unlisted {
  color: var(--muted);
}

pre {
  overflow: auto;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px;
}

.paste-rendered {
  text-align: left;
}

.paste-body {
  white-space: pre-wrap;
}

.file-preview-media {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
}

.upload-progress {
  width: min(100%, 620px);
}

.upload-progress[hidden] {
  display: none;
}

.site-foot {
  margin-top: 64px;
  color: var(--muted);
}

body.theme-dark {
  color-scheme: dark;
  --bg: oklch(0.15 0.01 250);
  --surface: oklch(0.22 0.01 250);
  --ink: oklch(0.93 0.01 250);
  --muted: oklch(0.75 0.02 250);
  --line: oklch(0.44 0.03 250);
  --accent-soft: oklch(0.26 0.05 235);
}

body.theme-dark input,
body.theme-dark textarea,
body.theme-dark select {
  background: oklch(0.12 0.01 250);
}

@media (prefers-color-scheme: dark) {
  body.theme-auto {
    color-scheme: dark;
    --bg: oklch(0.15 0.01 250);
    --surface: oklch(0.22 0.01 250);
    --ink: oklch(0.93 0.01 250);
    --muted: oklch(0.75 0.02 250);
    --line: oklch(0.44 0.03 250);
    --accent-soft: oklch(0.26 0.05 235);
  }

  body.theme-auto input,
  body.theme-auto textarea,
  body.theme-auto select {
    background: oklch(0.12 0.01 250);
  }

  .settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 24px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
  }

  .settings-tabs .tab-button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    padding: 6px 16px;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease;
  }

  .settings-tabs .tab-button:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
  }

  .settings-tabs .tab-button.is-active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }

  body.theme-dark .settings-tabs .tab-button.is-active {
    color: var(--bg);
  }

  @media (max-width: 520px) {
    .page {
      width: min(100% - 16px, 760px);
      margin-top: 18px;
    }

    .page--wide {
      width: min(100% - 16px, 1180px);
    }

    .brand {
      font-size: 42px;
    }

    .drop-zone span {
      font-size: 18px;
    }

    .site-nav a,
    .site-nav form {
      display: inline-block;
      margin: 3px 4px;
    }

    table:not(.table-card) {
      display: block;
      overflow-x: auto;
      font-size: 14px;
      white-space: nowrap;
    }

    td {
      white-space: normal;
    }

    .table-card,
    .table-card thead,
    .table-card tbody,
    .table-card tr,
    .table-card th,
    .table-card td {
      display: block;
      width: 100%;
    }

    .table-card thead {
      position: absolute;
      inline-size: 1px;
      block-size: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }

    .table-card tr {
      border: 1px solid var(--line);
      margin: 10px 0;
      padding: 6px 0;
    }

    .table-card td,
    .table-card th {
      border: 0;
      padding: 4px 8px;
    }

    .table-card td[data-label]::before {
      content: attr(data-label) ": ";
      display: inline;
      color: var(--muted);
      font-weight: 700;
    }

    .admin-nav,
    .settings-tabs,
    .result-actions,
    .action-list {
      align-items: stretch;
      flex-direction: column;
    }

    .admin-nav a,
    .result-actions a,
    .action-list a,
    .action-list button,
    .settings-tabs button {
      width: 100%;
    }
  }
}