:root {
    --bg-primary: #ffffff;
    --bg-soft: #fff7f7;
    --bg-card: #ffffff;
    --bg-muted: #fff0f1;
    --bg-tinted: #fde8eb;

    --accent-primary: #dc1e34;
    --accent-strong: #b41326;
    --accent-soft: #ff8b95;
    --accent-glow: rgba(220, 30, 52, 0.22);
    --accent-warm: #f59e0b;

    --text-primary: #1a1a1f;
    --text-secondary: #4a4a52;
    --text-muted: #71717a;

    --border-subtle: rgba(220, 30, 52, 0.14);
    --border-strong: rgba(220, 30, 52, 0.42);
    --border-line: rgba(0, 0, 0, 0.06);

    --success: #10b981;
    --danger: #b91c1c;

    --shadow-soft: 0 6px 22px -10px rgba(220, 30, 52, 0.18),
                   0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-strong: 0 14px 40px -16px rgba(220, 30, 52, 0.30),
                     0 4px 12px -6px rgba(0, 0, 0, 0.08);

    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial,
        sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    font-family: var(--font-stack);
    background: var(--bg-primary);
    overflow-x: hidden;
}

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

a:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

button {
    font-family: inherit;
}

/* ---- Background: layered red mist on a light canvas ---- */

.haze-stage {
    position: relative;
    z-index: 0;
    min-height: 100vh;
}

.haze-stage::before,
.haze-stage::after {
    content: "";
    position: fixed;
    inset: -10vmin;
    z-index: -2;
    pointer-events: none;
}

.haze-stage::before {
    background:
        radial-gradient(60vmin 40vmin at 12% 18%, rgba(255, 87, 100, 0.22), transparent 70%),
        radial-gradient(70vmin 50vmin at 88% 8%, rgba(220, 30, 52, 0.16), transparent 72%),
        radial-gradient(80vmin 60vmin at 70% 95%, rgba(255, 139, 149, 0.18), transparent 70%),
        radial-gradient(60vmin 40vmin at 8% 90%, rgba(220, 30, 52, 0.10), transparent 70%),
        linear-gradient(180deg, #ffffff 0%, #fff7f7 60%, #fde8eb 100%);
}

.haze-stage::after {
    background-image:
        linear-gradient(rgba(220, 30, 52, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(220, 30, 52, 0.07) 1px, transparent 1px);
    background-size: 56px 56px;
    background-position: -1px -1px;
    mask-image: radial-gradient(ellipse at center, #000 35%, transparent 78%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 35%, transparent 78%);
    z-index: -1;
}

#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.55;
}

/* ---- App shell ---- */

.app-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 36px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 14px -4px var(--accent-glow);
    overflow: hidden;
    background: #fff;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    display: block;
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--text-primary);
}

.brand-name .brand-en {
    color: var(--accent-primary);
    margin-left: 8px;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 1.4px;
}

.app-meta {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.45);
    margin-right: 6px;
    display: inline-block;
}

/* ---- Hero / page intro ---- */

.hero {
    padding: 36px 36px 12px;
    text-align: center;
}

.hero h1 {
    margin: 0 0 8px;
    font-size: 32px;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.hero h1 .accent {
    color: var(--accent-primary);
}

.hero p {
    margin: 0 auto;
    max-width: 720px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

.hero .pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--bg-tinted);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    margin-bottom: 16px;
    border: 1px solid var(--border-subtle);
}

/* ---- Compact chip-row nav (live subsystems only) ---- */

.chip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 18px auto 0;
    max-width: 880px;
}

.chip-row[hidden] {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 12px;
    border-radius: 999px;
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    font-size: 12.5px;
    line-height: 1;
    text-decoration: none;
    transition: all 0.12s;
    box-shadow: 0 1px 2px rgba(220, 30, 52, 0.05);
}

.chip:hover {
    border-color: var(--border-strong);
    color: var(--accent-strong);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -4px var(--accent-glow);
    text-decoration: none;
}

.chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.55);
}

