:root {
  color-scheme: dark;
  --bg: #17181b;
  --panel: #24262b;
  --panel-2: #2d3036;
  --text: #eef0f3;
  --muted: #9aa1ab;
  --line: #3c4048;
  --accent: #5865f2;
  --danger: #da373c;
  --ok: #248046;
}
body[data-theme="discord"] {
  --bg: #313338;
  --panel: #2b2d31;
  --panel-2: #383a40;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --line: #1e1f22;
  --accent: #5865f2;
  --danger: #da373c;
  --ok: #23a559;
}
body[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --text: #20242a;
  --muted: #5f6672;
  --line: #d9dee7;
  --accent: #315ce8;
  --danger: #c9363d;
  --ok: #1e8b4d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Yu Gothic UI", system-ui, sans-serif;
  display: grid;
  grid-template-columns: 230px 1fr;
  overflow-x: hidden;
}
aside {
  background: color-mix(in srgb, var(--bg) 72%, #000 28%);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { margin: 0 4px 22px; }
.brand strong { display: block; font-size: 22px; }
.brand span, .muted { color: var(--muted); }
.nav, .logout button {
  display: block;
  width: 100%;
  margin: 5px 0;
  text-align: left;
  background: transparent;
  color: var(--text);
}
.nav.active { background: var(--accent); }
.logout { position: absolute; left: 14px; right: 14px; bottom: 16px; }
main { padding: 20px 24px 40px; min-width: 0; overflow-x: hidden; }
header {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; }
h2 { font-size: 17px; margin-bottom: 14px; }
p { margin: 4px 0 0; }
.status {
  min-width: 88px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--danger);
  font-weight: 700;
}
.status.running { background: var(--ok); }
.page { display: none; padding-top: 18px; }
.page.active { display: block; }
article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
  overflow: hidden;
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr); }
.form-grid, .option-builder, .role-create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
  min-width: 0;
}
.form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.role-create-grid {
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(130px, 1fr) minmax(150px, auto);
}
label { display: block; color: var(--muted); margin: 8px 0; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
input, select, textarea, button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 74%, #000 26%);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}
input[type="checkbox"] { width: auto; min-width: 16px; }
input[type="file"] {
  padding: 8px;
}
select, input, textarea { min-width: 0; }
textarea { resize: vertical; min-height: 80px; }
button {
  width: auto;
  cursor: pointer;
  background: var(--panel-2);
  border: 0;
  font-weight: 700;
}
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  border-radius: 6px;
  padding: 10px 14px;
  color: white;
  text-decoration: none;
  font-weight: 700;
}
button:hover { filter: brightness(1.08); }
.primary { background: var(--accent); color: white; }
.danger { background: var(--danger); color: white; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.bot-actions-card {
  align-self: start;
}
.bot-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr));
  gap: 10px;
  margin: 0;
}
.bot-actions button {
  width: 100%;
  min-height: 42px;
}
.inline-actions {
  margin: 0;
}
.text-edit-tools {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1f2228;
  padding: 14px;
}
.text-edit-tools h3 {
  margin: 0 0 6px;
}
.text-editing .site-text {
  outline: 1px dashed #f0b232;
  outline-offset: 2px;
  border-radius: 3px;
  cursor: text;
}
.text-editing .site-text:focus {
  outline: 2px solid #f0b232;
  background: rgba(240, 178, 50, .12);
}
.coming-soon {
  min-height: 320px;
}
.soon-panel {
  margin-top: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #1f2228;
  padding: 22px;
  display: grid;
  gap: 8px;
}
.soon-panel strong {
  font-size: 22px;
}
.soon-panel span {
  color: var(--muted);
}
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-row h2 { margin-bottom: 0; }
.hidden { display: none !important; }
.rr-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.25fr);
  gap: 16px;
  align-items: start;
}
.rr-review {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  align-items: start;
}
.rr-review h3 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 0;
}
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0 0; }
.metrics div { background: var(--panel-2); padding: 12px; border-radius: 6px; }
dt { color: var(--muted); }
dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.logs {
  background: #101115;
  border-radius: 6px;
  min-height: 220px;
  max-height: 340px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}
