/* Discord Webhook Builder. Editor colours follow the site theme; the
   preview uses Discord's own dark look so it matches what people will see. */

body {
    padding: 0 calc(20px * var(--space-scale)) calc(60px * var(--space-scale));
}

#site-header {
    margin: 0 calc(-20px * var(--space-scale));
}

.hidden {
    display: none !important;
}

.wb-intro {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    padding: calc(30px * var(--space-scale));
    margin: 0 auto calc(24px * var(--space-scale));
}

.wb-intro h1 {
    color: var(--text);
    font-size: 2.2em;
    margin: 0 0 calc(10px * var(--space-scale));
    line-height: 1.2;
}

.wb-intro p {
    color: var(--text-muted);
}

.wb-instructions {
    margin-top: calc(14px * var(--space-scale));
    border-top: 1px solid var(--border);
    padding-top: calc(12px * var(--space-scale));
}

.wb-instructions summary {
    cursor: pointer;
    color: var(--accent-bright);
    font-weight: 600;
}

.wb-instructions-body p {
    margin: calc(10px * var(--space-scale)) 0;
}

.wb-instructions-body code {
    background: var(--surface-alt);
    padding: 1px 5px;
    border-radius: calc(4px * var(--radius-scale));
}

.wb-instructions-body a {
    color: var(--accent-bright);
}

/* ---- Workspace ---------------------------------------------------------- */

.wb-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: calc(24px * var(--space-scale));
    max-width: 1400px;
    margin: 0 auto;
    align-items: start;
}

/* As tall as the editor, so the preview inside can stay on screen. */
.wb-preview-col {
    align-self: stretch;
    min-width: 0;
}

.wb-view-switch {
    display: none;
}

/* Below the site's sticky header (72px). */
.wb-preview-sticky {
    position: sticky;
    top: calc(72px + 16px * var(--space-scale));
}

.wb-preview-label {
    color: var(--text-muted);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

@media (max-width: 900px) {
    .wb-workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .wb-view-switch {
        display: flex;
        gap: 6px;
        position: sticky;
        top: 72px;
        z-index: 5;
        background: var(--bg);
        padding: 8px 0;
        margin-bottom: 8px;
    }

    .wb-view-btn {
        flex: 1;
    }

    .wb-view-btn.active {
        background: var(--accent);
        border-color: var(--accent-bright);
        color: var(--on-accent);
    }

    .wb-workspace[data-view="editor"] .wb-preview-col,
    .wb-workspace[data-view="preview"] .wb-editor {
        display: none;
    }

    .wb-preview-sticky {
        position: static;
    }

    /* Too tall to keep on screen on a phone. */
    .wb-actions-card {
        position: static;
        box-shadow: none;
    }
}

/* ---- Editor cards --------------------------------------------------------- */

.wb-editor {
    display: flex;
    flex-direction: column;
    gap: calc(16px * var(--space-scale));
    min-width: 0;
}

.wb-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    padding: calc(20px * var(--space-scale));
    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--space-scale));
    min-width: 0;
}

.wb-card h2 {
    color: var(--text);
    font-size: 1.15em;
    margin: 0;
}

.wb-card h2 i {
    color: var(--accent-bright);
    margin-right: 6px;
}

.wb-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.wb-label {
    color: var(--text-muted);
    font-size: 0.9em;
    display: block;
}

.wb-hint {
    color: var(--text-muted);
    font-size: 0.88em;
    margin: 0;
}

.wb-hint[data-kind="ok"] {
    color: var(--success);
}

.wb-hint[data-kind="err"] {
    color: var(--danger);
}

.wb-counter {
    color: var(--text-muted);
    font-size: 0.8em;
    font-variant-numeric: tabular-nums;
    float: right;
}

.wb-counter.over {
    color: var(--danger);
    font-weight: 600;
}

input,
select,
textarea,
button {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    padding: calc(9px * var(--space-scale)) calc(11px * var(--space-scale));
    font-size: 0.95rem;
    font-family: inherit;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    box-sizing: border-box;
}

input[type="text"],
input[type="url"],
input[type="datetime-local"],
textarea {
    width: 100%;
    min-width: 0;
}

