:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e0e6;
  --accent: #1f7a5f;
  --accent-dark: #155d49;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  width: min(920px, calc(100vw - 32px));
  margin: 32px auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

p,
span,
legend {
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

label,
.form-field,
fieldset {
  display: block;
  margin: 0 0 18px;
}

.field-label,
label span,
legend {
  display: block;
  font-size: 14px;
  margin-bottom: 8px;
}

textarea,
input[type="file"],
input[type="text"],
input[type="password"],
input:not([type]) {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 12px;
}

.format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  position: relative;
  z-index: 1;
}

.format-btn {
  min-width: 36px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  line-height: 1;
}

.format-btn:hover {
  background: #eef7f4;
}

.format-btn * {
  pointer-events: none;
}

.fmt-bold {
  font-weight: 700;
}

.fmt-italic {
  font-style: italic;
}

.fmt-underline {
  text-decoration: underline;
}

.fmt-strike {
  text-decoration: line-through;
}

.format-btn code {
  color: inherit;
  font-size: 12px;
}

.media-list {
  display: grid;
  gap: 10px;
  margin: -8px 0 18px;
}

.media-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfd;
}

.media-item.dragging {
  opacity: 0.6;
}

.media-item.drag-over {
  border-color: var(--accent);
  background: #eef7f4;
}

.media-preview {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: #e8edf1;
}

.media-meta {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.media-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.media-control,
.media-remove {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent);
  padding: 8px 10px;
}

.media-control:disabled {
  cursor: default;
  opacity: 0.4;
}

.media-control:hover:not(:disabled) {
  background: #eef7f4;
}

.media-remove {
  color: #a43b36;
}

.media-remove:hover {
  background: #fff0ef;
}

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

.rich-editor {
  position: relative;
  z-index: 0;
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 400;
  padding: 12px;
  line-height: 1.5;
  outline: none;
  white-space: pre-line;
}

.rich-editor:hover {
  font-weight: 400;
}

.rich-editor:focus {
  border-color: var(--accent);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.rich-editor blockquote {
  margin: 8px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: #eef7f4;
  color: var(--text);
}

.rich-editor code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #eef1f3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

.rich-editor a {
  color: var(--accent);
  text-decoration: underline;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.channel-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.channel-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.channel-group h3 {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.3;
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

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

button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

pre {
  min-height: 24px;
  white-space: pre-wrap;
  color: var(--muted);
}

.notice {
  margin-top: 12px;
  color: #8a5a00;
}

@media (max-width: 640px) {
  .media-item {
    grid-template-columns: 64px 1fr;
  }

  .media-controls {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .channel-groups {
    grid-template-columns: 1fr;
  }
}