.chip-label {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.chip-zh {
    color: var(--text-muted);
    font-size: 11.5px;
}

/* ---- Main login card ---- */

.app-main {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12px 20px 40px;
}

.portal-stack {
    width: 100%;
    max-width: 1080px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.login-card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-line);
    border-radius: 16px;
    box-shadow: var(--shadow-strong);
    overflow: hidden;
}

.card-title {
    padding: 22px 28px 12px;
    border-bottom: 1px solid var(--border-line);
}

.card-title h2 {
    margin: 0 0 4px;
    font-size: 18px;
    color: var(--text-primary);
    letter-spacing: 0.4px;
}

.card-title p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 10px 18px 0;
    border-bottom: 1px solid var(--border-line);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex-shrink: 0;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 12px 14px;
    cursor: pointer;
    font-size: 13px;
    letter-spacing: 0.4px;
    position: relative;
    transition: color 0.15s;
}

.tab-btn[aria-selected="true"] {
    color: var(--accent-primary);
    font-weight: 600;
}

.tab-btn[aria-selected="true"]::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 2px;
    background: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-glow);
    border-radius: 2px;
}

.tab-panel {
    display: none;
    padding: 24px 28px 28px;
}

.tab-panel.active {
    display: block;
    animation: fade-in 0.18s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.form-row {
    margin-bottom: 14px;
}

.form-row label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.form-row input {
    width: 100%;
    padding: 11px 14px;
    background: #fff;
    border: 1px solid var(--border-line);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.12s, box-shadow 0.12s;
    font-family: inherit;
}

.form-row input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    gap: 12px;
}

.btn {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-strong) 100%);
    color: #ffffff;
    font-weight: 700;
    border: none;
    padding: 11px 22px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    letter-spacing: 0.5px;
    box-shadow: 0 6px 16px -6px var(--accent-glow);
    transition: transform 0.08s, box-shadow 0.12s, filter 0.1s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -8px var(--accent-glow);
    filter: brightness(1.04);
}

.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--border-strong);
    box-shadow: none;
}

.btn-secondary:hover {
    background: var(--bg-tinted);
}

.note {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

.subform-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.subform-toggle button {
    flex: 1;
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border-line);
    border-radius: 7px;
    padding: 8px 0;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.12s;
}

.subform-toggle button[aria-pressed="true"] {
    background: var(--bg-tinted);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    font-weight: 600;
}

.alert {
    padding: 9px 14px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}

.alert.error {
    display: block;
    border: 1px solid rgba(185, 28, 28, 0.3);
    background: rgba(185, 28, 28, 0.06);
    color: var(--danger);
}

.alert.ok {
    display: block;
    border: 1px solid rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.06);
    color: var(--success);
}

/* ---- Subsystem grid (RedHaze ID/CMS/Chat/Mall/...) ---- */

.subsystem-card {
    background: var(--bg-card);
    border: 1px solid var(--border-line);
    border-radius: 16px;
    padding: 22px 26px;
    box-shadow: var(--shadow-soft);
}

.subsystem-card .section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-header h3 {
    margin: 0;
    font-size: 16px;
    letter-spacing: 0.4px;
    color: var(--text-primary);
}

.section-header .section-sub {
    color: var(--text-muted);
    font-size: 12px;
}

.subsystem-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.subsystem {
    border: 1px solid var(--border-line);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
    position: relative;
    transition: border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}

.subsystem:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.subsystem .name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 14px;
}

.subsystem .zh {
    color: var(--text-secondary);
    font-size: 12px;
}

.subsystem .desc {
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.6;
}

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 1px solid var(--border-subtle);
}

.tag.live {
    background: var(--bg-tinted);
    color: var(--accent-strong);
    border-color: var(--border-strong);
}

.tag.planned {
    background: #fafafa;
    color: var(--text-muted);
}

.tag.preview {
    background: #fff7ed;
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.4);
}

/* ---- Workspace (post-login pages) ---- */

