/* FreightCore website. Colours as tokens; dark by default, like Discord. */
:root {
  --bg: #313338;
  --panel: #2b2d31;
  --panel-2: #1e1f22;
  --text: #dbdee1;
  --muted: #949ba4;
  --accent: #5865f2;
  --accent-text: #ffffff;
  --border: #3f4147;
  --dev: #da373c;
  --stage: #2f7fd1;
  --prod: #23a55a;
  --hover: #35373c;
  --selected: #404249;
  --embed: #2b2d31;
  --link: #00a8fc;
  --mention-bg: rgba(88, 101, 242, 0.3);
  --mention-text: #c9cdfb;
  --code-bg: #1e1f22;
  --warn: #f0b232;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ffffff;
    --panel: #f2f3f5;
    --panel-2: #e3e5e8;
    --text: #313338;
    --muted: #5c5e66;
    --border: #d4d7dc;
    --hover: #e8e9eb;
    --selected: #d7d9dd;
    --embed: #f2f3f5;
    --link: #006ce7;
    --mention-bg: rgba(88, 101, 242, 0.15);
    --mention-text: #4e5bd6;
    --code-bg: #e3e5e8;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "gg sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}

.brand { color: var(--text); font-weight: 700; text-decoration: none; }

.env {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: #fff;
  vertical-align: 2px;
}
.env-dev { background: var(--dev); }
.env-stage { background: var(--stage); }
.env-prod { background: var(--prod); }

.who { display: flex; align-items: center; gap: 8px; }
.who form { margin: 0; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }

main { flex: 1; padding: 32px 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}
.narrow { max-width: 480px; margin: 0 auto; }

h1 { margin: 0 0 12px; font-size: 22px; }
.hint { color: var(--muted); font-size: 13px; }
.role { font-weight: 600; }

.button {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}
.button.secondary { background: var(--panel-2); color: var(--text); }

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
button.link:hover { color: var(--text); text-decoration: underline; }

.foot { padding: 12px 16px; color: var(--muted); font-size: 12px; text-align: center; }

/* --- the shell: channel tree and content ------------------------------------- */

main.full { padding: 0; display: flex; }

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.tree {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px 8px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 50px);
  position: sticky;
  top: 0;
}
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree .threads { padding-left: 18px; }
.section + .section { margin-top: 14px; }
.category {
  padding: 0 8px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.chan {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  margin: 1px 0;
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
}
.chan:hover { background: var(--hover); color: var(--text); }
.chan[aria-current="page"] { background: var(--selected); color: var(--text); }
.chan-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.glyph { width: 18px; text-align: center; flex: none; opacity: 0.8; }
.count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.main-col { min-width: 0; }
.content { padding: 20px 24px 40px; min-width: 0; }
.problem {
  margin: 12px 24px 0;
  padding: 8px 12px;
  border-radius: 4px;
  background: var(--dev);
  color: #fff;
}
.intro { max-width: 640px; }
.channel-head { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.channel-head h1 { display: flex; align-items: center; gap: 6px; }
.topic { color: var(--muted); margin: -6px 0 12px; font-size: 13px; }
.notice {
  border-left: 3px solid var(--warn);
  background: var(--panel);
  padding: 8px 12px;
  border-radius: 4px;
}
.toolbar { font-size: 13px; }
.crumbs { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); }
a { color: var(--link); }

/* --- managed messages ------------------------------------------------------- */

.messages, .revisions { list-style: none; margin: 0; padding: 0; }
.item, .revision { padding: 10px 0; border-bottom: 1px solid var(--border); }
.item.gone .dmsg { opacity: 0.55; }
.meta, .rev-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0 0 56px;
  color: var(--muted);
  font-size: 12px;
}
.rev-head { margin: 0 0 8px; }
.badge {
  padding: 0 6px;
  border-radius: 4px;
  background: var(--dev);
  color: #fff;
}

.dmsg { display: flex; gap: 16px; }
.dmsg-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.dmsg-avatar.blank { background: var(--accent); }
.dmsg-body { min-width: 0; flex: 1; }
.dmsg-head { display: flex; align-items: baseline; gap: 6px; }
.dmsg-name { font-weight: 600; color: var(--text); }
.app-tag {
  padding: 0 4px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 600;
  line-height: 15px;
}
.dmsg-when { color: var(--muted); font-size: 12px; }

.md { overflow-wrap: anywhere; }
.md-h1 { font-size: 1.5em; font-weight: 700; margin: 6px 0 2px; }
.md-h2 { font-size: 1.25em; font-weight: 700; margin: 6px 0 2px; }
.md-h3 { font-size: 1.1em; font-weight: 700; margin: 6px 0 2px; }
.md-sub { color: var(--muted); font-size: 12px; }
.md-quote { border-left: 4px solid var(--border); padding-left: 10px; }
.md-list { margin: 2px 0; padding-left: 22px; }
.md-code, .md-pre code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.875em; }
.md-code { background: var(--code-bg); padding: 0 3px; border-radius: 3px; }
.md-pre { background: var(--code-bg); padding: 8px; border-radius: 4px; margin: 4px 0; white-space: pre-wrap; }
.mention { background: var(--mention-bg); color: var(--mention-text); padding: 0 2px; border-radius: 3px; font-weight: 500; }
.timestamp { background: var(--code-bg); padding: 0 2px; border-radius: 3px; }
.spoiler { background: var(--panel-2); color: transparent; border-radius: 3px; }
.spoiler:hover { color: inherit; }
.emoji { width: 1.375em; height: 1.375em; vertical-align: bottom; }

