/* ============================================
   ASM 在线实验平台 — Warm Terminal
   暖色暗色调 + 琥珀强调 + 工业精度
   ============================================ */

:root {
    --bg-base: #0f0e0c;
    --bg-surface: #161513;
    --bg-elevated: #1c1a17;
    --bg-hover: #24221e;
    --border: #2a2722;
    --border-active: #3d3830;
    --text-primary: #e4dfd4;
    --text-secondary: #8a857a;
    --text-muted: #55524a;
    --accent: #d4a34c;
    --accent-glow: #e8b85e;
    --accent-muted: #7a5e2e;
    --error: #d15b5b;
    --error-bg: #261a1a;
    --success: #5e9e74;
    --info: #5e8aae;
    --font-ui: "DM Sans", -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    --font-code: "JetBrains Mono", "Fira Code", "SF Mono", "Consolas", "Courier New", monospace;
    --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
    --radius: 6px;
    --radius-sm: 3px;
    --transition: 180ms ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- grain texture ---- */
.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 99999;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- header ---- */
header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.header-inner {
    max-width: 100%;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    user-select: none;
}

.logo-text {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.logo-text h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1;
}

.logo-dot {
    color: var(--accent);
}

.logo-text .subtitle {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

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

.meta-badge {
    font-size: 11px;
    font-family: var(--font-code);
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.meta-sep {
    color: var(--text-muted);
    font-size: 12px;
}

/* ---- header nav ---- */
.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    margin-right: 16px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-icon {
    width: 16px;
    height: 16px;
}

.nav-label {
    line-height: 1;
}

/* ---- main layout ---- */
.main {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ---- editor panel ---- */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- toolbar ---- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
}

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

/* ---- run button ---- */
.btn-run {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #1a1410;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    position: relative;
}

.btn-run:hover {
    background: var(--accent-glow);
    box-shadow: 0 0 20px rgba(212, 163, 76, 0.2);
}

.btn-run:active {
    transform: scale(0.97);
}

.btn-run:disabled {
    background: var(--accent-muted);
    color: rgba(26, 20, 16, 0.5);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-run .btn-icon {
    font-size: 11px;
}

.btn-run .btn-label {
    line-height: 1;
}

.btn-run .btn-hint {
    font-size: 10px;
    font-family: var(--font-code);
    color: rgba(26, 20, 16, 0.4);
    margin-left: 2px;
}

.btn-run:disabled .btn-hint {
    opacity: 0.3;
}

/* ---- select ---- */
.select-wrap {
    position: relative;
}

.select {
    appearance: none;
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font-ui);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
    min-width: 140px;
}

.select:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
}

.select:focus {
    outline: none;
    border-color: var(--accent);
}

.select-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

/* ---- status ---- */
.status {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color var(--transition);
}

.status.running {
    color: var(--info);
}

.status.success {
    color: var(--success);
}

.status.error {
    color: var(--error);
}

/* ---- CodeMirror ---- */
#editor-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

#editor-container .CodeMirror {
    height: 100%;
    font-family: var(--font-code);
    font-size: 13.5px;
    line-height: 1.6;
    background: var(--bg-base);
    color: var(--text-primary);
}

/* CodeMirror theme overrides */
.CodeMirror-gutters {
    background: var(--bg-base) !important;
    border-right: 1px solid var(--border) !important;
}

.CodeMirror-linenumber {
    color: var(--text-muted) !important;
}

.CodeMirror-cursor {
    border-left-color: var(--accent) !important;
}

.CodeMirror-selected {
    background: rgba(212, 163, 76, 0.15) !important;
}

.CodeMirror-focused .CodeMirror-selected {
    background: rgba(212, 163, 76, 0.22) !important;
}

/* override material theme syntax colors */
.cm-s-material .cm-keyword { color: #c9906b !important; }
.cm-s-material .cm-variable-2 { color: #b0a080 !important; }
.cm-s-material .cm-def { color: #6b90a8 !important; }
.cm-s-material .cm-comment { color: #55524a !important; font-style: italic; }
.cm-s-material .cm-number { color: #9ea86b !important; }
.cm-s-material .cm-string { color: #8b9e6b !important; }
.cm-s-material .cm-variable { color: #c8c0b8 !important; }

.CodeMirror-activeline-background {
    background: rgba(255, 255, 255, 0.02) !important;
}

.CodeMirror-matchingbracket {
    color: var(--accent) !important;
    text-shadow: 0 0 4px rgba(212, 163, 76, 0.4);
}

/* ---- input area ---- */
.input-area {
    padding: 10px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.input-header label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.input-area textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-base);
    resize: none;
    transition: border-color var(--transition);
    line-height: 1.5;
}

.input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.input-area textarea::placeholder {
    color: var(--text-muted);
}

/* ---- output panel ---- */
.output-panel {
    width: 420px;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.output-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.output-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px rgba(94, 158, 116, 0.4);
}

.output-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(212, 163, 76, 0.03) 0%, transparent 70%),
        var(--bg-base);
}

/* custom scrollbar */
.output-body::-webkit-scrollbar {
    width: 5px;
}

.output-body::-webkit-scrollbar-track {
    background: transparent;
}

.output-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.output-body::-webkit-scrollbar-thumb:hover {
    background: var(--border-active);
}

.CodeMirror-vscrollbar::-webkit-scrollbar {
    width: 5px;
}

.CodeMirror-vscrollbar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

#output {
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.55;
    color: #c8b078;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    min-height: 100%;
}

#output:empty::before {
    content: "准备就绪 — 点击运行或按 Ctrl+Enter";
    color: var(--text-muted);
    font-style: italic;
}

#output.error-text {
    color: var(--error);
}

#output .warning {
    color: var(--accent);
}

/* ---- clear button ---- */
.btn-clear {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-clear:hover {
    border-color: var(--border-active);
    color: var(--text-secondary);
    background: var(--bg-hover);
}

/* ---- responsive ---- */
@media (max-width: 800px) {
    .main {
        flex-direction: column;
    }

    .output-panel {
        width: 100%;
        max-height: 240px;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .header-inner {
        padding: 10px 14px;
    }

    .logo-icon {
        font-size: 22px;
    }

    .logo-text h1 {
        font-size: 18px;
    }

    .logo-text .subtitle {
        display: none;
    }

    .toolbar {
        padding: 8px 12px;
        flex-wrap: wrap;
    }

    .btn-run .btn-hint {
        display: none;
    }

    .nav-label {
        display: none;
    }
}

@media (max-width: 500px) {
    .header-meta {
        display: none;
    }
}
