:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #161616;
  --sub: #6f6f68;
  --faint: #a5a59c;
  --line: #e6e6e1;
  --line2: #efefe9;
  --accent: oklch(0.55 0.21 305);
  --accent-ink: oklch(0.47 0.2 305);
  --accent-soft: oklch(0.95 0.04 305);
  --ink: #161616;
  --ink-text: #fbfbfa;
  --danger: oklch(0.55 0.16 25);
  --danger-text: #ffffff;
  --gray-dot: #bdbdb4;
  --page-shell-max: 1320px;
  --home-max: 1040px;
  --form-max: 860px;
  --list-max: 1240px;
  --admin-max: 1240px;
  --content-max: 860px;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0e;
  --surface: #1a1a18;
  --text: #f4f4ef;
  --sub: #a0a099;
  --faint: #6a6a62;
  --line: #2a2a26;
  --line2: #222220;
  --accent: oklch(0.74 0.17 305);
  --accent-ink: oklch(0.82 0.15 305);
  --accent-soft: oklch(0.32 0.09 305);
  --ink: #f4f4ef;
  --ink-text: #15150f;
  --danger: oklch(0.68 0.17 25);
  --danger-text: #15150f;
  --gray-dot: #55554d;
}

* {
  box-sizing: border-box;
}

::selection {
  background: oklch(0.55 0.21 305 / 0.2);
}

html {
  min-height: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  margin: 0;
  min-height: 100vh;
}

body,
input,
textarea,
select,
button {
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

img {
  max-width: 100%;
}

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

textarea {
  resize: vertical;
}

.site-header {
  align-items: center;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 64px;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  align-items: center;
  display: inline-flex;
  flex: none;
}

.brand img {
  display: block;
  height: 30px;
  width: auto;
}

.site-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: flex-end;
  min-width: 0;
}

.site-nav a,
.site-nav .link-button {
  border-bottom: 2px solid transparent;
  color: var(--sub);
  font-size: 13.5px;
  min-height: auto;
  padding: 4px 0 3px;
}

.site-nav a.active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.site-nav .inline-form {
  align-items: center;
}

.theme-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  min-height: 30px;
  padding: 0;
  width: 30px;
}

.theme-toggle span {
  background: linear-gradient(90deg, var(--text) 50%, transparent 50%);
  border: 1px solid var(--text);
  border-radius: 999px;
  display: block;
  height: 13px;
  width: 13px;
}

.page-shell {
  margin: 0 auto;
  max-width: var(--page-shell-max);
  padding: 56px 32px 120px;
}

.auth-shell {
  max-width: none;
  padding-top: 88px;
}

.hero-page {
  margin: 0 auto;
  max-width: var(--home-max);
  padding: 40px 0 0;
}

.hero-logo {
  display: block;
  height: 74px;
  margin-bottom: 30px;
  width: auto;
}

.home h1 {
  color: var(--text);
  font-size: 52px;
  font-weight: 700;
  line-height: 1.05;
  margin: 0 0 22px;
  max-width: 680px;
}

.home > p {
  color: var(--sub);
  font-size: 17px;
  line-height: 1.7;
  margin: 0 0 40px;
  max-width: 520px;
}

.hero-actions,
.actions,
.table-actions,
.article-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-actions {
  gap: 22px;
}

.feature-grid {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 40px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 80px;
  padding-top: 36px;
}

.feature-grid h2 {
  align-items: center;
  color: var(--text);
  display: flex;
  font-size: 15px;
  font-weight: 600;
  gap: 9px;
  line-height: 1.3;
  margin: 0 0 8px;
}

.feature-grid p {
  color: var(--sub);
  font-size: 13.5px;
  line-height: 1.7;
  margin: 0;
}

.narrow-panel {
  margin: 0 auto;
  max-width: 420px;
}

.form-page,
.settings-page {
  margin: 0 auto;
  max-width: var(--form-max);
}

.list-page {
  margin: 0 auto;
  max-width: var(--list-max);
}

