:root {
    --bg: #070b12;
    --bg-2: #0c121c;
    --panel: rgba(16, 24, 36, 0.86);
    --panel-solid: #101824;
    --line: rgba(154, 196, 224, 0.12);
    --line-strong: rgba(62, 224, 200, 0.28);
    --text: #f3f7fb;
    --muted: #8b9cb0;
    --faint: #66788c;
    --accent: #3ee0c8;
    --accent-2: #7aa8ff;
    --ok: #5ee4a4;
    --warn: #ffb45a;
    --danger: #ff7a6b;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    --radius: 22px;
    --font: "Segoe UI Variable", "PingFang SC", "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    background: #070b12;
    color: #f3f7fb;
}

body {
    background:
        radial-gradient(1200px 520px at 12% -10%, rgba(62, 224, 200, 0.14), transparent 46%),
        radial-gradient(900px 480px at 100% 0%, rgba(122, 168, 255, 0.12), transparent 42%),
        var(--bg);
    color: var(--text);
    font-family: var(--font);
}

a {
    color: var(--accent);
    text-decoration: none;
}

code {
    color: var(--accent);
}

button,
.btn {
    font-family: inherit;
}

input,
.editor {
    font-family: 'Noto Sans SC', -apple-system, sans-serif;
}

button,
.btn {
    display: inline-block;
    height: 40px;
    line-height: 38px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

button:hover,
.btn:hover {
    border-color: rgba(62, 224, 200, 0.35);
    background: rgba(62, 224, 200, 0.08);
}

button:active,
.btn:active {
    transform: translateY(1px);
}

.primary,
.loginBox .primary {
    background: linear-gradient(180deg, #4af0d6, #21c8b0);
    border-color: transparent;
    color: #04221d;
    font-weight: 700;
}

.primary:hover,
.btn.primary:hover {
    background: linear-gradient(180deg, #67f6df, #2ad4bb);
    border-color: transparent;
}

.wide {
    width: 100%;
    height: 46px;
    line-height: 44px;
    font-size: 15px;
}

.softBtn {
    background: rgba(255, 255, 255, 0.04);
}

.dangerBtn {
    color: #ffd0ca;
}

.ghostBtn {
    height: 36px;
    line-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: transparent;
}

.fileInput {
    display: none;
}

.page {
    min-height: 100%;
}

.authScreen,
.loginPage {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.authCard,
.loginBox {
    width: 100%;
    max-width: 440px;
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(18, 28, 42, 0.92), rgba(10, 16, 26, 0.92));
    box-shadow: var(--shadow);
}

.installCard {
    max-width: 560px;
}

.authMark,
.logoMark {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    color: var(--accent);
    background: rgba(62, 224, 200, 0.1);
    border: 1px solid rgba(62, 224, 200, 0.18);
    margin-bottom: 18px;
}

.authTitle,
.loginTitle {
    margin: 0 0 8px;
    font-size: 28px;
    letter-spacing: -0.03em;
}

.authHint,
.loginHint,
.authError,
.loginError {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.authError,
.loginError {
    color: var(--warn);
}

.field {
    display: block;
    margin-bottom: 14px;
}

.field span,
.authCard label span,
.loginBox label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
}

.field input,
.passwordInput,
.loginBox input,
.newProject input,
.passwordBar input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(7, 11, 18, 0.72);
    color: var(--text);
    outline: 0;
    padding: 0 14px;
    font-size: 15px;
}

.field input:focus,
.passwordInput:focus,
.newProject input:focus,
.passwordBar input:focus,
.editor:focus {
    border-color: rgba(62, 224, 200, 0.45);
    box-shadow: 0 0 0 4px rgba(62, 224, 200, 0.08);
}

.fieldGrid {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 12px;
}

.installLinks {
    display: flex;
    gap: 10px;
}

.installLinks .btn,
.installLinks .primary {
    flex: 1;
    width: auto;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.03);
}

.status:before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--faint);
}

.status.ok {
    color: var(--ok);
    border-color: rgba(94, 228, 164, 0.22);
}

.status.ok:before {
    background: var(--ok);
    box-shadow: 0 0 0 4px rgba(94, 228, 164, 0.14);
}

.status.warn {
    color: var(--warn);
    border-color: rgba(255, 180, 90, 0.24);
}

.status.warn:before {
    background: var(--warn);
}

.consoleApp {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.appBar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 12, 20, 0.72);
    backdrop-filter: blur(16px);
}