.preview {
  margin: 14px 0;
  border-left: 4px solid var(--accent);
  background: #1f2228;
  border-radius: 6px;
  padding: 12px;
  min-height: 48px;
}
.rr-review .preview {
  margin: 0;
  border-left: 0;
  background: #313338;
  padding: 0;
  min-height: 180px;
}
.preview-title { font-weight: 800; margin-bottom: 6px; }
.preview-img { max-width: min(100%, 420px); max-height: 260px; display: block; margin-top: 10px; border-radius: 6px; }
.emoji-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}
.selected-emoji {
  min-width: 180px;
  background: #181a1f;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.selected-emoji span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}
.selected-emoji strong {
  display: flex;
  align-items: center;
  min-height: 26px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.emoji-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 8px;
  margin: 12px 0;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}
.emoji-card, .chip {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  min-width: 0;
}
.emoji-card {
  cursor: pointer;
  min-height: 52px;
  transition: border-color .15s, background .15s, transform .15s;
}
.emoji-card:hover { border-color: #6873f6; background: #343842; }
.emoji-card.selected {
  border-color: var(--accent);
  background: #33384f;
}
.emoji-card img, .emoji-glyph {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  object-fit: contain;
  display: grid;
  place-items: center;
  font-size: 22px;
}
.emoji-card span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.option-list {
  display: grid;
  gap: 8px;
}
.option-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(110px, 150px) auto;
  gap: 10px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}
.option-row .emoji {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: #181a1f;
  border-radius: 6px;
  overflow: hidden;
}
.option-row strong,
.option-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.option-row small {
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inline-emoji {
  width: 24px;
  height: 24px;
  object-fit: contain;
  vertical-align: -6px;
}
.option-row .inline-emoji {
  width: 28px;
  height: 28px;
  vertical-align: middle;
}
.rr-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.post-picker-list {
  display: grid;
  gap: 12px;
}
.post-picker-card {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  background: #1f2228;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.post-picker-card:not(.static):hover {
  border-color: var(--accent);
  background: #2e3447;
}
.post-picker-card.static {
  cursor: default;
}
.post-picker-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}
.post-picker-meta strong,
.post-picker-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.discord-preview.compact {
  min-height: 0;
  padding: 12px;
}
.discord-preview.compact .discord-embed {
  max-width: 560px;
}
.discord-preview.compact .discord-embed-image,
.discord-preview.compact .discord-standalone-image {
  max-height: 220px;
}
.selected-existing-preview {
  margin: 10px 0 14px;
}
.selected-existing-preview .post-picker-card {
  padding: 0;
  background: transparent;
  border: 0;
}
.selected-existing-preview .post-picker-meta {
  padding: 0 0 8px;
}
.rr-edit-card {
  text-align: left;
  display: grid;
  gap: 5px;
  min-height: 108px;
  background: #1f2228;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.rr-edit-card:hover,
.rr-edit-card.selected {
  border-color: var(--accent);
  background: #30364b;
}
.rr-edit-card strong,
.rr-edit-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rr-edit-card .inline-emoji {
  width: 22px;
  height: 22px;
  margin-right: 3px;
}
.existing-edit {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.existing-edit h3 {
  margin: 0;
  font-size: 15px;
}
.selected-pill {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #181a1f;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
}
.selected-pill .inline-emoji {
  width: 26px;
  height: 26px;
}
.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.table-actions button {
  padding: 6px 9px;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .62);
  padding: 24px;
}
.modal-panel {
  width: min(980px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.modal-emoji-grid {
  max-height: 520px;
}
.reaction-users {
  margin: 14px 0;
}
.reaction-users h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 15px;
}
.reaction-users h3 small {
  color: var(--muted);
  font-weight: 400;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1f2228;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  margin: 6px 0;
}
.user-row img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}
.user-row em {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  padding: 2px 5px;
}
.unicode-emoji {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.discord-preview {
  background: #313338;
  color: #dbdee1;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  min-height: 180px;
  font-family: "gg sans", "Noto Sans", "Yu Gothic UI", system-ui, sans-serif;
}
.discord-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #5865f2;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
}
.discord-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.discord-message { min-width: 0; }
.discord-content {
  margin-top: 4px;
  color: #dbdee1;
  overflow-wrap: anywhere;
}
.discord-author {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #f2f3f5;
  font-weight: 700;
  line-height: 1.2;
}
.discord-author span {
  background: #5865f2;
  color: white;
  font-size: 10px;
  border-radius: 3px;
  padding: 1px 4px;
}
.discord-author time {
  color: #949ba4;
  font-size: 12px;
  font-weight: 400;
}
.discord-embed {
  margin-top: 6px;
  max-width: 520px;
  background: #2b2d31;
  border-left: 4px solid #5865f2;
  border-radius: 4px;
  padding: 12px;
}
.discord-embed-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}
.discord-embed-thumb {
  width: 84px;
  max-height: 84px;
  object-fit: cover;
  border-radius: 4px;
}
.discord-embed-title {
  color: #f2f3f5;
  font-weight: 700;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.discord-embed-body {
  color: #dbdee1;
  overflow-wrap: anywhere;
}
.discord-embed-image {
  display: block;
  margin-top: 10px;
  max-width: min(100%, 420px);
  max-height: 280px;
  border-radius: 4px;
  object-fit: contain;
}
.discord-embed-footer {
  margin-top: 10px;
  color: #b5bac1;
  font-size: 12px;
}
.discord-image-message { margin-top: 8px; }
.discord-standalone-image {
  max-width: min(100%, 520px);
  max-height: 320px;
  border-radius: 4px;
  object-fit: contain;
}
.discord-image-placeholder {
  border: 1px dashed #4e5058;
  color: #949ba4;
  border-radius: 4px;
  padding: 18px;
  max-width: 520px;
}
.discord-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.discord-reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 3px 8px;
  background: #2b2d31;
  border: 1px solid #3f4147;
  border-radius: 8px;
  color: #b5bac1;
}
.discord-reaction b {
  font-size: 13px;
  font-weight: 700;
}
.discord-reaction .inline-emoji {
  width: 22px;
  height: 22px;
  vertical-align: middle;
}
.empty-options {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}
.chip strong {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip button { padding: 3px 7px; flex: 0 0 auto; }
.table-wrap { overflow: auto; }
.stored-cards { display: none; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; white-space: nowrap; }
.theme-options,
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.theme-options button {
  width: 100%;
}
.category-check {
  min-height: 42px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.detail-preview {
  border-radius: 8px;
  min-height: 0;
}
.internal-details {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}
.internal-details dl {
  display: grid;
  gap: 8px;
}
.news-result-list,
.news-history {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.news-card-row,
.news-history-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}
.news-card-row img {
  width: 74px;
  height: 54px;
  object-fit: cover;
  border-radius: 5px;
}
.news-card-row:not(:has(img)) {
  grid-template-columns: 1fr;
}
.news-card-row strong,
.news-history-row strong {
  display: block;
  overflow-wrap: anywhere;
}
.news-card-row small,
.news-history-row span {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}
.news-history-row {
  grid-template-columns: 1fr;
}
.compact-logs {
  min-height: 160px;
  max-height: 260px;
}
#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: .2s;
  max-width: min(420px, calc(100vw - 32px));
}
#toast.show { opacity: 1; transform: translateY(0); }
.login-body { display: grid; place-items: center; grid-template-columns: 1fr; }
.login-panel { width: min(420px, calc(100vw - 28px)); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px; }
.stack > * { margin-top: 12px; }
.error { color: #ffb4b4; }
.setup-note {
  margin-top: 14px;
  background: #1f2228;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}
.setup-note code {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--text);
}
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

@media (max-width: 860px) {
  body { display: block; }
  aside { position: static; height: auto; display: flex; gap: 8px; overflow-x: auto; padding: 12px; }
  .brand, .logout { display: none; }
  .nav { white-space: nowrap; text-align: center; }
  main { padding: 12px; }
  header, .grid.two { display: block; }
  .bot-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status { margin-top: 12px; }
  .emoji-toolbar { grid-template-columns: 1fr; }
  .selected-emoji { min-width: 0; }
  .rr-layout, .rr-review, .role-create-grid { grid-template-columns: 1fr; }
  .section-row { display: block; }
  .section-row button { margin-top: 10px; width: 100%; }
  .option-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .option-row .role-mode { grid-column: 2 / -1; }
  .discord-preview { grid-template-columns: 34px minmax(0, 1fr); padding: 12px; }
  .discord-avatar { width: 34px; height: 34px; }
  .table-wrap { display: none; }
  .stored-cards {
    display: grid;
    gap: 10px;
  }
  .stored-card {
    background: #1f2228;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }
  .stored-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
  }
  .stored-card-head strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .stored-card-head span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
  }
  .stored-card dl {
    margin: 0;
    display: grid;
    gap: 8px;
  }
  .stored-card dl div {
    min-width: 0;
  }
  .stored-card dt {
    color: var(--muted);
    font-size: 12px;
  }
  .stored-card dd {
    margin: 0;
    overflow-wrap: anywhere;
  }
  .stored-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
  }
  .stored-card-actions button {
    width: 100%;
  }
  table, tbody, tr, td { display: block; width: 100%; }
  table tr:first-child { display: none; }
  table tr {
    background: #1f2228;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 10px 0;
    padding: 8px;
  }
  table td {
    border-bottom: 0;
    padding: 7px 4px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 2px;
  }
  .table-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .table-actions button {
    width: 100%;
  }
}
