:root {
    --porcelain: #f3f7f6;
    --paper: #ffffff;
    --ink: #173632;
    --muted: #637b77;
    --line: #cbd9d6;
    --teal: #08796d;
    --teal-dark: #075c54;
    --signal: #da6a35;
    --danger: #ad3a35;
    --shadow: 0 18px 60px rgba(20, 54, 50, .10);
    font-family: "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background: var(--porcelain);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--porcelain); }
a { color: inherit; }
button, input { font: inherit; }
button, input, a { outline-offset: 3px; }
:focus-visible { outline: 3px solid rgba(8, 121, 109, .45); }
.eyebrow, .section-mark { margin: 0; color: var(--teal); font: 700 .7rem/1.4 "IBM Plex Mono", Consolas, monospace; letter-spacing: .16em; }
.muted, .footnote { color: var(--muted); }

.login-page { display: grid; place-items: center; padding: 4vw; background: radial-gradient(circle at 20% 20%, #dcece8 0, transparent 32%), var(--porcelain); }
.login-shell { width: min(960px, 100%); min-height: 590px; display: grid; grid-template-columns: 1.15fr .85fr; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.identity-panel { padding: clamp(2.5rem, 6vw, 5.5rem); display: flex; flex-direction: column; justify-content: space-between; background: var(--ink); color: #f7fbfa; }
.identity-panel .eyebrow { color: #75cfc3; }
.identity-panel h1 { margin: 1.6rem 0; font-size: clamp(3rem, 7vw, 5.4rem); font-weight: 760; line-height: .96; letter-spacing: -.06em; }
.identity-note { max-width: 25rem; color: #b7ceca; line-height: 1.8; }
.four-trace { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr auto; align-items: center; gap: .7rem; font: 600 .72rem "IBM Plex Mono", Consolas, monospace; color: #dceae7; }
.four-trace i { height: 1px; background: #59827b; position: relative; }
.four-trace i::after { content: ""; position: absolute; right: 32%; top: -4px; width: 7px; height: 7px; border: 1px solid #79d5c9; transform: rotate(45deg); background: var(--ink); }
.login-panel { padding: clamp(2.2rem, 5vw, 4.5rem); display: flex; flex-direction: column; justify-content: center; gap: 2rem; }
.login-panel h2 { margin: .5rem 0; font-size: 2rem; letter-spacing: -.035em; }
.login-panel p { line-height: 1.6; }
.login-form { display: grid; gap: .7rem; }
.login-form label { margin-top: .7rem; font-weight: 650; font-size: .9rem; }
.login-form input { width: 100%; border: 1px solid var(--line); background: #fbfdfc; padding: .9rem 1rem; color: var(--ink); }
.login-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 121, 109, .1); }
.login-form button { border: 0; margin-top: 1rem; padding: 1rem; color: white; background: var(--teal); font-weight: 700; cursor: pointer; }
.login-form button:hover { background: var(--teal-dark); }
.notice { padding: .8rem 1rem; border-left: 3px solid; font-size: .9rem; }
.notice.error { border-color: var(--danger); background: #fff1f0; color: #7c2824; }
.notice.success { border-color: var(--teal); background: #edf8f5; }
.footnote { margin: 0; font-size: .78rem; }

.topbar { min-height: 72px; display: flex; align-items: center; gap: 2rem; padding: 0 max(1.2rem, calc((100vw - 1280px) / 2)); background: var(--ink); color: white; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; white-space: nowrap; }
.brand b { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #75cfc3; color: #75cfc3; font: 800 .78rem "IBM Plex Mono", Consolas, monospace; }
.brand span { font-weight: 720; }
.topbar nav { align-self: stretch; display: flex; align-items: stretch; gap: 1.5rem; margin-left: auto; }
.topbar nav a { display: flex; align-items: center; border-bottom: 3px solid transparent; text-decoration: none; color: #b9ceca; font-size: .9rem; }
.topbar nav a:hover, .topbar nav a.active { color: white; border-bottom-color: #75cfc3; }
.quiet-button { border: 1px solid #52736d; background: transparent; color: white; padding: .55rem .85rem; cursor: pointer; }
.workspace { width: min(1280px, calc(100% - 2.4rem)); margin: 0 auto; padding: 3rem 0 5rem; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2rem; }
.page-heading h1 { margin: .35rem 0 0; font-size: clamp(2.2rem, 4vw, 3.5rem); letter-spacing: -.055em; }
.mode-label { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .86rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 5px rgba(8, 121, 109, .12); }
.instrument-rack { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow); }
.instrument-rack article { min-width: 0; padding: 1.5rem; border-right: 1px solid var(--line); position: relative; }
.instrument-rack article:last-child { border-right: 0; }
.instrument-rack article::before { content: ""; position: absolute; left: 1.5rem; top: 0; width: 44px; height: 3px; background: var(--teal); }
.instrument-rack article.alert-cell::before { background: var(--danger); }
.instrument-rack span, .instrument-rack small { display: block; color: var(--muted); }
.instrument-rack span { font-size: .78rem; font-weight: 700; }
.instrument-rack strong { display: block; margin: .65rem 0 .25rem; font: 750 2.35rem/1 "IBM Plex Mono", Consolas, monospace; letter-spacing: -.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.instrument-rack strong.version { font-size: 1.1rem; letter-spacing: -.025em; margin-top: 1.15rem; }
.instrument-rack small { font-size: .72rem; }
.work-section { margin-top: 2rem; padding: clamp(1.2rem, 3vw, 2rem); background: var(--paper); border: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: .3rem 0 0; font-size: 1.4rem; }
.section-heading > p { color: var(--muted); font-size: .8rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { padding: 1rem .8rem; color: var(--muted); text-align: left; font-size: .72rem; letter-spacing: .05em; }
td { padding: 1rem .8rem; border-top: 1px solid #e1e9e7; }
.mono { font-family: "IBM Plex Mono", Consolas, monospace; font-size: .8rem; }
.status-pill { display: inline-block; padding: .25rem .5rem; background: #e8f5f2; color: var(--teal-dark); font: 700 .7rem "IBM Plex Mono", Consolas, monospace; }
.status-pill.failed { background: #fff0ee; color: var(--danger); }
.empty-state { padding: 4rem 1rem; text-align: center; }
.empty-wave { font-size: 3.2rem; color: var(--teal); }
.empty-state h3 { margin: .5rem 0; }
.empty-state p { color: var(--muted); }
.split-workspace { display: grid; grid-template-columns: 1.15fr .85fr; gap: 2rem; }
.split-workspace .work-section { margin-top: 0; }
.stack-form { display: grid; gap: .7rem; margin-top: 1.5rem; }
.stack-form label { margin-top: .5rem; font-weight: 700; font-size: .86rem; }
.stack-form select, .stack-form input { width: 100%; border: 1px solid var(--line); background: #fbfdfc; padding: .8rem; color: var(--ink); }
.stack-form fieldset { margin: .7rem 0; padding: 1rem; border: 1px solid var(--line); }
.stack-form legend { padding: 0 .4rem; font-weight: 700; font-size: .86rem; }
.stack-form .check-row { display: flex; align-items: center; gap: .7rem; margin: .6rem 0; font-weight: 500; }
.stack-form .check-row input { width: auto; }
.check-row span { display: flex; flex-direction: column; }
.check-row small { margin-top: .2rem; color: var(--muted); }
.primary-button, .secondary-button, .danger-button, .text-button { display: inline-block; border: 0; padding: .85rem 1rem; text-decoration: none; font-weight: 700; cursor: pointer; }
.primary-button { color: white; background: var(--teal); }
.secondary-button { color: var(--ink); background: #e5eeec; }
.text-button { padding: .35rem 0; color: var(--teal-dark); background: transparent; }
.danger-button { color: #fff; background: #a63b2b; }
.confirmation-key { display: block; margin: 1rem 0; padding: 1rem; border-left: 3px solid var(--orange); background: #fff7f0; font-size: 1.15rem; }
.danger-text { color: var(--danger); }
.token-reveal { margin-bottom: 2rem; padding: 1.2rem; border: 2px solid var(--signal); background: #fff8f1; }
.token-reveal strong, .token-reveal code { display: block; }
.token-reveal code { margin: .8rem 0; padding: .8rem; overflow-wrap: anywhere; background: white; border: 1px solid #efd1bc; font-size: .95rem; }
.token-reveal p { margin: 0; color: #805032; font-size: .82rem; }
.download-list { display: grid; margin-top: 1.5rem; border-top: 1px solid var(--line); }
.download-list a { display: grid; grid-template-columns: 4rem 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.download-list a:hover strong { color: var(--teal); }
.download-list span { color: var(--muted); font-size: .82rem; }
.inline-form { display: inline; }
.horizontal-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 1rem; margin-top: 1.5rem; }
.horizontal-form label { display: grid; gap: .45rem; font-size: .82rem; font-weight: 700; }
.horizontal-form input { min-width: 0; border: 1px solid var(--line); background: #fbfdfc; padding: .8rem; color: var(--ink); }
.row-note { display: block; margin-top: .4rem; color: var(--muted); font-size: .7rem; }
.empty-state.compact { padding: 2rem 1rem; }
.narrow-workspace { max-width: 820px; }
.preview-grid { display: grid; grid-template-columns: repeat(2, 1fr); margin: 2rem 0; border: 1px solid var(--line); }
.preview-grid div { padding: 1.2rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.preview-grid dt { color: var(--muted); font-size: .75rem; }
.preview-grid dd { margin: .45rem 0 0; font-size: 1.4rem; font-weight: 750; }
.action-row { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; }

@media (max-width: 820px) {
    .login-page { padding: 0; place-items: stretch; }
    .login-shell { min-height: 100vh; grid-template-columns: 1fr; }
    .identity-panel { min-height: 310px; padding: 2rem; }
    .identity-panel h1 { font-size: 3.6rem; }
    .login-panel { padding: 2rem; }
    .topbar { flex-wrap: wrap; gap: 1rem; padding: 1rem 1.2rem 0; }
    .topbar nav { order: 3; width: 100%; overflow-x: auto; margin: 0; gap: 1.3rem; }
    .topbar nav a { padding: .8rem 0; white-space: nowrap; }
    .workspace { padding-top: 2rem; }
    .split-workspace { grid-template-columns: 1fr; }
    .horizontal-form { grid-template-columns: 1fr; align-items: stretch; }
    .instrument-rack { grid-template-columns: 1fr 1fr; }
    .instrument-rack article:nth-child(2) { border-right: 0; }
    .instrument-rack article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 500px) {
    .page-heading, .section-heading { align-items: start; flex-direction: column; }
    .instrument-rack { grid-template-columns: 1fr; }
    .instrument-rack article { border-right: 0; border-bottom: 1px solid var(--line); }
    .instrument-rack article:last-child { border-bottom: 0; }
    .four-trace { gap: .4rem; font-size: .62rem; }
    .preview-grid { grid-template-columns: 1fr; }
    .action-row { align-items: stretch; flex-direction: column-reverse; }
    .action-row a, .action-row button { width: 100%; text-align: center; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
