:root {
    color-scheme: dark;
    --bg: #0d0d12;
    --panel: #17171f;
    --panel-soft: #1d1d27;
    --line: #30303d;
    --line-soft: #262630;
    --muted: #9d9cab;
    --text: #f5f5f8;
    --accent: #9146ff;
    --accent-hover: #a970ff;
    --green: #3ba55c;
    --yellow: #d6a849;
    --red: #ed4245;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, ui-sans-serif, system-ui, sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.topbar { height: 72px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); background: rgba(13,13,18,.9); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #6331ad); font-weight: 850; }
.current-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.user-copy { display: flex; flex-direction: column; min-width: 110px; }
.user-copy strong { font-size: 14px; line-height: 1.25; }
.user-copy span { color: var(--muted); font-size: 12px; }
.logout-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; color: var(--muted); background: transparent; }
.logout-button:hover { color: var(--text); background: var(--panel-soft); }
.logout-button svg { width: 18px; fill: currentColor; }

main { width: min(1180px, calc(100% - 40px)); margin: 42px auto 110px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { margin: 2px 0 4px; font-size: clamp(30px, 4vw, 42px); letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0 0 4px !important; color: #b98cff !important; font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.quick-actions { display: flex; gap: 9px; }
.quick-actions form { margin: 0; }

.button { border: 0; border-radius: 9px; padding: 10px 15px; color: white; font-weight: 700; }
.button.primary { background: var(--accent); }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { border: 1px solid var(--line); background: var(--panel-soft); }
.button.secondary:hover { border-color: #4b4a5c; background: #252531; }

.notice { margin-bottom: 16px; padding: 12px 15px; border: 1px solid; border-radius: 10px; }
.notice.success { color: #b8ecc8; border-color: #285f39; background: #142c1c; }
.notice.error { color: #ffc2c2; border-color: #733237; background: #32181b; }
.notice.warning { color: #f1d79e; border-color: #695527; background: #302816; }
code { padding: 2px 5px; border-radius: 5px; color: #d7c2ff; background: #29243a; }

.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 34px; }
.status-card { min-width: 0; display: flex; gap: 14px; padding: 18px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--panel); }
.service-icon, .service-avatar { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; object-fit: cover; display: grid; place-items: center; font-size: 18px; font-weight: 900; }
.service-icon.small, .service-avatar.small { width: 36px; height: 36px; border-radius: 9px; font-size: 15px; }
.twitch-icon { color: white; background: #9146ff; }
.discord-icon { color: white; background: #5865f2; }
.live-dot { flex: 0 0 auto; width: 12px; height: 12px; margin: 14px; border-radius: 50%; background: #5d5c69; box-shadow: 0 0 0 5px #292832; }
.live-dot.active { background: var(--red); box-shadow: 0 0 0 5px #482326; }
.status-content { min-width: 0; flex: 1; }
.status-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-title h2 { margin: 0; font-size: 16px; }
.status-content p { overflow: hidden; margin: 3px 0 1px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.status-content small { display: block; overflow: hidden; color: #6f6e7b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.status-error { color: #ff8d8f !important; }
.status-badge { flex: 0 0 auto; padding: 3px 7px; border-radius: 20px; color: #bbb9c5; background: #2a2933; font-size: 10px; font-weight: 750; }
.status-badge.ok { color: #b8ecc8; background: #1b3b26; }
.status-badge.pending { color: #f3d69a; background: #3a301c; }
.status-badge.live { color: #ffc2c2; background: #482326; }

.settings-form { display: block; }
.card { border: 1px solid var(--line-soft); border-radius: 16px; background: var(--panel); }
.activation-card { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px; margin-bottom: 44px; }
.activation-card h2 { margin: 2px 0; font-size: 20px; }
.activation-card p { margin: 0; color: var(--muted); }
.activation-control { display: flex; align-items: center; gap: 12px; }
.activation-state { min-width: 132px; color: var(--muted); font-size: 13px; text-align: right; }
.activation-state.active { color: #86d99f; }
.activation-state.pending { color: #f3d69a; }
.switch { display: block; flex: 0 0 auto; }
.switch input { display: none; }
.switch span { display: block; position: relative; width: 52px; height: 29px; border-radius: 30px; background: #3d3c48; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 21px; height: 21px; border-radius: 50%; background: white; transition: .2s; }
.switch input[type="checkbox"]:checked ~ .switch-track { background: var(--accent); }
.switch input[type="checkbox"]:checked ~ .switch-track::after { transform: translateX(23px); }

.section-block { margin: 0 0 52px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 15px; }
.section-heading h2 { margin: 1px 0 0; font-size: 25px; letter-spacing: -.02em; }
.section-heading > p { max-width: 390px; margin: 0; color: var(--muted); text-align: right; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.config-card { overflow: hidden; padding: 0; }
.config-card summary { list-style: none; cursor: pointer; }
.config-card summary::-webkit-details-marker { display: none; }
.card-heading { display: flex; align-items: center; gap: 11px; padding: 18px 20px; }
.config-card[open] .card-heading { border-bottom: 1px solid var(--line-soft); }
.card-heading h3 { margin: 0; font-size: 17px; }
.card-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.connection-summary { min-width: 0; flex: 1; }
.connection-summary p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: var(--muted); font-size: 20px; transition: transform .2s; }
.config-card[open] .chevron { transform: rotate(180deg); }
.config-body { padding: 2px 22px 22px; }
.connection-detail { margin-top: 12px; padding: 8px 10px; border-radius: 7px; color: var(--muted); background: #121219; font-size: 11px; }
.connection-detail.error { color: #ff9b9d; background: #32181b; }
.permission-list { margin-top: 12px; padding: 10px 12px; border: 1px solid #6f3439; border-radius: 8px; color: #ffc0c2; background: #2c171a; font-size: 11px; }
.permission-list ul { margin: 5px 0 0; padding-left: 18px; }

label { display: block; margin: 16px 0 0; color: #e4e3e9; font-size: 13px; font-weight: 650; }
input, textarea, select { display: block; width: 100%; margin-top: 7px; padding: 10px 11px; border: 1px solid #383744; border-radius: 8px; outline: none; color: var(--text); background: #101016; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(145,70,255,.12); }
textarea { resize: vertical; }
input[type="color"] { height: 42px; padding: 4px; }
label small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 400; }
label small.resolved-name { color: #86d99f; font-weight: 650; }
.optional { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.compact { grid-template-columns: 110px 1fr; }
.checkbox { display: flex; align-items: center; gap: 9px; }
.checkbox input { width: auto; margin: 0; accent-color: var(--accent); }

.bot-profile-card { display: grid; grid-template-columns: 210px 1fr; gap: 28px; padding: 26px; }
.avatar-editor { display: flex; flex-direction: column; align-items: center; padding: 10px; border-right: 1px solid var(--line-soft); }
.avatar-editor img, .avatar-fallback { width: 108px; height: 108px; margin-bottom: 15px; border-radius: 50%; object-fit: cover; }
.avatar-fallback { display: grid; place-items: center; color: white; background: linear-gradient(135deg, var(--accent), #5865f2); font-size: 38px; font-weight: 850; }
.file-button { margin: 0; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); cursor: pointer; }
.file-button:hover { border-color: #565464; }
.file-button input { display: none; }
.avatar-editor small { margin-top: 8px; color: var(--muted); text-align: center; font-size: 10px; }
.profile-fields > label { margin-top: 0; }
.presence-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 16px; }
.presence-group { padding: 15px; border: 1px solid var(--line-soft); border-radius: 11px; background: #13131a; }
.presence-group h4 { margin: 0 0 5px; }

.embed-studio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(390px, .9fr); gap: 18px; align-items: start; }
.embed-fields { padding: 22px; }
.embed-fields hr { margin: 24px 0; border: 0; border-top: 1px solid var(--line-soft); }
.embed-fields h3 { margin: 0; }
.mode-tabs { display: flex; gap: 4px; width: max-content; padding: 4px; border-radius: 9px; background: #101016; }
.mode-tab { padding: 7px 11px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-weight: 650; }
.mode-tab.active { color: var(--text); background: #2a2934; }
.variables { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.variables span { margin-right: 3px; color: var(--muted); font-size: 11px; }
.variables code { font-size: 11px; }
.theme-note { margin: 13px 0 0; padding: 9px 10px; border-radius: 8px; color: var(--muted); background: #121219; font-size: 11px; }

.discord-preview-wrap { position: sticky; top: 94px; }
.preview-label { margin: 0 0 8px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.discord-preview { overflow: hidden; border: 1px solid #35363c; border-radius: 13px; color: #dbdee1; background: #313338; font-family: "gg sans", Inter, sans-serif; box-shadow: 0 18px 45px rgba(0,0,0,.28); }
.discord-channel { padding: 13px 16px; border-bottom: 1px solid #26272d; font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.discord-channel span { margin-right: 7px; color: #949ba4; font-size: 20px; }
.discord-message { display: flex; gap: 12px; padding: 20px 16px 24px; }
.discord-message > img, .message-avatar { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.message-avatar.fallback { display: grid; place-items: center; background: var(--accent); color: white; font-weight: 800; }
.message-body { min-width: 0; flex: 1; }
.message-meta { display: flex; align-items: center; gap: 5px; }
.message-meta strong { color: #f2f3f5; }
.message-meta > span:last-child { color: #949ba4; font-size: 11px; }
.app-badge { padding: 0 4px; border-radius: 3px; color: white; background: #5865f2; font-size: 9px; }
.mention-preview { height: 21px; color: #c9cdfb; }
.discord-embed { overflow: hidden; max-width: 410px; margin-top: 3px; padding: 13px 14px 11px; border-left: 4px solid var(--accent); border-radius: 4px; background: #2b2d31; }
.embed-author { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: #f2f3f5; font-size: 12px; font-weight: 650; }
.author-dot { width: 18px; height: 18px; border-radius: 50%; background: #9146ff; }
.author-avatar { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }
.embed-title { color: #00a8fc; font-weight: 700; }
.embed-description { margin-top: 7px; color: #dbdee1; font-size: 13px; white-space: normal; }
.embed-fields-preview { display: flex; gap: 34px; margin-top: 12px; }
.embed-fields-preview[hidden] { display: none; }
.embed-fields-preview div { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.embed-fields-preview strong { color: #f2f3f5; }
.embed-fields-preview span { color: #dbdee1; }
.embed-image { display: block; width: 100%; min-height: 150px; max-height: 220px; margin-top: 12px; border-radius: 4px; object-fit: cover; background: linear-gradient(135deg, #372658, #181820); }
.embed-image[hidden] { display: none; }
.embed-image.image-unavailable { min-height: 190px; }
.embed-footer { margin-top: 8px; color: #b5bac1; font-size: 11px; }
.embed-time { margin-top: 8px; color: #b5bac1; font-size: 10px; }
.discord-link-button { margin-top: 8px; padding: 8px 13px; border: 0; border-radius: 4px; color: white; background: #4e5058; font-weight: 650; }

.savebar { position: sticky; bottom: 16px; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 16px; border: 1px solid #444250; border-radius: 12px; background: rgba(29,29,39,.94); backdrop-filter: blur(15px); box-shadow: 0 14px 35px rgba(0,0,0,.4); }
.savebar[hidden] { display: none; }
.savebar div { display: flex; flex-direction: column; }
.savebar span { color: var(--muted); font-size: 11px; }

@media (max-width: 900px) {
    .status-grid { grid-template-columns: 1fr; }
    .two-columns, .embed-studio { grid-template-columns: 1fr; }
    .discord-preview-wrap { position: static; }
    .section-heading > p { display: none; }
}

@media (max-width: 640px) {
    main { width: min(100% - 24px, 1180px); margin-top: 26px; }
    .topbar { padding: 0 14px; }
    .user-copy { display: none; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .quick-actions { width: 100%; }
    .quick-actions form, .quick-actions button { flex: 1; width: 100%; }
    .field-row, .presence-grid { grid-template-columns: 1fr; }
    .bot-profile-card { grid-template-columns: 1fr; }
    .activation-card { align-items: flex-start; gap: 16px; }
    .activation-control { flex-direction: column-reverse; align-items: flex-end; }
    .activation-state { min-width: 0; }
    .avatar-editor { border-right: 0; border-bottom: 1px solid var(--line-soft); padding-bottom: 22px; }
    .savebar div { display: none; }
    .savebar { justify-content: flex-end; }
}
