:root {
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #1e293b;
    background: #f4f7fb;
    line-height: 1.6;
    --page-gutter: 32px;
    --page-width: 1440px;
    --sidebar-width: 232px;
    --touch-size: 44px;
    --surface: #fff;
    --surface-subtle: #f8fafc;
    --surface-strong: #eef2ff;
    --border: #e5eaf2;
    --border-strong: #cbd5e1;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-dim: #596b82;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --primary-soft: #eff6ff;
    --success: #16704a;
    --success-soft: #eaf8f0;
    --warning: #946010;
    --warning-soft: #fff7e6;
    --danger: #b42332;
    --danger-soft: #fff0f1;
    --neutral: #64748b;
    --neutral-soft: #f0f3f7;
    --focus: #2563eb;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; }
body { min-width: 320px; margin: 0; background: #f4f7fb; font-size: 14px; }
button, input, select { font: inherit; }
button, a, summary, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
button, input, select { min-height: var(--touch-size); }
a { color: var(--primary); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1100; top: 8px; left: 8px; padding: 10px 16px; border-radius: 8px; color: #fff; background: var(--primary-strong); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.icon { display: inline-block; flex: 0 0 auto; vertical-align: middle; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(25px, 2.5vw, 32px); font-weight: 700; line-height: 1.35; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.5; letter-spacing: -.02em; }
h3 { font-size: 15px; }

.app-sidebar { position: fixed; z-index: 100; inset: 0 auto 0 0; display: flex; flex-direction: column; width: var(--sidebar-width); padding: 30px 18px 22px; color: #c7d3e6; background: #111d32; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; color: #fff; text-decoration: none; }
.brand-mark { display: grid; flex: 0 0 40px; width: 40px; height: 40px; place-items: center; border: 1px solid #4e80f4; border-radius: 12px; background: #2563eb; }
.brand-text { font-size: 17px; font-weight: 700; letter-spacing: -.035em; white-space: nowrap; }
.brand-text small { display: block; margin-top: 3px; color: #94a5bf; font-size: 10px; font-weight: 400; letter-spacing: .08em; }
.nav-caption { margin: 45px 15px 12px; color: #91a2bd; font-size: 11px; letter-spacing: .12em; }
.workspace-nav { display: flex; flex-direction: column; gap: 8px; }
.workspace-link { display: flex; align-items: center; gap: 13px; min-height: 48px; padding: 11px 16px; border-radius: 9px; color: #aebed6; text-decoration: none; font-size: 13px; font-weight: 500; transition: color .15s, background .15s; }
.workspace-link:hover { color: #fff; background: #1d2b43; }
.workspace-link.is-current { color: #fff; background: #2563eb; box-shadow: 0 4px 14px #07132740; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 18px 8px 0; border-top: 1px solid #2a374b; color: #bccbe0; font-size: 12px; }
.sidebar-footer small { display: block; margin-top: 3px; color: #91a2bd; font-size: 10px; }

.page-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; min-height: 144px; max-width: calc(var(--page-width) + 64px); margin-left: var(--sidebar-width); padding: 30px var(--page-gutter) 20px; }
.page-header-main { min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: 9px; margin: 0 0 12px; color: var(--text-muted); font-size: 11px; }
.breadcrumb span + span::before { content: "/"; margin-right: 9px; color: #b3bfd0; }
.eyebrow, .section-kicker { margin: 0 0 4px; color: var(--text-muted); font-size: 10px; font-weight: 600; letter-spacing: .13em; }
.subtitle { margin: 0; color: var(--text-muted); font-size: 13px; }
.header-status, .media-service-info { margin: 10px 0 0; color: var(--text-dim); font-size: 12px; overflow-wrap: anywhere; }
.header-status { max-width: 400px; margin: 0; padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.page-content { width: min(var(--page-width), calc(100% - var(--sidebar-width) - 64px)); margin: 8px 32px 48px calc(var(--sidebar-width) + 32px); }
.panel { min-width: 0; padding: 24px; margin-bottom: 24px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 3px 10px rgb(22 40 72 / 2%); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.panel-heading-actions, .row-actions, .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel-heading-actions { justify-content: flex-end; }
.count-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--text-dim); background: var(--surface-subtle); font-size: 12px; font-weight: 500; white-space: nowrap; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: var(--touch-size); padding: 10px 16px; border: 1px solid transparent; border-radius: 8px; color: #fff; background: var(--primary); font-weight: 600; font-size: 13px; line-height: 1.5; text-decoration: none; transition: background .15s, box-shadow .15s; }
.button:hover:not(:disabled) { background: var(--primary-strong); box-shadow: 0 3px 8px rgb(37 99 235 / 12%); }
.button-secondary { color: #475569; border-color: var(--border); background: #fff; }
.button-secondary:hover:not(:disabled) { color: var(--primary-strong); border-color: #c7d7fa; background: var(--primary-soft); box-shadow: none; }
.button-danger { color: var(--danger); border-color: #f2d4d9; background: #fff; }
.button-danger:hover:not(:disabled) { border-color: #f2bec7; background: var(--danger-soft); box-shadow: none; }
.button-small { min-height: 36px; padding: 6px 12px; font-size: 12px; }

.message { min-height: 0; margin-bottom: 16px; padding: 0; border-radius: 8px; font-size: 13px; }
.message:empty { margin: 0; }
.message:not(:empty) { padding: 11px 15px; border: 1px solid transparent; }
.message.success { color: var(--success); border-color: #d5edde; background: var(--success-soft); }
.message.warning { color: var(--warning); background: var(--warning-soft); }
.message.error { color: var(--danger); background: var(--danger-soft); }
.toast { position: fixed; z-index: 1000; top: 22px; left: 50%; width: max-content; max-width: min(560px, calc(100vw - 32px)); padding: 13px 20px; border: 1px solid transparent; border-radius: 10px; box-shadow: 0 10px 35px rgb(23 32 51 / 15%); opacity: 0; color: var(--success); background: var(--success-soft); font-size: 13px; font-weight: 600; pointer-events: none; transform: translate(-50%, -16px); transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { color: var(--danger); border-color: #f0caca; background: var(--danger-soft); }
.toast.warning { color: var(--warning); border-color: #ead19d; background: var(--warning-soft); }
.toast.success { border-color: #bde8cc; }
.state { padding: 36px 16px; color: var(--text-dim); text-align: center; font-size: 13px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 4px 9px; border-radius: 6px; font-size: 11px; font-weight: 600; line-height: 1.6; }
.status-ready, .status-on { color: var(--success); background: var(--success-soft); }
.status-warning { color: var(--warning); background: var(--warning-soft); }
.status-danger { color: var(--danger); background: var(--danger-soft); }
.status-muted, .status-off { color: var(--neutral); background: var(--neutral-soft); }
.status-pill::before { content: ""; flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

input, select { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid #dce3ed; border-radius: 8px; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: #78869a; }
input:focus, select:focus { border-color: #7fa4f4; box-shadow: 0 0 0 3px rgb(37 99 235 / 9%); }
input[readonly] { color: var(--text-muted); background: var(--surface-subtle); }
.hint { margin: 8px 0 0; color: var(--text-dim); font-size: 12px; line-height: 1.7; }
.page-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 0 3px; color: var(--text-muted); font-size: 11px; }

@media (min-width: 1737px) {
    .page-header { margin-left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width) - var(--page-width) - 64px) / 2); }
    .page-content { margin-left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width) - var(--page-width)) / 2); }
}
@media (max-width: 1100px) {
    :root { --page-gutter: 24px; }
    .app-sidebar { inset: auto 0 0; width: 100%; height: calc(68px + env(safe-area-inset-bottom)); padding: 5px 16px env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: #fff; box-shadow: 0 -4px 24px rgb(22 40 72 / 5%); }
    .brand, .nav-caption, .sidebar-footer { display: none; }
    .workspace-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); height: 100%; gap: 4px; }
    .workspace-link { flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; padding: 4px; border-radius: 8px; color: #64748b; font-size: 10px; }
    .workspace-link.is-current { color: var(--primary); background: var(--primary-soft); box-shadow: none; }
    .workspace-link:hover { color: var(--primary-strong); background: var(--primary-soft); }
    .page-header { max-width: none; min-height: 128px; margin-left: 0; padding: 24px 24px 18px; }
    .page-content { width: calc(100% - 48px); margin: 8px 24px calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
    html { scroll-padding-top: 16px; }
    :root { --page-gutter: 16px; }
    .page-header { flex-wrap: wrap; align-items: flex-start; gap: 14px; min-height: auto; padding: calc(20px + env(safe-area-inset-top)) 16px 18px; }
    .page-header-main { flex: 1 1 220px; }
    .page-header h1 { font-size: 26px; }
    .breadcrumb { margin-bottom: 9px; }
    .subtitle { font-size: 12px; }
    .header-status { max-width: none; width: 100%; font-size: 12px; }
    .page-content { width: calc(100% - 32px); margin: 0 16px calc(92px + env(safe-area-inset-bottom)); }
    .panel { padding: 18px 16px; margin-bottom: 16px; border-radius: 12px; }
    .panel-heading { align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
    .panel-heading-actions { justify-content: flex-start; }
    .button-small { min-height: var(--touch-size); }
    input, select { font-size: 16px; }
    .toast { top: max(16px, env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media (forced-colors: active) {
    .workspace-link.is-current, .status-pill, .button { border: 1px solid ButtonText; }
}