.brandBlock,
.appBarMeta,
.topbar,
.consoleTop {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logoMark {
    width: 42px;
    height: 42px;
    margin: 0;
    border-radius: 14px;
}

.brandName {
    font-size: 16px;
    font-weight: 700;
}

.brandSub,
.meta,
.cardHint {
    color: var(--muted);
    font-size: 12px;
}

.currentChip {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
}

.currentChip span {
    color: var(--muted);
    font-size: 12px;
}

.currentChip strong,
.projectName {
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    word-break: break-word;
}

.consoleBody {
    flex: 1;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    border-right: 1px solid var(--line);
    background: rgba(9, 14, 22, 0.78);
}

.sideLabel,
.cardLabel,
.title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sideLabel {
    margin-bottom: 4px;
}

.sideHint {
    color: var(--faint);
    font-size: 12px;
    margin-bottom: 10px;
}

.newProject {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.newProject input {
    height: 40px;
    flex: 1;
    min-width: 0;
}

.newProject button {
    height: 40px;
    line-height: 38px;
}

.projectList {
    flex: 1;
    overflow: auto;
}

.projectItem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--text);
    background: transparent;
}

.projectItem:hover {
    background: rgba(255, 255, 255, 0.04);
}

.projectItem.active {
    background: rgba(62, 224, 200, 0.1);
    border-color: rgba(62, 224, 200, 0.22);
}

.projectAvatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(122, 168, 255, 0.14);
    color: #c9d8ff;
    font-size: 13px;
    font-weight: 700;
}

.projectItem.active .projectAvatar {
    background: rgba(62, 224, 200, 0.18);
    color: var(--accent);
}

.sideFoot {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
}

.sideLink {
    display: block;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

.sideLink small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.workspace {
    min-width: 0;
    padding: 20px;
    overflow: auto;
}

.stageGrid {
    display: grid;
    grid-template-columns: 0.92fr 1.08fr;
    gap: 16px;
    margin-bottom: 16px;
}

.screenCard,
.composerCard,
.historyCard,
.secretCard,
.previewCard {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.14);
}

.cardHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.cardHeadLeft {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.fontSizeTitle,
.fontSizeLabel {
    color: var(--muted);
    font-size: 12px;
}

.fontSizeLabel {
    min-width: 42px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.fontSizeBtn {
    min-width: 36px;
    height: 28px;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 26px;
    background: rgba(255, 255, 255, 0.04);
}

.fontSizeBtn.active {
    background: rgba(102, 255, 217, 0.16);
    color: #66ffd9;
    border-color: rgba(102, 255, 217, 0.35);
}

.fontSizeRange {
    width: 110px;
    height: 22px;
    margin: 0;
    vertical-align: middle;
}

.liveDot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--danger);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.liveDot:before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 0 rgba(255, 122, 107, 0.7);
    animation: livePulse 1.6s infinite;
}

@keyframes livePulse {
    70% {
        box-shadow: 0 0 0 8px rgba(255, 122, 107, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 122, 107, 0);
    }
}

.bezel {
    padding: 10px;
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 30%),
        #070b12;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.previewBoard {
    min-height: 280px;
    max-height: 360px;
    padding: 28px;
    font-size: 32px;
    line-height: 1.7;
    border: 0;
    border-radius: 22px;
    background: rgba(8, 12, 20, 0.55);
}

.emojiBar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.emojiBar button {
    min-width: 36px;
    height: 36px;
    line-height: 34px;
    padding: 0;
    border-radius: 10px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.03);
}

.editor {
    min-height: 170px;
    max-height: 260px;
    overflow: auto;
    outline: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(7, 11, 18, 0.72);
    color: var(--text);
    font-family: 'Noto Sans SC', -apple-system, sans-serif;
    font-size: 20px;
    line-height: 1.7;
    word-break: break-word;
    white-space: pre-wrap;
    margin-bottom: 12px;
}

.editor:empty:before {
    content: attr(data-placeholder);
    color: var(--faint);
}

.editor img,
.historyBody img,
.viewerContent img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 8px 0;
    border-radius: 12px;
}

.emojiBar button img.emoji {
    width: 22px;
    height: 22px;
    display: block;
    margin: 6px auto 0;
    border: 0;
    border-radius: 0;
}

.editor img.emoji,
.viewerContent img.emoji,
.historyBody img.emoji,
.historyItem img.emoji {
    display: inline-block !important;
    width: 1.15em !important;
    height: 1.15em !important;
    max-width: none !important;
    margin: 0 0.06em !important;
    border: 0 !important;
    border-radius: 0 !important;
    vertical-align: -0.18em !important;
}

.composerActions,
.passwordBar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.sendBtn,
.composerActions .primary {
    width: auto;
    margin-left: auto;
    height: 42px;
    line-height: 40px;
    padding: 0 22px;
    border-radius: 14px;
}

.passwordBar input {
    max-width: 220px;
}

.historyList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    max-height: 280px;
    overflow: auto;
}

.historyItem {
    display: block;
    width: 100%;
    height: auto;
    line-height: 1.5;
    text-align: left;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(7, 11, 18, 0.72);
}

