:root {
  color-scheme: light dark;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1d1c1a;
  --muted: #6b6862;
  --border: #dedbd3;
  --accent: #b1305b;
  --accent-text: #ffffff;
  --ok-bg: #dcf2e3;
  --ok-text: #17613a;
  --warn-bg: #fbecc9;
  --warn-text: #775204;
  --bad-bg: #fbdfdc;
  --bad-text: #96261c;
  --neutral-bg: #e8e6e0;
  --neutral-text: #57544e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #211f1e;
    --surface-2: #2c2a28;
    --text: #f1eeea;
    --muted: #a7a29a;
    --border: #3a3734;
    --accent: #e8628f;
    --accent-text: #220a13;
    --ok-bg: #173826;
    --ok-text: #8ee0ae;
    --warn-bg: #40310f;
    --warn-text: #f3cf7a;
    --bad-bg: #47201c;
    --bad-text: #f7aaa1;
    --neutral-bg: #33302d;
    --neutral-text: #c2bdb5;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 15px;
}

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

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

button {
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 14px;
}

button:disabled {
  cursor: default;
  opacity: 0.6;
}

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

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

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

input[type='password'],
textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

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

textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.small {
  font-size: 13px;
}

.error {
  color: var(--bad-text);
  margin: 0;
  min-height: 1.5em;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 24px;
  display: grid;
  gap: 14px;
}

.login-card h1 {
  font-size: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 17px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.tabs button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tabs button[aria-current='page'] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.content {
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 16px 60px;
  display: grid;
  gap: 16px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.chip.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.chip.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.chip.bad {
  background: var(--bad-bg);
  color: var(--bad-text);
}

.banner {
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.banner.bad {
  background: var(--bad-bg);
  color: var(--bad-text);
}

.banner button {
  margin-left: 8px;
  background: transparent;
  border-color: currentColor;
  color: inherit;
  padding: 2px 10px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.post-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  text-align: left;
}

.post-card:hover {
  border-color: var(--accent);
}

.post-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.post-body {
  padding: 11px 13px 13px;
  display: grid;
  gap: 7px;
}

.post-caption {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3em;
  overflow-wrap: anywhere;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.form {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 2px;
}

.field-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  align-items: baseline;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 9px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

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

.nowrap {
  white-space: nowrap;
}

.history-post {
  min-width: 170px;
  max-width: 320px;
  overflow-wrap: anywhere;
}

.history-error {
  min-width: 170px;
  overflow-wrap: anywhere;
}

.editor {
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.editor::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.editor-head {
  display: flex;
  gap: 12px;
  padding: 16px 18px 0;
}

.editor-head img {
  width: 64px;
  height: 64px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-2);
}

.editor-caption {
  max-height: 64px;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 15px;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
}

@media (max-width: 560px) {
  .tabs {
    order: 3;
    margin-left: 0;
    width: 100%;
  }

  #logout {
    margin-left: auto;
  }
}