.embed {
  display: flex;
  gap: 16px;
  max-width: 520px;
  margin-top: 6px;
  padding: 8px 16px 16px 12px;
  background: var(--embed);
  border: 1px solid var(--border);
  border-left: 4px solid var(--panel-2);
  border-radius: 4px;
}
.embed-main { flex: 1; min-width: 0; }
.embed-author, .embed-footer { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.embed-author { font-size: 14px; font-weight: 600; }
.embed-author img { width: 24px; height: 24px; border-radius: 50%; }
.embed-title { margin-top: 8px; font-weight: 700; }
.embed-desc { margin-top: 8px; font-size: 14px; }
.embed-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.embed-field { grid-column: 1 / -1; font-size: 14px; }
.embed-field.inline { grid-column: auto; }
.embed-field-name { font-weight: 600; margin-bottom: 2px; }
.embed-image { display: block; max-width: 100%; max-height: 300px; margin-top: 16px; border-radius: 4px; }
.embed-thumb { width: 80px; height: 80px; object-fit: contain; border-radius: 4px; margin-top: 8px; flex: none; }
.embed-footer { font-size: 12px; color: var(--muted); }
.embed-footer img { width: 20px; height: 20px; border-radius: 50%; }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .tree { position: static; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--border); }
}

/* --- managing messages (step 3) ---------------------------------------------- */

.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.success, .error { padding: 8px 12px; border-radius: 4px; color: #fff; }
.success { background: var(--prod); }
.error { background: var(--dev); }
form.inline { display: inline; margin: 0; }
button.link.danger { color: var(--dev); font-size: inherit; }
button.button { border: 0; font: inherit; font-weight: 600; cursor: pointer; }

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.editor-form label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.editor-form label .hint { font-weight: 400; }
.editor-form input:not([type="checkbox"]), .editor-form textarea, .editor-form select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text);
  font: 14px/1.4 inherit;
  font-family: inherit;
}
.editor-form input.short { max-width: 120px; }
.editor-form input.id { max-width: 220px; }
.editor-form textarea { resize: vertical; }
.editor-form label.check { font-weight: 400; }
.editor-form fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 12px 12px 0; margin: 0 0 12px; }
.editor-form legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.actions { display: flex; gap: 8px; margin-top: 8px; }
.editor-preview { position: sticky; top: 12px; }
.editor-preview .category { padding: 0 0 8px; }

@media (max-width: 1000px) {
  .editor { grid-template-columns: 1fr; }
  .editor-preview { position: static; }
}

.ended {
  margin: 6px 0 0 56px;
  padding: 6px 10px;
  border-left: 3px solid var(--dev);
  background: var(--panel);
  border-radius: 4px;
  font-size: 13px;
}

/* --- older pages and retention (step 3b) ------------------------------------- */

.older { padding: 8px 0 12px; text-align: center; border-bottom: 1px solid var(--border); }
.removed { margin: 4px 0; color: var(--muted); font-style: italic; font-size: 13px; }

/* --- moderation log --------------------------------------------------------- */

.topnav { margin-right: auto; margin-left: 16px; font-size: 14px; }
.topnav a { color: var(--text); text-decoration: none; }
.topnav a:hover { text-decoration: underline; }
.modlog { width: 100%; border-collapse: collapse; font-size: 13px; }
.modlog th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.modlog td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.modlog tr.older td { text-align: center; }
.tag { padding: 0 4px; border-radius: 3px; background: var(--selected); color: var(--muted); font-size: 11px; }
.filters .filter { margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: var(--selected); }
.filters .filter a { text-decoration: none; margin-left: 2px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
h2 { margin: 20px 0 8px; font-size: 16px; }
.logged { padding: 10px 0; }
.attachments, .views { margin: 8px 0 0 56px; padding: 0; list-style: none; font-size: 13px; }
.views { margin-left: 0; }

/* --- administration ----------------------------------------------------------- */

.topnav a + a { margin-left: 16px; }
.identities { list-style: none; margin: 0; padding: 0; }
.identity { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.identity.gone { opacity: 0.6; }
.identity-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.identity-body { min-width: 0; flex: 1; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.roles { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.role-chip { padding: 0 6px; border: 1px solid var(--border); border-left-width: 4px; border-radius: 4px; font-size: 12px; }
.role-picker { display: flex; flex-wrap: wrap; gap: 4px 12px; max-height: 240px; overflow-y: auto; padding: 4px 0; }
.identity-form .dmsg-avatar { display: block; margin: 4px 0; }
.head-row .actions { margin-top: 0; align-items: center; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font: inherit; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form + form { margin-left: 8px; }
.warning { color: #f0b232; font-size: 12px; margin-top: 2px; }