.historyTime {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.historyBody {
    display: block;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.historyList:has(.emptyHint) {
    display: block;
}

.secretCard {
    margin-top: 16px;
}

.secretCard summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    list-style: none;
}

.secretCard summary::-webkit-details-marker {
    display: none;
}

.secretCard[open] .passwordBar {
    margin-top: 12px;
}

.operatorBar {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.operatorBar input {
    width: 100%;
    max-width: 360px;
    height: 44px;
    margin: 8px 8px 8px 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(7, 11, 18, 0.72);
    color: var(--text);
    padding: 0 14px;
}

.historyAdmin {
    margin-top: 12px;
}

.historyFold summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 10px;
}

.historyMore {
    max-height: 220px;
}

.historyAdminBar {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.ctxMenu {
    position: fixed;
    z-index: 40;
    min-width: 160px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #121a26;
    box-shadow: var(--shadow);
}

.ctxMenu button {
    display: block;
    width: 100%;
    height: 36px;
    line-height: 34px;
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: 10px;
}

.ctxMenu button:hover {
    background: rgba(62, 224, 200, 0.1);
}

.ctxMenu button:disabled {
    color: var(--faint);
    cursor: not-allowed;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 8, 14, 0.62);
}

.overlay[hidden],
.ctxMenu[hidden],
.historyAdmin[hidden] {
    display: none !important;
}

.dialog {
    width: 100%;
    max-width: 380px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #101824;
    box-shadow: var(--shadow);
}

.dialog h3 {
    margin: 0 0 14px;
    font-size: 18px;
}

.dialog input {
    width: 100%;
    height: 44px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(7, 11, 18, 0.72);
    color: var(--text);
    padding: 0 14px;
}

.dialogActions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.clockApp,
.viewerApp {
    min-height: 100%;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-direction: column;
    flex-direction: column;
    padding: 28px;
}

.clockFace {
    text-align: center;
    padding: 18px 0 8px;
}

.clockTime {
    color: var(--accent);
    font: 700 96px/1 "Bahnschrift", "Segoe UI Variable Display", Consolas, "Courier New", monospace;
    letter-spacing: 0.08em;
    text-shadow: 0 0 40px rgba(62, 224, 200, 0.22);
}

.clockDate {
    margin-top: 10px;
    color: #b7c7d8;
    font-size: 20px;
    letter-spacing: 0.12em;
}

.topbar {
    min-height: 52px;
    margin: 8px 0 18px;
    justify-content: space-between;
}

.clockApp .projectName,
.viewerApp .projectName {
    font-size: 28px;
    margin-top: 4px;
}

.boardWrap {
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    min-height: 180px;
    padding: 6px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
}

.viewerContent {
    height: 100%;
    min-height: 180px;
    overflow: auto;
    border: 0;
    border-radius: 22px;
    background: rgba(8, 12, 20, 0.55);
    color: var(--text);
    padding: 28px;
    font: 32px/1.7 var(--font);
    word-break: break-word;
    white-space: pre-wrap;
}

.viewerContent:empty:before,
.viewerContent.is-missing:before {
    content: none;
}

.emptyState {
    color: #8b9cb0;
    font-size: 18px;
    line-height: 1.7;
}

.emptyTitle {
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.viewerContent img.emoji {
    display: inline-block !important;
    width: 1.15em !important;
    height: 1.15em !important;
    max-width: none !important;
    margin: 0 0.06em !important;
    border: 0 !important;
    vertical-align: -0.18em !important;
}

.viewerContent a {
    color: var(--accent);
}

.embedBody,
.embedApp,
.embedBoard {
    background: #070b12;
}

.embedApp {
    padding: 0;
    min-height: 100%;
}

.embedBoard {
    height: 100%;
    min-height: 120px;
    padding: 0;
    border: 0;
    border-radius: 0;
}

.embedBody .viewerContent {
    background: #070b12;
    border-radius: 0;
    padding: 8px 4px;
    font-size: 32px;
}

@media (max-width: 1100px) {
    .consoleBody,
    .stageGrid,
    .fieldGrid {
        display: block;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .previewBoard {
        min-height: 180px;
    }
}

@media (max-width: 860px) {
    .appBar,
    .appBarMeta,
    .brandBlock,
    .topbar,
    .composerActions,
    .passwordBar,
    .installLinks {
        display: flex;
        flex-wrap: wrap;
    }

    .clockTime {
        font-size: 48px;
    }

    .clockApp .projectName,
    .viewerApp .projectName {
        font-size: 24px;
    }

    .sendBtn,
    .composerActions .primary,
    .passwordBar input,
    .installLinks .btn,
    .installLinks .primary {
        width: 100%;
        max-width: none;
        margin-left: 0;
    }

    .authCard,
    .loginBox,
    .workspace,
    .clockApp,
    .viewerApp {
        padding: 16px;
    }
}
