@font-face { font-family: Geist; src: url(/fonts/Geist-Medium.ttf); font-weight: 400 500; }
@font-face { font-family: Geist; src: url(/fonts/Geist-Bold.ttf); font-weight: 600 700; }
@font-face { font-family: Geist; src: url(/fonts/Geist-Black.ttf); font-weight: 800 900; }

:root {
  --ivory: #F5F0EA;
  --paper: #FBF8F4;
  --line: #E4DDD3;
  --ink: #202126;
  --ink-2: #55534F;
  --ink-3: #8C8880;
  --coral: #F07891;
  --coral-ink: #C84F69;
  --coral-soft: #FBE3E8;
  --ok: #2F7D5B;
  --bad: #B3364F;
  /* Discord dark */
  --d-bg: #313338;
  --d-embed: #2B2D31;
  --d-text: #DBDEE1;
  --d-muted: #949BA4;
  --d-link: #00A8FC;
  --d-btn: #4E5058;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Geist, system-ui, sans-serif;
  background: var(--ivory);
  color: var(--ink);
  font-size: 14px;
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* top bar */
.top {
  display: flex; align-items: center; gap: 28px;
  padding: 14px 28px;
  background: var(--ink); color: var(--ivory);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.wm { font-weight: 900; font-size: 20px; letter-spacing: .02em; }
.wm b { color: var(--coral); font-weight: 900; }
.sub { color: #A9A49C; font-weight: 500; }
.guild { display: flex; align-items: center; gap: 10px; color: #CFC9C0; }
.guild img { width: 26px; height: 26px; border-radius: 50%; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.ghost {
  background: transparent; border: 1px solid #45464D; color: var(--ivory);
  padding: 8px 14px; border-radius: 9px; font-weight: 600;
}
.ghost:hover { border-color: var(--coral); color: #fff; }

/* layout */
.layout { flex: 1; display: grid; grid-template-columns: minmax(420px, 1fr) minmax(420px, 560px); min-height: 0; }
.editor { overflow-y: auto; padding: 28px 40px 0; }
.editor h1 { font-size: 34px; font-weight: 900; margin: 0 0 22px; letter-spacing: -.01em; }
.block { margin-bottom: 30px; }
.block h2 { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.block h2 em, .field em { font-style: normal; font-weight: 500; color: var(--ink-3); margin-left: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; color: var(--ink-2); font-size: 13px; }
.count { float: right; }
input, select, textarea {
  width: 100%; background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
.spacer { height: 40px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 8px 15px; font-weight: 600;
}
.chips button:hover { border-color: var(--ink); }

.toggles { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.toggle { display: flex; align-items: center; gap: 10px; color: var(--ink-2); cursor: pointer; }
.toggle input {
  appearance: none; width: 34px; height: 20px; padding: 0; border-radius: 999px; flex: none;
  background: #D6CFC5; border: 0; position: relative; cursor: pointer; transition: background .15s;
}
.toggle input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.toggle input:checked { background: var(--ink); }
.toggle input:checked::after { transform: translateX(14px); }
.toggle input:focus { box-shadow: 0 0 0 3px var(--coral-soft); }

.swatches { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(0,0,0,.12);
  padding: 0; position: relative;
}
.swatch.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch-custom { display: flex; align-items: center; gap: 8px; margin-left: 6px; color: var(--ink-2); }
.swatch-custom input[type=color] { width: 40px; height: 34px; padding: 2px; border-radius: 10px; }
.swatch-custom input.hex { width: 96px; font-family: ui-monospace, monospace; }

.toolbar { display: flex; flex-wrap: wrap; gap: 4px; }
.toolbar button {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; min-width: 32px; font-size: 13px;
}
.toolbar button:hover { border-color: var(--ink); }

.row-item {
  display: grid; gap: 8px; align-items: start; margin-bottom: 10px;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
}
.row-item.fieldrow { grid-template-columns: 1fr 1.6fr auto; }
.row-item.btnrow { grid-template-columns: 1fr 1.6fr auto; align-items: center; }
.row-item textarea { min-height: 40px; }
.row-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.add {
  border: 1px dashed #CFC7BC; background: transparent; border-radius: 10px;
  padding: 9px 14px; font-weight: 600; color: var(--ink-2);
}
.add:hover { border-color: var(--ink); color: var(--ink); }
.add:disabled { opacity: .4; cursor: default; }
.link { background: none; border: 0; color: var(--coral-ink); font-weight: 600; padding: 4px 2px; }
.link:hover { text-decoration: underline; }

.imgslot { display: flex; flex-direction: column; gap: 8px; }
.slot-name { font-weight: 600; color: var(--ink-2); font-size: 13px; }
.drop {
  height: 150px; border: 1px dashed #CFC7BC; border-radius: 12px; background: var(--paper);
  display: grid; place-items: center; overflow: hidden; cursor: pointer; position: relative;
}
.drop p { margin: 0; color: var(--ink-3); }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; background: #EAE4DB; }
.drop.has img { display: block; }
.drop.has p { display: none; }
.drop.over { border-color: var(--coral); background: var(--coral-soft); }
.slot-row { display: flex; gap: 8px; align-items: center; }

.edit-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--ink); color: var(--ivory); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px;
}
.edit-banner span { color: #BDB7AE; margin-left: 10px; }
.edit-banner .link { color: var(--coral); }

/* preview */
.preview-col {
  background: var(--d-bg); color: var(--d-text); padding: 24px 24px 0; overflow-y: auto;
  border-left: 1px solid #1E1F22;
}
.preview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.preview-head h2 { margin: 0; font-size: 15px; color: #F2F3F5; }
.seein { display: flex; align-items: center; gap: 8px; color: var(--d-muted); }
.seein select { width: auto; background: #1E1F22; border-color: #1E1F22; color: var(--d-text); padding: 6px 10px; }
.hint { color: var(--d-muted); font-size: 12.5px; line-height: 1.5; }
.drawer .hint { color: var(--ink-3); }

.msg { display: grid; grid-template-columns: 40px 1fr; gap: 0 16px; font-family: "gg sans", "Noto Sans", Geist, sans-serif; font-size: 15px; line-height: 1.375; }
.msg .av { width: 40px; height: 40px; border-radius: 50%; }
.msg .who { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.msg .name { color: #F2F3F5; font-weight: 600; }
.msg .tag { background: #5865F2; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.msg .time { color: var(--d-muted); font-size: 12px; margin-left: 2px; }
.msg .content { white-space: pre-wrap; word-wrap: break-word; margin-bottom: 4px; }
.embed {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; max-width: 520px;
  background: var(--d-embed); border-left: 4px solid var(--coral); border-radius: 4px;
  padding: 10px 16px 16px 12px; margin-top: 4px;
}
.embed > * { grid-column: 1; }
.embed .thumb { grid-column: 2; grid-row: 1 / span 4; width: 80px; height: 80px; object-fit: contain; border-radius: 4px; }
.e-author { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #F2F3F5; margin-top: 6px; }
.e-author img { width: 24px; height: 24px; border-radius: 50%; }
.e-title { font-weight: 600; font-size: 16px; color: #F2F3F5; }
.e-title a { color: var(--d-link); text-decoration: none; }
.e-desc { font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.e-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 14px; }
.e-field { grid-column: 1 / -1; }
.e-field.inline { grid-column: auto; }
.e-field .fn { font-weight: 600; color: #F2F3F5; margin-bottom: 2px; }
.e-field .fv { white-space: pre-wrap; }
.e-image { grid-column: 1 / -1 !important; max-width: 100%; border-radius: 4px; margin-top: 8px; }
.e-foot { grid-column: 1 / -1 !important; font-size: 12px; color: var(--d-muted); margin-top: 8px; }
.btnrow-d { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.d-btn {
  background: var(--d-btn); color: #fff; border-radius: 8px; padding: 0 16px; height: 32px;
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500;
}
.d-btn svg { width: 14px; height: 14px; opacity: .85; }

/* rendered markdown */
.md strong { font-weight: 700; }
.md h1, .md h2, .md h3 { margin: 6px 0 2px; color: #F2F3F5; line-height: 1.25; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 16px; }
.md .sub { font-size: 12px; color: var(--d-muted); display: block; }
.md ul, .md ol { margin: 2px 0; padding-left: 22px; white-space: normal; }
.md blockquote { margin: 0; padding-left: 12px; border-left: 4px solid #4E5058; }
.md code { background: #1E1F22; border-radius: 4px; padding: 1px 4px; font-size: 85%; font-family: ui-monospace, Consolas, monospace; }
.md pre { background: #1E1F22; border: 1px solid #1E1F22; border-radius: 4px; padding: 8px; margin: 4px 0; white-space: pre-wrap; }
.md pre code { background: none; padding: 0; }
.md a { color: var(--d-link); text-decoration: none; }
.md .spoiler { background: #1E1F22; color: transparent; border-radius: 3px; cursor: pointer; }
.md .spoiler:hover { color: inherit; }
.md .mention { background: rgba(88,101,242,.3); color: #C9CDFB; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.md .ts { background: rgba(255,255,255,.06); border-radius: 3px; padding: 0 2px; }

/* action bar */
.actionbar {
  display: flex; align-items: center; gap: 20px; padding: 12px 28px;
  background: var(--paper); border-top: 1px solid var(--line);
}
.where { color: var(--ink-2); }
.where strong { color: var(--ink); }
.limits { margin-left: auto; color: var(--ink-3); font-size: 12.5px; }
.limits.over { color: var(--bad); font-weight: 600; }
.primary {
  background: var(--ink); color: var(--ivory); border: 0; border-radius: 10px;
  padding: 11px 26px; font-weight: 700; font-size: 15px;
}
.primary:hover { background: #000; }
.primary:disabled { opacity: .45; cursor: default; }

/* history drawer */
.drawer { position: fixed; inset: 0; background: rgba(32,33,38,.45); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-panel { width: min(460px, 100%); height: 100%; background: var(--ivory); padding: 24px; overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; font-size: 20px; font-weight: 900; }
#history { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
#history li button {
  width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
}
#history li button:hover { border-color: var(--ink); }
#history .h-title { font-weight: 700; }
#history .h-meta { color: var(--ink-3); font-size: 12.5px; }
#history .empty { color: var(--ink-3); }

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--ivory); padding: 12px 18px; border-radius: 12px;
  max-width: min(640px, calc(100% - 32px)); box-shadow: 0 10px 30px rgba(0,0,0,.25); line-height: 1.5;
}
.toast.bad { background: var(--bad); }
.toast a { color: var(--coral); font-weight: 700; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .preview-col { border-left: 0; padding-bottom: 24px; }
  .editor { padding: 20px 16px 0; }
  .grid2, .row-item.fieldrow, .row-item.btnrow { grid-template-columns: 1fr; }
  .top { padding: 12px 16px; gap: 14px; flex-wrap: wrap; }
  .actionbar { padding: 12px 16px; }
}

/* tabs */
.tabs { display: flex; gap: 4px; background: #2C2D33; padding: 4px; border-radius: 11px; }
.tab { background: transparent; border: 0; color: #BDB7AE; padding: 7px 16px; border-radius: 8px; font-weight: 600; }
.tab.on { background: var(--ivory); color: var(--ink); }
.tab:not(.on):hover { color: #fff; }

/* giveaways */
#gw-quick { margin-bottom: 8px; }
.gw-list-head { margin-top: 30px; }
.dlink { background: none; border: 0; color: var(--d-link); font-weight: 600; }
.gw-list { list-style: none; margin: 0; padding: 0 0 24px; display: flex; flex-direction: column; gap: 10px; }
.gw-item { background: var(--d-embed); border-radius: 8px; padding: 12px 14px; border-left: 4px solid var(--coral); }
.gw-item.done { border-left-color: #4E5058; }
.gw-item .gw-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.gw-item .gw-prize { color: #F2F3F5; font-weight: 600; }
.gw-item .gw-state { color: var(--d-muted); font-size: 12.5px; white-space: nowrap; }
.gw-item .gw-meta { color: var(--d-muted); font-size: 13px; margin-top: 4px; }
.gw-item .gw-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gw-item .gw-actions button, .gw-item .gw-actions a {
  background: var(--d-btn); color: #fff; border: 0; border-radius: 6px; padding: 6px 12px; font-size: 13px; font-weight: 500; text-decoration: none;
}
.gw-item .gw-actions button:hover, .gw-item .gw-actions a:hover { background: #6D6F78; }
.gw-item .gw-actions .danger { background: #8E2A3F; }
.d-btn.success { background: #248046; }
.empty-d { color: var(--d-muted); }

.demo-banner { background: var(--coral); color: var(--ink); font-weight: 700; padding: 10px 28px; text-align: center; }
