:root {
  --bg: #0a0a0d;
  --glow: rgba(225, 48, 108, 0.14);
  --surface: #131319;
  --surface-2: #1b1b23;
  --border: #26262f;
  --text: #edeef2;
  --muted: #8b8b98;
  --accent: #e1306c;
  --accent-text: #ffffff;
  --accent-glow: rgba(225, 48, 108, 0.35);
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --rail-w: 68px;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8;
    --glow: rgba(225, 48, 108, 0.1);
    --surface: #ffffff;
    --surface-2: #eef0f5;
    --border: #dcdfe6;
    --text: #1a1a22;
    --muted: #666a76;
    --accent-glow: rgba(225, 48, 108, 0.2);
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(ellipse 900px 480px at 50% -8%, var(--glow), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--mono);
  display: flex;
  align-items: stretch;
}

/* ─── Icon rail ──────────────────────────────────────────────────────────── */

.rail {
  flex: 0 0 var(--rail-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 0;
  border-right: 1px solid var(--border);
  min-height: 100vh;
}

.rail-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: 18px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}

.rail-logo svg {
  width: 20px;
  height: 20px;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.rail-spacer {
  flex: 1;
}

.rail-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}

.rail-link svg {
  width: 19px;
  height: 19px;
}

.rail-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.rail-link.active {
  color: var(--accent);
  background: var(--surface-2);
  border-color: var(--border);
}

.rail-link.danger:hover {
  color: var(--bad);
}

.rail form {
  display: contents;
}

.rail button.rail-link {
  font: inherit;
  cursor: pointer;
  background: none;
}

/* ─── Shell ──────────────────────────────────────────────────────────────── */

.shell {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  width: 100%;
}

.shell.centered {
  max-width: 400px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 20px;
}

.brand {
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
  display: block;
  margin-bottom: 16px;
}

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

/* ─── Cards ──────────────────────────────────────────────────────────────── */

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

.card.narrow {
  max-width: 380px;
  margin: 0 auto;
  width: 100%;
}

h1 {
  font-size: 19px;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 15px;
  margin: 24px 0 12px;
  letter-spacing: -0.01em;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stack label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.row-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.row-form input[name='name'] {
  flex: 1 1 240px;
}

input,
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  min-width: 0;
}

input[type='text'],
input:not([type]),
input[name='username'],
input[name='name'],
input[type='date'],
input[type='datetime-local'] {
  border-radius: var(--radius-pill);
}

textarea {
  resize: vertical;
  font-family: inherit;
}

input[type='file'] {
  border-radius: var(--radius-sm);
  padding: 8px;
}

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

button,
.button {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  font-weight: 550;
}

button.primary:hover {
  filter: brightness(1.08);
}

button.danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 13px;
}

.link-button.danger {
  color: var(--bad);
}

.inline {
  display: inline;
}

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

.small {
  font-size: 13px;
}

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

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

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

.connection-line {
  margin: 0 0 14px;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert-error {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
}

.alert-notice {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

/* ─── Post queue ─────────────────────────────────────────────────────────── */

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

.post {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.post:first-child {
  border-top: none;
}

.post-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface-2);
}

.post-thumb-lg {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 14px;
}

.post-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.post-caption {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.post-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.post-error {
  font-size: 12px;
  color: var(--bad);
}

.post-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.badge {
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.badge-published {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}

.badge-failed {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
}

.badge-scheduled,
.badge-publishing {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}

.badge-canceled {
  opacity: 0.6;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tr.revoked td {
  opacity: 0.5;
}

code.token {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  user-select: all;
}

/* Touch targets. */
@media (pointer: coarse) {
  input,
  select,
  button,
  .button {
    min-height: 44px;
  }

  .rail-link {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 640px) {
  body {
    flex-direction: column;
  }

  .rail {
    flex-direction: row;
    width: 100%;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    gap: 2px;
  }

  .rail-logo {
    margin-bottom: 0;
    margin-right: 6px;
  }

  .rail-nav {
    flex-direction: row;
  }

  .shell {
    padding: 20px 14px 48px;
  }

  .shell.centered {
    min-height: calc(100vh - 64px);
  }

  .post {
    flex-wrap: wrap;
  }

  .post-actions {
    flex-direction: row;
    align-items: center;
  }
}