.admin-page {
  margin: 0 auto;
  max-width: var(--admin-max);
}

.content-page {
  margin: 0 auto;
  max-width: var(--content-max);
}

.eyebrow {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.narrow-panel .eyebrow {
  color: var(--accent-ink);
  letter-spacing: 0.16em;
  margin-bottom: 16px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.narrow-panel h1,
.section-header h1,
.admin-heading h1,
.content-header h1,
.settings-page > h1 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.08;
  margin: 0;
}

.narrow-panel h1 {
  font-size: 34px;
  margin-bottom: 36px;
}

.section-header h1,
.admin-heading h1 {
  font-size: 34px;
  margin-bottom: 8px;
}

.form-page .section-header h1 {
  font-size: 32px;
}

.content-header h1 {
  font-size: 40px;
  line-height: 1.12;
}

.section-header,
.content-header {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 36px;
}

.section-header-bordered {
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  margin-bottom: 34px;
  padding-bottom: 24px;
}

.section-header p,
.admin-heading p,
.narrow-panel > p,
.content-header p,
.muted {
  color: var(--sub);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.admin-heading {
  margin-bottom: 24px;
}

.auth-switch {
  color: var(--sub);
  font-size: 13.5px;
  margin: 22px 0 0;
  text-align: center;
}

.auth-switch a,
.text-link {
  border-bottom: 1px solid currentColor;
  color: var(--text);
  font-weight: 500;
  padding-bottom: 2px;
}

.button,
button {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: var(--ink-text);
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 500;
  justify-content: center;
  min-height: 40px;
  padding: 10px 20px;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover,
button:hover {
  opacity: 0.88;
  text-decoration: none;
}

button.secondary,
.button.secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

button.secondary:hover,
.button.secondary:hover {
  border-color: var(--text);
  opacity: 1;
}

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

.link-button {
  background: transparent;
  border: 0;
  color: var(--text);
  display: inline;
  font-size: 13px;
  min-height: auto;
  padding: 0;
}

.link-button:hover {
  color: var(--accent-ink);
  opacity: 1;
}

.link-button.danger,
.table-actions .danger {
  color: var(--danger);
}

.inline-form {
  display: inline-flex;
}

.stack-form {
  display: grid;
  gap: 0;
}

.stack-form label,
.settings-form label {
  color: var(--sub);
  display: grid;
  font-size: 13px;
  gap: 8px;
  margin-bottom: 24px;
}

.narrow-panel .stack-form label {
  margin-bottom: 20px;
}

.stack-form button[type="submit"] {
  font-size: 15px;
  min-height: 44px;
  width: 100%;
}

input,
textarea,
select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  outline: none;
  padding: 12px 14px;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--text);
}

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

textarea {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  min-height: 220px;
}

input[name="slug"],
code,
.mono,
.row-slug,
.secret-output,
.attachment-card strong,
.attachment-markdown {
  font-family: var(--font-mono);
}

.inline-input,
.search-form,
.upload-form {
  display: flex;
  gap: 10px;
}

.inline-input input,
.search-form input {
  flex: 1;
}

.inline-input button {
  padding-left: 18px;
  padding-right: 18px;
}

.choice-group {
  border: 0;
  display: grid;
  gap: 10px;
  margin: 0 0 28px;
  padding: 0;
}

.choice-group legend {
  color: var(--sub);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 0;
}

.radio-choice {
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 14px;
  margin: 0;
  padding: 15px 18px;
  position: relative;
}

.radio-choice input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.radio-control {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  flex: none;
  height: 18px;
  justify-content: center;
  margin-top: 1px;
  width: 18px;
}

.radio-control::after {
  background: transparent;
  border-radius: 999px;
  content: "";
  height: 9px;
  width: 9px;
}

.radio-choice input:checked + .radio-control {
  border-color: var(--accent);
}

.radio-choice input:checked + .radio-control::after {
  background: var(--accent);
}

.radio-choice:has(input:checked) {
  border-color: var(--accent);
}

.radio-copy {
  display: grid;
  gap: 3px;
}

.radio-title {
  align-items: center;
  color: var(--text);
  display: flex;
  font-size: 15px;
  font-weight: 500;
  gap: 8px;
}

.radio-description {
  color: var(--sub);
  font-size: 13px;
}

[data-password-field][hidden] {
  display: none;
}

.field-error,
.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

.form-error {
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line));
  border-radius: 6px;
  margin-bottom: 18px;
  padding: 11px 14px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--sub);
  font-size: 14px;
  margin: 0;
  padding: 24px;
}

