:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --ink: #1c1915;
  --muted: #655f56;
  --line: #ddd6c8;
  --card: #fffcf7;
  --accent: #1d4e3a;
  --accent-ink: #f6f3ea;
  --warn: #8a3d24;
  --warn-bg: #f8e6dc;
  --ok-bg: #e5f0ea;
  --shadow: 0 1px 0 rgba(28, 25, 21, 0.04);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

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

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.92em;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-nav a, .linkish {
  color: var(--ink);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }

h1 { font-size: 1.8rem; font-weight: 650; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

.page-head, .actions, .link-row, .top, .top-nav {
  display: flex;
  gap: 12px;
}

.page-head {
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
}

.kicker { margin: 0 0 4px; color: var(--muted); }

.card {
  --card-pad: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: var(--card-pad);
  box-shadow: var(--shadow);
  margin: 16px 0;
}

.card > h2 {
  margin: calc(var(--card-pad) * -1) calc(var(--card-pad) * -1) 18px;
  padding: 14px var(--card-pad);
  background: #f1ebe2;
  border-bottom: 1px solid var(--line);
  border-radius: 15px 15px 0 0;
}

.narrow { max-width: 460px; }

.form { display: grid; gap: 16px; }
.form label, fieldset { display: grid; gap: 8px; }
.form .check, label.check { display: flex; align-items: center; gap: 8px; }

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

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  font-size: 16px;
}

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

button, .button {
  min-height: 44px;
  margin-top: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
  white-space: normal;
  text-align: center;
}

.link-row button {
  white-space: nowrap;
  flex: 0 0 auto;
}

button.danger {
  background: transparent;
  color: var(--warn);
  border: 1px solid var(--warn);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
button.danger:hover,
button.danger:focus-visible {
  background: #b4332a;
  border-color: #b4332a;
  color: #fff;
  box-shadow: 0 8px 18px rgba(180, 51, 42, 0.22);
}
button.danger:active {
  background: #8d241d;
  border-color: #8d241d;
}
button.linkish { min-height: 0; width: auto; margin-top: 0; padding: 0; }

.top-nav a,
.top-nav button.linkish {
  margin-top: 0;
  min-height: 40px;
  width: auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: #efeae0;
  color: var(--ink);
}

.actions { flex-wrap: wrap; align-items: center; margin: 16px 0 20px; gap: 12px 16px; }
.actions a {
  margin-top: 0;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}

.hint { color: var(--muted); font-size: 0.92rem; margin: 0; }
.banner {
  background: var(--ok-bg);
  border-radius: 12px;
  padding: 12px 14px;
}
.banner.warn { background: var(--warn-bg); color: var(--warn); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ece7dc;
  font-size: 0.85rem;
}
.badge-active { background: #d9eadf; }
.badge-closed { background: #ece7dc; }
.badge-draft { background: #f3e6c8; }

.stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 8px 0 18px;
}
.stats div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.stats dt { color: var(--muted); font-size: 0.82rem; }
.stats dd { margin: 4px 0 0; font-size: 1.15rem; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.anchors { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.anchors a {
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--ink);
}

.channel {
  margin: 12px 0;
  padding: 18px 16px;
  border-radius: 14px;
  background: #f7f4ee;
}
.channel:nth-of-type(even) { background: #f3eee4; }
.channel form + form { margin-top: 14px; }
.link-row {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}
.link-row a { overflow-wrap: anywhere; flex: 1 1 220px; min-width: 0; }
.link-row button { margin-top: 0; }
.inline { margin-top: 12px; }
ul.plain li form { margin-top: 12px; }

.editor { display: grid; gap: 10px; }
.editor-bar, .editor-extra, .emoji-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.editor-extra[hidden], .emoji-box[hidden] { display: none; }
.editor-bar button, .editor-extra button, .emoji-box button {
  margin-top: 0;
  min-height: 36px;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}
.editor-bar button {
  width: 40px;
  padding: 0;
  font-size: 1rem;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.button-row form { margin: 0; }
.button-row button { margin-top: 0; }
#broadcast { scroll-margin-top: 84px; }
.photo-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7f4ee;
}
.photo-card .preview { margin: 0; max-height: 120px; object-fit: cover; }
.photo-remove {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 0;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--warn);
  border-radius: 999px;
  color: var(--warn);
  background: white;
  cursor: pointer;
}
.form label.photo-remove {
  display: inline-flex;
  flex-flow: row nowrap;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
}
.photo-remove span { white-space: nowrap; }
.photo-remove input {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  accent-color: var(--warn);
}
.photo-card:has(input:checked) .preview { opacity: 0.35; }
.photo-card:has(input:checked) .photo-remove { background: var(--warn-bg); }
.editor-bar button[data-cmd="emoji"],
.emoji-box button {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
h3.after-block { margin-top: 36px; }
.post-block { display: grid; gap: 16px; }
.post-block + .post-block {
  margin-top: 12px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.form label.prominent { gap: 12px; }
.prominent-label {
  display: block;
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}
td.row-action, th.row-action { width: 1%; white-space: nowrap; }
td.row-action form { margin: 0; }
td.row-action button { margin-top: 0; }
.emoji-box {
  max-height: 240px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}
.emoji-box button { width: 40px; padding: 0; border: 0; font-size: 1.25rem; }
.editor-extra input { flex: 1 1 180px; }
.editor-preview, .standard-body {
  white-space: pre-wrap;
  background: #f7f4ee;
  border-radius: 12px;
  padding: 12px 14px;
}
.editor-preview[hidden] { display: none; }
.page-head .button { margin-top: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 550; font-size: 0.85rem; }
.table-wrap, .matrix-scroll { overflow-x: auto; }
.preview { max-width: 240px; border-radius: 12px; display: block; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.state-missing { color: var(--warn); }
.only-mobile { display: none; }

@media (max-width: 860px) {
  .wrap { width: min(100% - 24px, 1120px); }
  .two { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .page-head, .top { align-items: flex-start; flex-direction: column; }
  .only-desktop { display: none !important; }
  .only-mobile { display: block; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    margin-bottom: 12px;
    padding: 6px 0;
  }
  table.stack td {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border: 0;
    padding: 8px 14px;
  }
  table.stack td::before {
    content: attr(data-label);
    color: var(--muted);
  }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
}
