:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  --surface: #0f1722;
  --canvas: #080d13;
  --sidebar: #080d13;
  --accent: #ff6a1a;
  --ink: #f7f8fa;
  --line: #344458;
  --muted: #aab4c2;
  --soft: #182536;
}
* { box-sizing: border-box; }
body { margin: 0; }
/* Safari owns the safe viewport; only the active tool and sidebar scroll. */
.workbench-document { height: 100%; overflow: hidden; }
.workbench-page { height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior-y: none; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-size: 18px; font-weight: 650; letter-spacing: .5px; }
.brand-logo { display: block; width: 52px; height: 38px; flex: 0 0 52px; object-fit: contain; filter: none; }
.brand-logo, .mobile-brand { box-sizing: border-box; padding: 4px; border-radius: 8px; background: #080d13; }
.brand small { display: block; margin-top: 4px; color: #aab4c2; font-size: 9px; letter-spacing: 2px; font-weight: 400; }
.quiet-link, .quiet-button { color: var(--muted); font-size: 12px; white-space: nowrap; }
.quiet-link:hover, .quiet-button:hover, .header-link:hover { color: var(--ink); }
.quiet-button { border: 0; padding: 6px 0; background: none; }
.quiet-button span { font-size: 18px; vertical-align: -1px; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 10px 17px; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: #080d13; font-weight: 600; }
.primary-button:hover { background: #ff833e; }
.secondary-button { background: var(--surface); color: var(--ink); }
.secondary-button:hover { background: var(--soft); }
.form-error { color: #ff8b82; font-size: 13px; line-height: 1.65; }
.login-page { min-height: 100vh; min-height: 100dvh; background: var(--canvas); }
.login-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 23px 40px; background: var(--sidebar); }
.login-header .quiet-link { color: #aab4c2; font-size: 13px; }
.login-header .quiet-link:hover { color: var(--ink); }
.login-main { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - 84px); min-height: calc(100dvh - 84px); padding: 28px 20px 70px; }
.login-card { width: 100%; max-width: 420px; border: 1px solid var(--line); border-radius: 12px; padding: 36px; background: var(--surface); }
.login-eyebrow { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.login-card h1 { font-size: 27px; line-height: 1.4; letter-spacing: -.6px; font-weight: 650; }
.login-intro { margin-top: 10px; color: var(--muted); font-size: 13px; line-height: 1.7; }
#login-form { margin-top: 28px; }
#login-form label { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 550; }
.password-field { display: flex; border: 1px solid #45556b; border-radius: 7px; background: var(--surface); }
.password-field:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px #0000000b; }
.password-field input { flex: 1; width: 0; min-width: 0; height: 46px; padding: 11px 13px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 16px; }
.password-field input:focus { outline: none; }
.password-field input::placeholder { color: #aab4c2; font-size: 14px; }
.password-toggle { border: 0; border-radius: 0 7px 7px 0; padding: 0 13px; background: transparent; color: var(--muted); font-size: 12px; }
.password-toggle:hover { color: var(--ink); }
#login-error { margin-top: 10px; }
#login-submit { width: 100%; margin-top: 21px; min-height: 46px; }
.login-note { display: flex; align-items: flex-start; gap: 7px; border-top: 1px solid var(--line); margin-top: 27px; padding-top: 20px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.login-note svg { flex-shrink: 0; margin-top: 1px; }
.login-footer { margin-top: 24px; color: #aab4c2; font-size: 10px; letter-spacing: 1.5px; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 10; border-radius: 6px; padding: 12px 16px; background: var(--surface); color: var(--ink); }
.skip-link:focus { top: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.workbench-shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); height: 100vh; height: 100dvh; min-height: 320px; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow-y: auto; padding: 23px 12px 18px; border-right: 1px solid var(--line); background: var(--sidebar); }
.sidebar-brand { padding: 0 3px; gap: 8px; font-size: 17px; letter-spacing: 0; }
.sidebar-caption { margin: 30px 12px 10px; color: var(--muted); font-size: 11px; }
.section-nav { display: flex; flex-direction: column; gap: 7px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 48px; border: 1px solid transparent; border-radius: 8px; padding: 11px 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.nav-item svg { flex: 0 0 19px; width: 19px; height: 19px; }
.nav-item:hover { background: #182536; color: var(--ink); }
.nav-item.is-active { background: var(--surface); border-color: var(--line); color: var(--accent); font-weight: 600; }
.sidebar-footer { display: flex; align-items: center; gap: 7px; margin: auto 12px 0; padding-top: 24px; color: var(--muted); font-size: 11px; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.workspace-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.workspace-header { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; flex: 0 0 64px; min-height: 64px; gap: 16px; border-bottom: 1px solid var(--line); padding: 8px 24px; background: var(--surface); }
.workspace-heading { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.heading-copy { min-width: 0; }
.workspace-heading h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 18px; line-height: 1.45; font-weight: 700; letter-spacing: -.3px; }
.frame-status { overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.6; text-overflow: ellipsis; white-space: nowrap; }
.mobile-brand { display: none; object-fit: contain; flex: 0 0 28px; filter: none; }
.workspace-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 5px; }
.layout-button, .header-tool, .workspace-menu > summary { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; min-width: 44px; padding: 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); white-space: nowrap; cursor: pointer; font-size: 12px; }
.layout-button svg, .header-tool svg, .workspace-menu > summary svg { width: 18px; height: 18px; flex: 0 0 18px; }
.layout-button[aria-pressed="true"] { background: var(--soft); border-color: var(--line); color: var(--accent); }
.layout-button:hover, .header-tool:hover, .workspace-menu > summary:hover { background: var(--soft); color: var(--ink); }
.workspace-menu { position: relative; }
.workspace-menu > summary { list-style: none; }
.workspace-menu > summary::-webkit-details-marker { display: none; }
.workspace-menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.workspace-menu-panel { position: absolute; right: 0; top: calc(100% + 8px); display: grid; min-width: 172px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 10px 30px #00000066; }
.workspace-menu-panel a, .workspace-menu-panel button { display: flex; align-items: center; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; }
.workspace-menu-panel a:hover, .workspace-menu-panel button:hover { background: var(--soft); }
.workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; padding: 0; }
.management-nav { display: flex; align-items: center; flex: 0 0 auto; gap: 24px; border-bottom: 1px solid var(--line); padding: 0 24px; background: var(--surface); overflow-x: auto; }
.management-nav a { display: block; flex: 0 0 auto; min-height: 48px; padding: 14px 2px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; }
.management-nav a[aria-current="page"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.frame-region { position: relative; display: flex; flex: 1; min-height: 0; min-width: 0; overflow: hidden; border: 0; border-radius: 0; background: var(--canvas); }
#tool-frame { display: block; width: 100%; height: 100%; min-height: 100%; border: 0; background: var(--surface); }
.frame-message { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; padding: 30px; background: var(--surface); text-align: center; }
.frame-message h2 { font-size: 16px; font-weight: 550; }
.frame-message p { max-width: 370px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.frame-message .secondary-button { margin-top: 8px; }
.loading-spinner { width: 23px; height: 23px; margin-bottom: 7px; border: 2px solid #344458; border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
.workbench-error { flex-shrink: 0; padding: 10px 16px; color: #ff8b82; font-size: 12px; line-height: 1.7; }
@keyframes spin { to { transform: rotate(360deg); } }
body[data-resolved-layout="ipad"] .workbench-shell { grid-template-columns: 88px minmax(0, 1fr); }
body[data-resolved-layout="ipad"] .sidebar { padding: 18px 7px; }
body[data-resolved-layout="ipad"] .sidebar-brand { justify-content: center; padding: 0; }
body[data-resolved-layout="ipad"] .brand-label, body[data-resolved-layout="ipad"] .sidebar-caption, body[data-resolved-layout="ipad"] .sidebar-footer { display: none; }
body[data-resolved-layout="ipad"] .section-nav { margin-top: 24px; gap: 8px; }
body[data-resolved-layout="ipad"] .nav-item { flex-direction: column; justify-content: center; gap: 6px; min-height: 76px; padding: 10px 4px; text-align: center; font-size: 11px; }
body[data-resolved-layout="ipad"] .nav-item span { max-width: 65px; }
body[data-resolved-layout="ipad"] .workspace-header { padding-inline: 20px; }
@media (max-width: 640px), (max-width: 1024px) and (max-height: 500px) and (pointer: coarse) {
  .workbench-shell, body[data-resolved-layout="ipad"] .workbench-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 64px 48px minmax(0, 1fr); min-height: 0; }
  .workspace-column { display: contents; }
  .workspace-header, body[data-resolved-layout="ipad"] .workspace-header { grid-row: 1; grid-column: 1; min-width: 0; height: 64px; padding: 8px 12px; gap: 8px; }
  .sidebar, body[data-resolved-layout="ipad"] .sidebar { grid-row: 2; grid-column: 1; flex-direction: row; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); overflow: hidden; }
  .sidebar-brand, .sidebar-caption, .sidebar-footer { display: none; }
  .section-nav, body[data-resolved-layout="ipad"] .section-nav { flex: 1; flex-direction: row; align-items: stretch; gap: 0; margin: 0; padding: 0 8px; overflow-x: auto; overscroll-behavior-x: contain; }
  .nav-item, body[data-resolved-layout="ipad"] .nav-item { flex: 1 0 auto; flex-direction: row; gap: 6px; justify-content: center; min-height: 47px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 11px 8px; white-space: nowrap; font-size: 11px; }
  body[data-resolved-layout="ipad"] .nav-item span { max-width: none; }
  .nav-item svg { display: none; }
  .nav-item.is-active { border-bottom-color: var(--accent); background: var(--soft); }
  .mobile-brand { display: block; }
  .workspace-heading { gap: 7px; }
  .workspace-heading h1 { font-size: 15px; }
  .frame-status { font-size: 10px; }
  .workspace-actions { gap: 1px; }
  #ipad-layout-button, #layout-auto-button { display: none; }
  .layout-button { gap: 5px; padding-inline: 8px; font-size: 11px; }
  .layout-button svg { display: none; }
  .workspace { grid-row: 3; grid-column: 1; }
  .management-nav { padding: 0 16px; gap: 24px; }
  .management-nav a { min-width: 44px; text-align: center; }
  .workspace-menu-panel { max-width: min(260px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))); }
}
@media (max-width: 440px) {
  .login-header { padding: 21px 22px; }
  .login-header .brand { font-size: 16px; }
  .login-header .quiet-link { font-size: 12px; }
  .login-main { justify-content: flex-start; padding: 54px 20px 45px; }
  .login-card { padding: 28px 25px; }
  .login-card h1 { font-size: 25px; }
  .workspace-header, body[data-resolved-layout="ipad"] .workspace-header { padding-inline: 8px; gap: 5px; }
  .workspace-heading { gap: 5px; }
  .mobile-brand { width: 24px; height: 24px; flex-basis: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