.workspace {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.workspace .container {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 28px 60px;
}

.workspace h1 {
    font-size: 22px;
    letter-spacing: 0.5px;
    margin: 0 0 6px;
    color: var(--text-primary);
}

.workspace .subtitle {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 13px;
}

.workspace .panel {
    background: var(--bg-card);
    border: 1px solid var(--border-line);
    border-radius: 14px;
    padding: 20px 22px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-soft);
}

.workspace table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.workspace th,
.workspace td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-line);
}

.workspace th {
    color: var(--accent-primary);
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    font-size: 11px;
}

.workspace .pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid var(--border-subtle);
    color: var(--accent-primary);
    background: var(--bg-tinted);
}

.workspace .actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.workspace .search-box {
    display: flex;
    gap: 8px;
}

.workspace .search-box input {
    flex: 1;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid var(--border-line);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
}

/* ---- Footer ---- */

.app-footer {
    padding: 18px 36px;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.4px;
    border-top: 1px solid var(--border-line);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
}

.app-footer .footer-brand {
    color: var(--accent-strong);
    font-weight: 600;
}

/* ---- RedHaze CMS / BBS ---- */

.identity-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--bg-tinted);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-subtle);
}

.identity-badge.anonymous {
    background: #f5f5f5;
    color: var(--text-muted);
    border-color: rgba(0, 0, 0, 0.08);
}

.identity-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.identity-badge.anonymous::before {
    background: var(--text-muted);
}

.cms-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.cms-toolbar .spacer {
    flex: 1;
}

.section-card {
    border: 1px solid var(--border-line);
    border-radius: 12px;
    padding: 16px 18px;
    background: #ffffff;
    transition: all 0.12s;
    text-decoration: none;
    color: var(--text-primary);
    display: block;
}

.section-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
    text-decoration: none;
}

.section-card .title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-card .summary {
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.6;
}

.cms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.post-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 16px;
    border: 1px solid var(--border-line);
    border-radius: 12px;
    background: #ffffff;
    transition: all 0.12s;
    text-decoration: none;
    color: var(--text-primary);
}

.post-row:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-soft);
    text-decoration: none;
}

.post-row .meta {
    flex: 1;
    min-width: 0;
}

.post-row .post-title {
    font-weight: 700;
    font-size: 14.5px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.post-row .post-sub {
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.post-row .post-status {
    flex-shrink: 0;
}

.status-pill {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border-subtle);
    color: var(--accent-strong);
    background: var(--bg-tinted);
}

.status-pill.pending {
    background: #fff7ed;
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.4);
}

.status-pill.rejected {
    background: #f5f5f5;
    color: var(--text-muted);
    border-color: rgba(0, 0, 0, 0.08);
}

.cms-post-body {
    padding: 6px 4px 16px;
    line-height: 1.8;
    font-size: 14.5px;
    color: var(--text-primary);
}

.cms-post-body p {
    margin: 0 0 12px;
}

.cms-post-body code {
    background: var(--bg-tinted);
    color: var(--accent-strong);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.9em;
}

.cms-post-body pre {
    background: var(--bg-tinted);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 10px 14px;
    overflow-x: auto;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comment {
    border: 1px solid var(--border-line);
    border-radius: 10px;
    padding: 10px 14px;
    background: #ffffff;
}

.comment .author-line {
    color: var(--accent-strong);
    font-weight: 600;
    font-size: 12.5px;
    margin-bottom: 4px;
}

.comment .body {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.6;
}

.compose-card textarea {
    width: 100%;
    min-height: 220px;
    padding: 12px 14px;
    border: 1px solid var(--border-line);
    border-radius: 10px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
}

.compose-card textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.compose-card select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-line);
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
}

.callout {
    padding: 10px 14px;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    background: var(--bg-tinted);
    color: var(--accent-strong);
    font-size: 12.5px;
    margin-bottom: 14px;
    line-height: 1.6;
}

.callout.muted {
    border-style: solid;
    border-color: var(--border-line);
    background: #fafafa;
    color: var(--text-secondary);
}