.data-table {
  width: 100%;
}

.data-table-head,
.data-row {
  display: grid;
  gap: 16px;
}

.page-table .data-table-head,
.page-table .data-row {
  grid-template-columns: 1.9fr 0.7fr 1.6fr 0.7fr 1.1fr;
}

.admin-users-table .data-table-head,
.admin-users-table .data-row {
  grid-template-columns: 1fr 0.8fr 0.9fr 0.8fr 0.5fr 2.4fr;
}

.data-table-head {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  padding: 0 6px 12px;
  text-transform: uppercase;
}

.admin-users-table .data-table-head {
  border-bottom: 1px solid var(--line);
  padding-top: 18px;
}

.data-row {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--sub);
  font-size: 14px;
  min-width: 0;
  padding: 18px 6px;
}

.admin-users-table .data-row {
  border-bottom: 1px solid var(--line);
  border-top: 0;
}

.row-title {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-slug {
  background: transparent;
  color: var(--sub);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-muted {
  color: var(--faint);
  font-size: 13.5px;
}

.row-muted-strong {
  color: var(--sub);
  font-size: 13px;
}

.table-actions {
  align-items: center;
  gap: 12px;
}

.admin-users-table .table-actions {
  gap: 14px;
}

.table-actions a,
.table-actions .link-button {
  color: var(--text);
  font-size: 13px;
}

.table-actions a + a {
  color: var(--sub);
}

.visibility-mark,
.permission-note {
  align-items: center;
  color: var(--sub);
  display: inline-flex;
  font-size: 13.5px;
  gap: 7px;
}

.visibility-mark.is-muted {
  color: var(--faint);
}

.status-dot {
  border-radius: 999px;
  display: inline-block;
  flex: none;
  height: 7px;
  width: 7px;
}

.status-public {
  background: var(--accent);
}

.status-muted {
  background: var(--gray-dot);
}

.subsection {
  margin-top: 56px;
}

.subsection h2,
.gallery h2,
.setting-card h2 {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 6px;
}

.permission-note {
  margin: 0 0 18px;
}

.upload-form {
  margin-bottom: 24px;
}

.upload-form input[type="file"] {
  flex: 1;
}

.attachment-grid,
.image-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, 1fr);
}

.attachment-card,
.image-grid figure {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0;
  overflow: hidden;
}

.attachment-card img,
.image-grid img {
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  width: 100%;
}

.attachment-card figcaption,
.image-grid figcaption {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 8px 12px;
}