input[type="datetime-local"] {
    color-scheme: dark;
    width: auto;
}

textarea {
    resize: vertical;
    line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
    outline: none;
    border-color: var(--accent-bright);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

button {
    cursor: pointer;
}

button:hover:not(:disabled) {
    border-color: var(--accent-bright);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wb-primary {
    background: var(--accent);
    border-color: var(--accent-bright);
    color: var(--on-accent);
    font-weight: 600;
}

.wb-primary:hover:not(:disabled) {
    background: var(--accent-bright);
}

.wb-danger:hover:not(:disabled) {
    border-color: var(--danger);
    color: var(--danger);
}

.wb-small {
    padding: 5px 10px;
    font-size: 0.85rem;
}

.wb-icon-btn {
    padding: 6px 9px;
    line-height: 1;
}

.wb-add {
    align-self: flex-start;
}

.wb-input-row {
    display: flex;
    gap: 8px;
}

.wb-input-row input {
    flex: 1;
}

.wb-grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

@media (max-width: 520px) {
    .wb-grid-2 {
        grid-template-columns: minmax(0, 1fr);
    }
}

.wb-check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.92em;
    cursor: pointer;
}

.wb-check input {
    width: auto;
    accent-color: var(--accent-bright);
}

/* The webhook link is a secret: dotted until shown. */
.wb-secret:not(.shown):not(:placeholder-shown) {
    -webkit-text-security: disc;
}

.wb-segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wb-segmented label {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.92em;
}

.wb-segmented label:has(input:checked) {
    border-color: var(--accent-bright);
    background: rgba(var(--accent-bright-rgb), 0.15);
}

.wb-segmented input {
    accent-color: var(--accent-bright);
}

.wb-target {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.wb-target.wb-disabled {
    opacity: 0.55;
}

.wb-edit-load {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.wb-edit-load summary {
    cursor: pointer;
    color: var(--accent-bright);
    font-weight: 600;
    margin-bottom: 8px;
}

.wb-edit-load .wb-hint {
    margin-bottom: 8px;
}

.wb-editing {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(var(--accent-bright-rgb), 0.12);
    border: 1px solid var(--accent-bright);
    border-radius: calc(12px * var(--radius-scale));
    padding: 12px 16px;
    color: var(--text);
}

.wb-editing i {
    color: var(--accent-bright);
    margin-right: 6px;
}

/* ---- Embeds ------------------------------------------------------------------ */

#wb-embeds {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wb-embed {
    border: 1px solid var(--border);
    border-radius: calc(10px * var(--radius-scale));
    background: var(--bg);
}

.wb-embed-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    cursor: pointer;
    list-style: none;
    color: var(--text);
    font-weight: 600;
}

.wb-embed-head::-webkit-details-marker {
    display: none;
}

.wb-embed-head::before {
    content: "▸";
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.wb-embed[open] > .wb-embed-head::before {
    transform: rotate(90deg);
}

.wb-embed-swatch {
    width: 12px;
    height: 12px;
    border-radius: calc(3px * var(--radius-scale));
    flex: none;
}

.wb-embed-swatch.none {
    border: 1px dashed var(--text-muted);
}

.wb-embed-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wb-embed-tools {
    display: flex;
    gap: 4px;
    flex: none;
}

.wb-embed-body {
    padding: 4px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wb-embed fieldset {
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    padding: 10px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.wb-embed legend {
    color: var(--text-muted);
    font-size: 0.85em;
    padding: 0 4px;
}

.wb-color-row,
.wb-time-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wb-color-row .wb-label,
.wb-time-row .wb-label {
    display: inline;
}

input[type="color"] {
    width: 44px;
    height: 34px;
    padding: 2px;
    cursor: pointer;
}

input[type="color"].none {
    opacity: 0.35;
}

.wb-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wb-field {
    display: flex;
    gap: 8px;
    border-left: 3px solid var(--border);
    padding-left: 8px;
}

.wb-field-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wb-field-tools {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---- Buttons and files ------------------------------------------------------------ */

#wb-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wb-button-row {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr) minmax(0, 1.4fr) auto auto;
    gap: 6px;
    align-items: center;
}

.wb-button-tools {
    display: flex;
    gap: 4px;
}

@media (max-width: 640px) {
    .wb-button-row {
        grid-template-columns: 70px minmax(0, 1fr) auto;
        border-left: 3px solid var(--border);
        padding-left: 8px;
    }

    .wb-button-row [data-bf="url"] {
        grid-column: 1 / -1;
    }

    .wb-button-row .wb-button-tools {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

.wb-files {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wb-files li {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    padding: 6px 6px 6px 12px;
    color: var(--text);
    min-width: 0;
}

.wb-files li > i {
    color: var(--text-muted);
}

.wb-file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wb-file-size,
.wb-file-kept {
    color: var(--text-muted);
    font-size: 0.82em;
    white-space: nowrap;
}

.wb-files li.wb-files-warn {
    color: var(--warning);
    border-color: var(--warning);
    font-size: 0.88em;
}

.wb-file-pick {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    padding: 9px 11px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.95rem;
}

.wb-file-pick:hover,
.wb-file-pick:focus-within {
    border-color: var(--accent-bright);
}

.wb-file-pick input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
}

/* ---- Actions ------------------------------------------------------------------------ */

.wb-actions-card {
    position: sticky;
    bottom: calc(10px * var(--space-scale));
    z-index: 4;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.35);
}

.wb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wb-actions .wb-primary {
    flex: 1 1 160px;
}

.wb-problems {
    margin: 0;
    padding: 10px 10px 10px 28px;
    color: var(--danger);
    font-size: 0.9em;
    border: 1px solid var(--danger);
    border-radius: calc(8px * var(--radius-scale));
    max-height: 9em;
    overflow-y: auto;
}

.wb-status {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.92em;
    color: var(--text-muted);
}

.wb-status[data-kind="ok"] {
    color: var(--success);
}

.wb-status[data-kind="err"] {
    color: var(--danger);
}

.wb-status span {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ---- Dialogs --------------------------------------------------------------------------- */

.wb-dialog {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    padding: 20px;
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    box-sizing: border-box;
}

.wb-dialog[open] {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wb-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.wb-dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
}

.wb-dialog-head h2 {
    margin: 0;
    font-size: 1.2em;
}

#wb-json-text {
    font-family: var(--font-mono), monospace;
    font-size: 0.85rem;
    min-height: 240px;
    flex: 1;
}

.wb-saved-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.wb-saved-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    padding: 8px 10px;
}

.wb-saved-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.wb-saved-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wb-saved-info small {
    color: var(--text-muted);
}

/* ---- Discord-style preview ------------------------------------------------------------ */

.dc-chat {
    background: #313338;
    color: #dbdee1;
    border-radius: calc(12px * var(--radius-scale));
    padding: 16px 16px 16px 0;
    font-family: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.375;
    overflow-wrap: anywhere;
    min-height: 120px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

@media (max-width: 900px) {
    .dc-chat {
        max-height: none;
    }
}

.dc-forum-title {
    font-size: 20px;
    font-weight: 700;
    color: #f2f3f5;
    padding: 0 0 12px 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid #3f4147;
}

.dc-forum-title i {
    color: #b5bac1;
    margin-right: 6px;
}

.dc-msg {
    display: flex;
    gap: 16px;
    padding-left: 16px;
}

.dc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex: none;
    object-fit: cover;
    background: #1e1f22;
}

.dc-body {
    flex: 1;
    min-width: 0;
}

.dc-head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.dc-name {
    color: #f2f3f5;
    font-weight: 500;
}

.dc-tag {
    background: #5865f2;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: calc(3px * var(--radius-scale));
    line-height: 15px;
    text-transform: uppercase;
}

.dc-time {
    color: #949ba4;
    font-size: 12px;
}

.dc-empty {
    color: #949ba4;
    font-style: italic;
}

.dc-content {
    white-space: normal;
}

.dc-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.dc-attach-img {
    max-width: min(400px, 100%);
    max-height: 300px;
    border-radius: calc(8px * var(--radius-scale));
}

.dc-attach-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: calc(8px * var(--radius-scale));
    padding: 12px 14px;
    max-width: 400px;
    min-width: 0;
}

.dc-attach-file i {
    font-size: 26px;
    color: #b5bac1;
}

.dc-attach-name {
    color: #00a8fc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dc-attach-size {
    color: #949ba4;
    font-size: 12px;
}

.dc-embed {
    display: flex;
    gap: 16px;
    background: #2b2d31;
    border-left: 4px solid #1e1f22;
    border-radius: calc(4px * var(--radius-scale));
    padding: 8px 16px 16px 12px;
    margin-top: 8px;
    max-width: 516px;
    box-sizing: border-box;
}

.dc-embed-inner {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
}

.dc-embed-author {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #f2f3f5;
}

.dc-embed-author a {
    color: #f2f3f5;
}

.dc-embed-author-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.dc-embed-title {
    font-weight: 600;
    color: #f2f3f5;
}

.dc-embed-title a {
    color: #00a8fc;
    text-decoration: none;
}

.dc-embed-title a:hover {
    text-decoration: underline;
}

.dc-embed-desc {
    font-size: 14px;
}

.dc-embed-fields {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 8px;
}

.dc-embed-field {
    min-width: 0;
    font-size: 14px;
}

.dc-field-name {
    font-weight: 600;
    color: #f2f3f5;
    margin-bottom: 2px;
}

.dc-embed-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: calc(4px * var(--radius-scale));
    align-self: flex-start;
}

.dc-embed-thumb {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: calc(4px * var(--radius-scale));
    flex: none;
    margin-top: 8px;
}

.dc-embed-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #b5bac1;
}

.dc-embed-footer-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.dc-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.dc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #4e5058;
    color: #fff;
    border-radius: calc(8px * var(--radius-scale));
    padding: 0 16px;
    min-height: 32px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.dc-btn:hover {
    background: #6d6f78;
}

.dc-btn .md-emoji {
    width: 18px;
    height: 18px;
}

/* Markdown inside the preview */

.md-p {
    min-height: 1.375em;
}

.md-h1,
.md-h2,
.md-h3 {
    font-weight: 700;
    color: #f2f3f5;
    line-height: 1.375;
    margin: 8px 0 4px;
}

.md-h1 { font-size: 1.5em; }
.md-h2 { font-size: 1.25em; }
.md-h3 { font-size: 1em; }

.md-sub {
    font-size: 0.8125em;
    color: #949ba4;
}

.md-list {
    margin: 4px 0;
    padding-left: 1.5em;
}

.md-quote {
    margin: 0;
    padding: 0 8px 0 12px;
    border-left: 4px solid #4e5058;
}

.md-code {
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: calc(4px * var(--radius-scale));
    padding: 0 3px;
    font-family: Consolas, "Andale Mono WT", "Liberation Mono", monospace;
    font-size: 0.85em;
}

.dc-embed .md-code,
.dc-embed .md-pre {
    background: #1e1f22;
}

.md-pre {
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: calc(4px * var(--radius-scale));
    padding: 8px;
    margin: 4px 0;
    white-space: pre-wrap;
    font-family: Consolas, "Andale Mono WT", "Liberation Mono", monospace;
    font-size: 0.875em;
    color: #dbdee1;
}

.md-link {
    color: #00a8fc;
    text-decoration: none;
}

.md-link:hover {
    text-decoration: underline;
}

.md-mention {
    background: rgba(88, 101, 242, 0.3);
    color: #c9cdfb;
    border-radius: calc(3px * var(--radius-scale));
    padding: 0 2px;
    font-weight: 500;
}

.md-timestamp {
    background: rgba(255, 255, 255, 0.06);
    border-radius: calc(3px * var(--radius-scale));
    padding: 0 2px;
}

.md-spoiler {
    background: #1e1f22;
    color: transparent;
    border-radius: calc(3px * var(--radius-scale));
    cursor: pointer;
}

.md-spoiler * {
    visibility: hidden;
}

.md-spoiler.shown {
    background: rgba(255, 255, 255, 0.1);
    color: inherit;
    cursor: auto;
}

.md-spoiler.shown * {
    visibility: visible;
}

.md-emoji {
    width: 1.375em;
    height: 1.375em;
    vertical-align: bottom;
    object-fit: contain;
}
