:root {
    --bg: #1e1f22; --panel: #2b2d31; --panel-2: #313338; --line: #3f4147; --text: #dbdee1; --muted: #949ba4;
    --accent: #5865f2; --accent-2: #4752c4; --danger: #da373c; --ok: #23a559; --warn: #f0b232;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, "Segoe UI", Roboto, sans-serif; }
a { color: #00a8fc; }
.loading, .notice { max-width: 34rem; margin: 15vh auto; padding: 1.5rem; background: var(--panel); border-radius: 8px; }
.notice h1 { margin-top: 0; font-size: 1.3rem; }
.muted { color: var(--muted); }

/* layout */
.app { display: grid; grid-template-columns: 17rem minmax(0, 1fr); grid-template-rows: auto 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; gap: 1rem; align-items: center; padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 600; }
.topbar .spacer { flex: 1; }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: .75rem; }
.main { overflow-y: auto; padding: 1rem 1.25rem 4rem; }
.side h2 { font-size: .8rem; text-transform: uppercase; color: var(--muted); margin: 1rem 0 .4rem; }
.side .item { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: .45rem .6rem; border-radius: 6px; cursor: pointer; }
.side .item:hover { background: var(--panel-2); }
.side .item.active { background: var(--accent); color: #fff; }
.side .item small { display: block; color: var(--muted); }
.side .item.active small { color: #e0e3ff; }
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--ok); margin-right: .35rem; }
.dot.off { background: var(--line); }

/* form */
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 28rem); gap: 1.5rem; align-items: start; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; }
.field label, .label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.field .row { display: flex; justify-content: space-between; align-items: baseline; }
.counter { font-size: .75rem; color: var(--muted); }
.counter.over { color: var(--danger); font-weight: 700; }
input[type=text], input[type=url], select, textarea {
    width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .6rem; font: inherit;
}
textarea { resize: vertical; min-height: 4rem; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=color] { width: 3rem; height: 2.2rem; padding: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; }
.inline-controls { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.embed-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin: 0 0 1rem; }
.embed-card > summary { cursor: pointer; padding: .6rem .8rem; display: flex; gap: .5rem; align-items: center; font-weight: 600; }
.embed-card > summary .spacer { flex: 1; }
.embed-body { padding: .25rem .9rem .9rem; }
.group { border-top: 1px solid var(--line); padding-top: .75rem; margin-top: .75rem; }
.group > .label { display: block; margin-bottom: .4rem; }
.field-row { background: var(--panel-2); border-radius: 6px; padding: .6rem; margin-bottom: .6rem; }
.field-row .tools { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; }

button { font: inherit; cursor: pointer; border: 0; border-radius: 6px; padding: .45rem .9rem; background: var(--panel-2); color: var(--text); }
button:hover:not(:disabled) { filter: brightness(1.2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; }
button.danger { background: var(--danger); color: #fff; }
button.small { padding: .15rem .5rem; font-size: .85rem; }
.actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .75rem 0; background: linear-gradient(transparent, var(--bg) 30%); }
.status { padding: .6rem .8rem; border-radius: 6px; margin: .5rem 0; background: var(--panel); border-left: 4px solid var(--muted); }
.status.ok { border-left-color: var(--ok); }
.status.error { border-left-color: var(--danger); }
.status ul { margin: .3rem 0 0 1.1rem; padding: 0; }
.unsaved { color: var(--warn); font-size: .85rem; }

/* the preview: what Discord will show */
.preview-wrap { position: sticky; top: 0; }
.preview-wrap h2 { font-size: .8rem; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
.dc-message { background: #313338; border-radius: 8px; padding: 1rem; display: flex; gap: .9rem; }
.dc-avatar { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--accent); }
.dc-body { min-width: 0; flex: 1; }
.dc-name { font-weight: 600; }
.dc-badge { background: var(--accent); color: #fff; font-size: .65rem; padding: .05rem .3rem; border-radius: 3px; margin-left: .35rem; vertical-align: middle; }
.dc-content { margin: .2rem 0 .4rem; overflow-wrap: anywhere; }
.dc-embed { margin-top: .4rem; max-width: 33rem; background: #2b2d31; border-left: 4px solid #1e1f22; border-radius: 4px; padding: .5rem .9rem .9rem .75rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
.dc-main { min-width: 0; }
.dc-author { display: flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 600; margin-top: .4rem; }
.dc-author img { width: 1.5rem; height: 1.5rem; border-radius: 50%; }
.dc-title { font-weight: 700; margin-top: .4rem; overflow-wrap: anywhere; }
.dc-title a { color: #00a8fc; text-decoration: none; }
.dc-description { font-size: .9rem; margin-top: .35rem; overflow-wrap: anywhere; }
.dc-fields { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.dc-field { flex: 1 1 100%; min-width: 0; font-size: .9rem; overflow-wrap: anywhere; }
.dc-field.inline { flex: 1 1 28%; }
.dc-field-name { font-weight: 700; font-size: .85rem; }
.dc-thumb { width: 5rem; height: 5rem; object-fit: cover; border-radius: 4px; margin-top: .4rem; }
.dc-image { max-width: 100%; max-height: 18rem; border-radius: 4px; margin-top: .6rem; display: block; }
.dc-footer { display: flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--muted); margin-top: .6rem; }
.dc-footer img { width: 1.25rem; height: 1.25rem; border-radius: 50%; }
.dc-empty { color: var(--muted); font-style: italic; }
.md-paragraph, .md-heading { white-space: normal; }
.md-h1 { font-size: 1.4rem; font-weight: 700; } .md-h2 { font-size: 1.2rem; font-weight: 700; } .md-h3 { font-size: 1.05rem; font-weight: 700; }
blockquote { margin: .2rem 0; padding-left: .7rem; border-left: 4px solid var(--line); }
pre { background: #1e1f22; border: 1px solid var(--line); border-radius: 4px; padding: .4rem .6rem; overflow-x: auto; margin: .3rem 0; }
code { background: #1e1f22; border-radius: 3px; padding: 0 .25rem; font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
pre code { background: none; padding: 0; }
ul { margin: .2rem 0; padding-left: 1.3rem; }
.mention, .emoji { background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 .2rem; }

@media (max-width: 62rem) {
    .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; }
    .side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 14rem; }
    .columns { grid-template-columns: 1fr; }
    .preview-wrap { position: static; }
}