.attachment-card strong,
.image-grid figcaption {
  color: var(--sub);
  font-size: 11.5px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-markdown {
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 11px;
  line-height: 1.5;
  margin: 0;
  padding: 8px 12px 10px;
}

.content-header {
  margin-bottom: 40px;
}

.article-meta {
  align-items: center;
  color: var(--faint);
  display: flex;
  flex-wrap: wrap;
  font-size: 13.5px;
  gap: 14px;
  margin-top: 14px;
}

.article-meta .mono {
  font-size: 12.5px;
}

.article-actions {
  flex: none;
  padding-top: 8px;
}

.markdown-body {
  border-top: 1px solid var(--line);
  color: var(--sub);
  font-size: 15.5px;
  line-height: 1.85;
  padding-top: 40px;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.3;
  margin: 36px 0 16px;
}

.markdown-body h1 {
  font-size: 28px;
}

.markdown-body h2 {
  font-size: 23px;
}

.markdown-body h3 {
  font-size: 19px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre {
  margin: 0 0 16px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 20px;
}

.markdown-body strong {
  color: var(--text);
  font-weight: 600;
}

.markdown-body code {
  background: var(--line2);
  border-radius: 3px;
  color: var(--text);
  font-size: 13.5px;
  padding: 2px 6px;
}

.markdown-body pre {
  background: var(--line2);
  border-radius: 8px;
  overflow-x: auto;
  padding: 16px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
}

.markdown-body a {
  border-bottom: 1px solid currentColor;
  color: var(--text);
}

.markdown-body img {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin: 32px 0;
  max-width: 100%;
}

.gallery {
  margin-top: 40px;
}

.tabs,
.segmented-control {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
}

.tabs {
  margin-bottom: 28px;
}

.tabs a,
.segmented-control span {
  border-radius: 4px;
  color: var(--sub);
  display: inline-flex;
  font-size: 13.5px;
  justify-content: center;
  min-width: 64px;
  padding: 7px 16px;
}

.tabs a.active {
  background: var(--ink);
  color: var(--ink-text);
}

.search-form {
  margin-bottom: 24px;
  max-width: 480px;
}

.badge {
  background: var(--line2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-block;
  font-size: 12px;
  padding: 2px 10px;
}

.stats-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 24px;
}

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 18px;
}

.stats-grid strong {
  color: var(--text);
  font-size: 32px;
  line-height: 1;
}

.stats-grid span {
  color: var(--sub);
  font-size: 13px;
}

.settings-form {
  display: grid;
  gap: 28px;
}

.setting-card {
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 24px;
}

.setting-card p {
  color: var(--sub);
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0;
  max-width: 420px;
}

.segmented-control {
  flex: none;
}

.segmented-control label {
  cursor: pointer;
  display: inline-flex;
  margin: 0;
}

.segmented-control input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.segmented-control input:checked + span {
  background: var(--ink);
  color: var(--ink-text);
}

.settings-form > button {
  justify-self: start;
  padding-left: 26px;
  padding-right: 26px;
}

.secret-output {
  background: var(--ink);
  border-radius: 8px;
  color: var(--ink-text);
  font-size: 20px;
  margin: 24px 0;
  overflow-x: auto;
  padding: 16px;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .site-header {
    align-items: flex-start;
    height: auto;
    min-height: 64px;
    padding: 16px 20px;
  }

  .site-nav {
    gap: 14px;
  }

  .page-shell,
  .auth-shell {
    padding: 40px 20px 80px;
  }

  .home h1 {
    font-size: 40px;
  }

  .hero-logo {
    height: 60px;
  }

  .feature-grid,
  .stats-grid,
  .attachment-grid,
  .image-grid {
    grid-template-columns: 1fr;
  }

  .section-header,
  .section-header-bordered,
  .content-header,
  .setting-card,
  .inline-input,
  .search-form,
  .upload-form {
    align-items: stretch;
    flex-direction: column;
  }

  .data-table-head {
    display: none;
  }

  .page-table .data-row,
  .admin-users-table .data-row {
    align-items: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    margin-bottom: 12px;
    padding: 16px;
  }

  .data-row > span {
    min-width: 0;
  }

  .row-title {
    white-space: normal;
  }

  .content-header h1 {
    font-size: 32px;
  }

  .article-actions {
    padding-top: 0;
  }
}

@media (max-width: 560px) {
  .site-header {
    gap: 14px;
  }

  .brand img {
    height: 26px;
  }

  .site-nav a,
  .site-nav .link-button {
    font-size: 13px;
  }

  .home h1 {
    font-size: 34px;
  }

  .home > p {
    font-size: 15.5px;
  }

  .narrow-panel h1,
  .section-header h1,
  .admin-heading h1 {
    font-size: 30px;
  }

  .tabs,
  .segmented-control {
    width: 100%;
  }

  .tabs a,
  .segmented-control label,
  .segmented-control span {
    flex: 1;
  }
}
