/* Aeris Design System 2.0 + V3 Unified Visual Foundation
 * Canonical semantic tokens and shared component states for Web and Android parity.
 */
:root {
  color-scheme: light;

  /* Typography */
  --ds-font-sans: "Segoe UI Variable", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  --ds-font-serif: Georgia, "Times New Roman", "Songti SC", serif;
  --ds-font-mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --ds-text-xs: 0.75rem;
  --ds-text-sm: 0.875rem;
  --ds-text-md: 1rem;
  --ds-text-lg: 1.125rem;
  --ds-text-xl: 1.375rem;
  --ds-text-2xl: 1.875rem;
  --ds-text-display: 3.5rem;
  --ds-leading-tight: 1.18;
  --ds-leading-body: 1.6;

  /* Four-pixel spacing scale */
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 20px;
  --ds-space-6: 24px;
  --ds-space-8: 32px;
  --ds-space-10: 40px;
  --ds-space-12: 48px;
  --ds-space-16: 64px;
  --ds-space-20: 80px;

  /* Shape and elevation */
  --ds-radius-xs: 4px;
  --ds-radius-sm: 6px;
  --ds-radius-md: 8px;
  --ds-radius-lg: 12px;
  --ds-radius-pill: 999px;
  --ds-border-width: 1px;
  --ds-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.055);
  --ds-shadow-raised: 0 14px 36px rgba(15, 23, 42, 0.1);
  --ds-shadow-dialog: 0 28px 72px rgba(15, 23, 42, 0.2);
  --ds-overlay: rgba(15, 23, 42, 0.52);
  --ds-overlay-soft: rgba(15, 23, 42, 0.42);
  --ds-hover: rgba(15, 23, 42, 0.055);
  --ds-skeleton: #e8edf3;
  --ds-skeleton-shine: rgba(255, 255, 255, 0.62);

  /* Motion */
  --ds-duration-instant: 80ms;
  --ds-duration-fast: 140ms;
  --ds-duration-normal: 200ms;
  --ds-duration-slow: 260ms;
  --ds-duration-pressed: var(--ds-duration-instant);
  --ds-duration-expand: var(--ds-duration-normal);
  --ds-duration-page: 220ms;
  --ds-duration-sheet: 280ms;
  --ds-pressed-scale: 0.985;
  --ds-pressed-opacity: 0.92;
  --ds-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ds-ease-emphasized: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Layout and touch */
  --ds-container-reading: 760px;
  --ds-container-default: 1200px;
  --ds-container-wide: 1440px;
  --ds-touch-min: 44px;
  --ds-skip-link-offset: var(--ds-space-3);
  --ds-z-skip: 1000;
  --ds-icon-sm: 16px;
  --ds-icon-md: 20px;
  --ds-icon-lg: 24px;

  /* Product workspace surfaces */
  --ds-workspace-canvas: #f4f6f9;
  --ds-workspace-canvas-warm: #f4f6f9;
  --ds-surface: #ffffff;
  --ds-surface-subtle: #f8fafc;
  --ds-surface-raised: #ffffff;
  --ds-surface-disabled: #e9edf2;
  --ds-text: #18212f;
  --ds-text-secondary: #475569;
  --ds-text-muted: #5b687a;
  --ds-text-disabled: #526174;
  --ds-border: #d8dee7;
  --ds-border-strong: #b9c4d0;

  /* Brand and semantic color */
  --ds-brand: #2563eb;
  --ds-brand-hover: #1d4ed8;
  --ds-brand-pressed: #1e40af;
  --ds-brand-soft: #edf4ff;
  --ds-on-brand: #ffffff;
  --ds-success: #147a46;
  --ds-success-soft: #eaf8f0;
  --ds-warning: #9a5708;
  --ds-warning-soft: #fff5de;
  --ds-error: #c23333;
  --ds-on-error: #ffffff;
  --ds-error-hover: #a92424;
  --ds-error-soft: #fff0f0;
  --ds-info: #1f5fbf;
  --ds-info-soft: #edf4ff;
  --ds-focus: #1d4ed8;
  --ds-focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.28);

  /* Public brand stage */
  --ds-stage: #f4f6f9;
  --ds-stage-surface: #ffffff;
  --ds-stage-surface-raised: #eef2f7;
  --ds-stage-text: #0f172a;
  --ds-stage-text-secondary: #475569;
  --ds-stage-border: #e2e8f0;
  --ds-stage-brand: #2563eb;
  --ds-stage-action: #2563eb;
  --ds-stage-on-action: #ffffff;
  --ds-stage-action-hover: #1d4ed8;

  /* Dark palette values are declared once and assigned below. */
  --ds-dark-workspace-canvas: #0f1217;
  --ds-dark-workspace-canvas-warm: #0f1217;
  --ds-dark-surface: #171c24;
  --ds-dark-surface-subtle: #22262d;
  --ds-dark-surface-raised: #272b33;
  --ds-dark-surface-disabled: #2c3139;
  --ds-dark-text: #f4f6f8;
  --ds-dark-text-secondary: #cbd2dc;
  --ds-dark-text-muted: #aeb8c6;
  --ds-dark-text-disabled: #98a4b4;
  --ds-dark-border: #363d48;
  --ds-dark-border-strong: #515b69;
  --ds-dark-brand: #78a6ff;
  --ds-dark-brand-hover: #9abcff;
  --ds-dark-brand-pressed: #5e91f5;
  --ds-dark-brand-soft: #1d3157;
  --ds-dark-on-brand: #08101f;
  --ds-dark-success: #6fd7a0;
  --ds-dark-success-soft: #173c2a;
  --ds-dark-warning: #f2c572;
  --ds-dark-warning-soft: #49351b;
  --ds-dark-error: #ff9b9b;
  --ds-dark-error-hover: #ffb3b3;
  --ds-dark-error-soft: #4c2528;
  --ds-dark-info: #91b7ff;
  --ds-dark-info-soft: #21365e;
  --ds-dark-focus: #9abcff;

  /* Compatibility aliases used by existing modules. */
  --color-background: var(--ds-workspace-canvas);
  --color-surface: var(--ds-surface);
  --color-surface-subtle: var(--ds-surface-subtle);
  --color-text: var(--ds-text);
  --color-text-secondary: var(--ds-text-secondary);
  --color-text-muted: var(--ds-text-muted);
  --color-text-disabled: var(--ds-text-disabled);
  --color-border: var(--ds-border);
  --color-border-strong: var(--ds-border-strong);
  --color-primary: var(--ds-brand);
  --color-primary-hover: var(--ds-brand-hover);
  --color-primary-soft: var(--ds-brand-soft);
  --color-success: var(--ds-success);
  --color-success-soft: var(--ds-success-soft);
  --color-warning: var(--ds-warning);
  --color-warning-soft: var(--ds-warning-soft);
  --color-error: var(--ds-error);
  --color-error-soft: var(--ds-error-soft);
  --radius-control: var(--ds-radius-md);
  --radius-card: var(--ds-radius-md);
  --shadow-card: var(--ds-shadow-card);
  --shadow-dialog: var(--ds-shadow-dialog);
  --space-1: var(--ds-space-1);
  --space-2: var(--ds-space-2);
  --space-3: var(--ds-space-3);
  --space-4: var(--ds-space-4);
  --space-5: var(--ds-space-5);
  --space-6: var(--ds-space-6);
  --space-8: var(--ds-space-8);
  --space-10: var(--ds-space-10);
  --font-xs: var(--ds-text-xs);
  --font-sm: var(--ds-text-sm);
  --font-md: var(--ds-text-md);
  --font-lg: var(--ds-text-lg);
  --font-xl: var(--ds-text-2xl);
  --duration-fast: var(--ds-duration-fast);
  --duration-normal: var(--ds-duration-normal);
  --page-max: var(--ds-container-default);
  --content-max: var(--ds-container-reading);
  --bg: var(--color-background);
  --panel: var(--color-surface);
  --ink: var(--color-text);
  --muted: var(--color-text-muted);
  --line: var(--color-border);
  --accent: var(--color-primary);
  --accent-strong: var(--color-primary-hover);
  --accent-2: var(--color-warning);
  --ok: var(--color-success);
  --danger: var(--color-error);
}

/* Keyboard-only route entry, using the existing semantic color/shape tokens. */
.skip-link {
  position: fixed;
  inset-block-start: var(--ds-skip-link-offset);
  inset-inline-start: var(--ds-skip-link-offset);
  z-index: var(--ds-z-skip);
  transform: translateY(-200%);
  padding: var(--ds-space-3) var(--ds-space-4);
  border: 2px solid var(--ds-focus);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  color: var(--ds-text);
  font: 600 var(--ds-text-md)/var(--ds-leading-body) var(--ds-font-sans);
}
.skip-link:focus { transform: translateY(0); }
html:not([data-p07-ui="enabled"]) .skip-link,
html:not([data-p07-ui="enabled"]) label[data-p07-label] { display: none; }
body.modal-open .skip-link { visibility: hidden; }
#pageContent { scroll-margin-top: var(--ds-space-4); }
.finance-page :is(strong, output), .plan-grid strong { font-variant-numeric: tabular-nums; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --ds-stage: #07090d;
  --ds-stage-surface: #11141a;
  --ds-stage-surface-raised: #171a21;
  --ds-stage-text: #f8fafc;
  --ds-stage-text-secondary: #b9c1cd;
  --ds-stage-border: rgba(255, 255, 255, 0.16);
  --ds-stage-brand: #8eb4ff;
  --ds-stage-action: #ffffff;
  --ds-stage-on-action: #0b0d11;
  --ds-stage-action-hover: #e8efff;
  --ds-workspace-canvas: var(--ds-dark-workspace-canvas);
  --ds-workspace-canvas-warm: var(--ds-dark-workspace-canvas-warm);
  --ds-surface: var(--ds-dark-surface);
  --ds-surface-subtle: var(--ds-dark-surface-subtle);
  --ds-surface-raised: var(--ds-dark-surface-raised);
  --ds-surface-disabled: var(--ds-dark-surface-disabled);
  --ds-text: var(--ds-dark-text);
  --ds-text-secondary: var(--ds-dark-text-secondary);
  --ds-text-muted: var(--ds-dark-text-muted);
  --ds-text-disabled: var(--ds-dark-text-disabled);
  --ds-border: var(--ds-dark-border);
  --ds-border-strong: var(--ds-dark-border-strong);
  --ds-brand: var(--ds-dark-brand);
  --ds-brand-hover: var(--ds-dark-brand-hover);
  --ds-brand-pressed: var(--ds-dark-brand-pressed);
  --ds-brand-soft: var(--ds-dark-brand-soft);
  --ds-on-brand: var(--ds-dark-on-brand);
  --ds-success: var(--ds-dark-success);
  --ds-success-soft: var(--ds-dark-success-soft);
  --ds-warning: var(--ds-dark-warning);
  --ds-warning-soft: var(--ds-dark-warning-soft);
  --ds-error: var(--ds-dark-error);
  --ds-on-error: var(--ds-dark-on-brand);
  --ds-error-hover: var(--ds-dark-error-hover);
  --ds-error-soft: var(--ds-dark-error-soft);
  --ds-info: var(--ds-dark-info);
  --ds-info-soft: var(--ds-dark-info-soft);
  --ds-focus: var(--ds-dark-focus);
  --ds-focus-ring: 0 0 0 3px rgba(154, 188, 255, 0.28);
  --ds-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.22), 0 12px 30px rgba(0, 0, 0, 0.2);
  --ds-shadow-raised: 0 18px 42px rgba(0, 0, 0, 0.28);
  --ds-shadow-dialog: 0 28px 72px rgba(0, 0, 0, 0.48);
  --ds-overlay: rgba(0, 0, 0, 0.7);
  --ds-overlay-soft: rgba(0, 0, 0, 0.58);
  --ds-hover: rgba(255, 255, 255, 0.075);
  --ds-skeleton: #2a3038;
  --ds-skeleton-shine: rgba(255, 255, 255, 0.09);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --ds-stage: #07090d;
    --ds-stage-surface: #11141a;
    --ds-stage-surface-raised: #171a21;
    --ds-stage-text: #f8fafc;
    --ds-stage-text-secondary: #b9c1cd;
    --ds-stage-border: rgba(255, 255, 255, 0.16);
    --ds-stage-brand: #8eb4ff;
    --ds-stage-action: #ffffff;
    --ds-stage-on-action: #0b0d11;
    --ds-stage-action-hover: #e8efff;
    --ds-workspace-canvas: var(--ds-dark-workspace-canvas);
    --ds-workspace-canvas-warm: var(--ds-dark-workspace-canvas-warm);
    --ds-surface: var(--ds-dark-surface);
    --ds-surface-subtle: var(--ds-dark-surface-subtle);
    --ds-surface-raised: var(--ds-dark-surface-raised);
    --ds-surface-disabled: var(--ds-dark-surface-disabled);
    --ds-text: var(--ds-dark-text);
    --ds-text-secondary: var(--ds-dark-text-secondary);
    --ds-text-muted: var(--ds-dark-text-muted);
    --ds-text-disabled: var(--ds-dark-text-disabled);
    --ds-border: var(--ds-dark-border);
    --ds-border-strong: var(--ds-dark-border-strong);
    --ds-brand: var(--ds-dark-brand);
    --ds-brand-hover: var(--ds-dark-brand-hover);
    --ds-brand-pressed: var(--ds-dark-brand-pressed);
    --ds-brand-soft: var(--ds-dark-brand-soft);
    --ds-on-brand: var(--ds-dark-on-brand);
    --ds-success: var(--ds-dark-success);
    --ds-success-soft: var(--ds-dark-success-soft);
    --ds-warning: var(--ds-dark-warning);
    --ds-warning-soft: var(--ds-dark-warning-soft);
    --ds-error: var(--ds-dark-error);
    --ds-error-hover: var(--ds-dark-error-hover);
    --ds-error-soft: var(--ds-dark-error-soft);
    --ds-info: var(--ds-dark-info);
    --ds-info-soft: var(--ds-dark-info-soft);
    --ds-focus: var(--ds-dark-focus);
    --ds-focus-ring: 0 0 0 3px rgba(154, 188, 255, 0.28);
    --ds-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.22), 0 12px 30px rgba(0, 0, 0, 0.2);
    --ds-shadow-raised: 0 18px 42px rgba(0, 0, 0, 0.28);
    --ds-shadow-dialog: 0 28px 72px rgba(0, 0, 0, 0.48);
    --ds-overlay: rgba(0, 0, 0, 0.7);
    --ds-overlay-soft: rgba(0, 0, 0, 0.58);
    --ds-hover: rgba(255, 255, 255, 0.075);
    --ds-skeleton: #2a3038;
    --ds-skeleton-shine: rgba(255, 255, 255, 0.09);
  }
}

html {
  min-width: 0;
  min-height: 100%;
  scroll-padding-top: calc(76px + env(safe-area-inset-top));
  background: var(--ds-workspace-canvas);
}

body.modal-open {
  overflow: hidden;
}

/* Dialog scroll locking must not resize every page/card and the fixed nav. */
html {
  scrollbar-gutter: stable;
}

.site-message-save-status {
  position: fixed;
  inset: auto 16px max(16px, env(safe-area-inset-bottom));
  z-index: 8999;
  width: fit-content;
  max-width: min(680px, calc(100% - 32px));
  margin-inline: auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: var(--ds-text);
  background: var(--ds-surface-raised);
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-radius-md);
  box-shadow: var(--ds-shadow-card);
  overflow-wrap: anywhere;
}

.session-recovery {
  min-height: 70dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--ds-space-4);
  color: var(--ds-text);
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ds-text);
  background: var(--ds-workspace-canvas);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-md);
  line-height: var(--ds-leading-body);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-experience="workspace"] {
}

body,
button,
input,
select,
textarea {
  font-family: var(--ds-font-sans);
  letter-spacing: 0;
}

h1,
h2,
h3,
h4,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4,
strong {
  color: var(--ds-text);
  text-shadow: none;
}

h1 {
  font-size: var(--ds-text-2xl);
  line-height: var(--ds-leading-tight);
}

h2 {
  font-size: var(--ds-text-xl);
  line-height: 1.3;
}

h3 {
  font-size: var(--ds-text-lg);
  line-height: 1.35;
}

a {
  color: var(--ds-brand-hover);
  text-underline-offset: 3px;
}

button,
.button-link,
.button-primary,
.button-secondary,
.button-ghost,
.danger-button {
  min-height: var(--ds-touch-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  padding: 0 var(--ds-space-4);
  border: var(--ds-border-width) solid var(--ds-border-strong);
  border-radius: var(--ds-radius-md);
  color: var(--ds-text);
  background: var(--ds-surface);
  box-shadow: none;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition:
    color var(--ds-duration-fast) var(--ds-ease-standard),
    background-color var(--ds-duration-fast) var(--ds-ease-standard),
    border-color var(--ds-duration-fast) var(--ds-ease-standard),
    transform var(--ds-duration-pressed) var(--ds-ease-standard),
    scale var(--ds-duration-pressed) var(--ds-ease-standard),
    opacity var(--ds-duration-pressed) var(--ds-ease-standard);
}

[hidden] {
  display: none !important;
}

button:hover:not(:disabled),
.button-link:hover,
.button-secondary:hover:not(:disabled) {
  border-color: #8fa0b3;
  background: var(--ds-surface-subtle);
}

button:active:not(:disabled),
.button-link:active,
[data-aeris-pressed="true"] {
  scale: var(--ds-pressed-scale);
  opacity: var(--ds-pressed-opacity);
}

summary,
[role="tab"],
[role="button"],
.site-nav-card > a {
  transition: opacity var(--ds-duration-pressed) var(--ds-ease-standard),
    scale var(--ds-duration-pressed) var(--ds-ease-standard),
    background-color var(--ds-duration-fast) var(--ds-ease-standard);
}

/* Row surfaces use tone/opacity; only their individual actions scale. */
article[data-aeris-pressed="true"],
.module-card[data-aeris-pressed="true"],
[data-widget-drag]:is(:active, [data-aeris-pressed="true"]) {
  scale: 1;
  opacity: 1;
  transition: none;
}

.home-widget-main:is(:active, [data-aeris-pressed="true"]) {
  scale: 1;
}

.ds-motion-tabs { position: relative; isolation: isolate; }
.ds-tab-indicator {
  position: absolute; pointer-events: none; bottom: 0; left: 0; height: 2px;
  background: var(--ds-brand); border-radius: var(--ds-radius-pill);
  transition: transform var(--ds-duration-expand) var(--ds-ease-emphasized);
}

button.primary,
.button-primary {
  border-color: var(--ds-brand);
  color: var(--ds-on-brand);
  background: var(--ds-brand);
}

button.primary:hover:not(:disabled),
.button-primary:hover:not(:disabled) {
  border-color: var(--ds-brand-hover);
  color: var(--ds-on-brand);
  background: var(--ds-brand-hover);
}

button.primary:active:not(:disabled),
.button-primary:active:not(:disabled) {
  border-color: var(--ds-brand-pressed);
  background: var(--ds-brand-pressed);
}

.button-secondary {
  border-color: var(--ds-border-strong);
  color: var(--ds-text);
  background: var(--ds-surface);
}

.button-ghost {
  border-color: transparent;
  color: var(--ds-text-secondary);
  background: transparent;
}

.button-ghost:hover:not(:disabled) {
  border-color: transparent;
  color: var(--ds-text);
  background: var(--ds-hover);
}

.danger-button {
  border-color: var(--ds-error);
  color: var(--ds-on-error);
  background: var(--ds-error);
}

.danger-button:hover:not(:disabled) {
  border-color: var(--ds-error-hover);
  color: var(--ds-on-error);
  background: var(--ds-error-hover);
}

button:disabled,
.button-link[aria-disabled="true"] {
  cursor: not-allowed;
  border-color: var(--ds-border-strong);
  color: var(--ds-text-disabled);
  background: var(--ds-surface-disabled);
  box-shadow: none;
  opacity: 1;
  transform: none;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ds-focus);
  outline-offset: 3px;
  box-shadow: var(--ds-focus-ring);
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  border: var(--ds-border-width) solid var(--ds-border-strong);
  border-radius: var(--ds-radius-md);
  color: var(--ds-text);
  background: var(--ds-surface);
  box-shadow: none;
  transition:
    border-color var(--ds-duration-fast) var(--ds-ease-standard),
    box-shadow var(--ds-duration-fast) var(--ds-ease-standard),
    background-color var(--ds-duration-fast) var(--ds-ease-standard);
}

input,
select {
  min-height: var(--ds-touch-min);
  padding: 0 var(--ds-space-3);
}

textarea {
  min-height: 120px;
  padding: var(--ds-space-3);
  line-height: var(--ds-leading-body);
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--ds-text-muted);
  opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--ds-text-disabled);
  background: var(--ds-surface-disabled);
  opacity: 1;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--ds-error);
}

.panel,
.quiz-card,
.result-panel,
.dashboard-card,
.module-card,
.tool-category-card,
.tool-shelf,
.workflow-editor,
.finance-card,
.admin-user-card,
.admin-login-card,
.trial-workbench {
  border-color: var(--ds-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-text);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-card);
}

.modal-layer {
  inset: var(--ds-overlay-top, 0px) 0 auto;
  height: var(--ds-overlay-height, 100dvh);
  overscroll-behavior: contain;
  padding:
    max(var(--ds-space-4), env(safe-area-inset-top))
    max(var(--ds-space-4), env(safe-area-inset-right))
    max(var(--ds-space-4), env(safe-area-inset-bottom))
    max(var(--ds-space-4), env(safe-area-inset-left));
  background: var(--ds-overlay);
  backdrop-filter: blur(3px);
  animation: dsModalBackdropIn var(--ds-duration-expand) var(--ds-ease-standard) both;
}

.modal-layer.is-closing {
  animation: dsModalBackdropOut var(--ds-duration-expand) var(--ds-ease-standard) both;
}

.modal-panel {
  max-height: calc(var(--ds-overlay-height, 100dvh) - 32px);
  min-height: 0;
  min-width: 0;
  overscroll-behavior: contain;
  overflow: auto;
  border: var(--ds-border-width) solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  color: var(--ds-text);
  background: var(--ds-surface-raised);
  box-shadow: var(--ds-shadow-dialog);
  animation: dsModalPanelIn var(--ds-duration-expand) var(--ds-ease-standard) both;
}

.modal-layer.is-closing .modal-panel {
  animation: dsModalPanelOut var(--ds-duration-expand) var(--ds-ease-standard) both;
}

@keyframes dsModalBackdropIn {
  from { background-color: var(--ds-overlay-soft); }
  to { background-color: var(--ds-overlay); }
}

@keyframes dsModalBackdropOut {
  from { background-color: var(--ds-overlay); }
  to { background-color: var(--ds-overlay-soft); }
}

@keyframes dsModalPanelIn {
  from { transform: translateY(8px) scale(0.99); }
  to { transform: translateY(0) scale(1); }
}

@keyframes dsModalPanelOut {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(8px) scale(0.99); }
}

.tabs,
.admin-tabs,
.feedback-tabs,
.wrong-book-tabs {
  border-color: var(--ds-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface-subtle);
}

.tabs button,
.admin-tabs button,
.feedback-tabs button,
.wrong-book-tabs button {
  color: var(--ds-text-secondary);
}

.tabs button.active,
.admin-tabs button.active,
.feedback-tabs button.active,
.wrong-book-tabs button.active,
[role="tab"][aria-selected="true"] {
  color: var(--ds-brand-hover);
  background: var(--ds-surface);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.status-badge,
.local-only-badge,
.membership-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 var(--ds-space-3);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-pill);
  color: var(--ds-text-secondary);
  background: var(--ds-surface-subtle);
  font-size: var(--ds-text-xs);
  font-weight: 700;
}

[data-tone="success"],
.status-success {
  border-color: #abd9bf;
  color: var(--ds-success);
  background: var(--ds-success-soft);
}

[data-tone="warning"],
.status-warning {
  border-color: #ebcf93;
  color: var(--ds-warning);
  background: var(--ds-warning-soft);
}

[data-tone="error"],
.status-error,
.login-failed {
  border-color: #edb2b2;
  color: var(--ds-error);
  background: var(--ds-error-soft);
}

.dashboard-empty,
.admin-empty-state,
.tool-empty-state,
.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  padding: var(--ds-space-6);
  border: 1px dashed var(--ds-border-strong);
  border-radius: var(--ds-radius-md);
  color: var(--ds-text-muted);
  background: var(--ds-surface-subtle);
  text-align: center;
}

.loading-state,
.skeleton {
  position: relative;
  overflow: hidden;
  color: var(--ds-text-muted);
  background: var(--ds-skeleton);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--ds-skeleton-shine) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: dsSkeleton 1.4s var(--ds-ease-standard) infinite;
}

@keyframes dsSkeleton {
  to { transform: translateX(100%); }
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ds-text);
  background: var(--ds-surface);
}

th,
td {
  padding: var(--ds-space-3) var(--ds-space-4);
  border-bottom: 1px solid var(--ds-border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--ds-text-secondary);
  background: var(--ds-surface-subtle);
  font-size: var(--ds-text-sm);
  font-weight: 750;
}

.section-kicker {
  color: var(--ds-brand-hover);
  font-size: var(--ds-text-xs);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.meta-line,
.local-processing-note,
.admin-date-help,
.admin-editor-subtitle,
small {
  color: var(--ds-text-muted);
  opacity: 1;
}

.danger-text {
  color: var(--ds-error) !important;
}

@media (max-width: 760px) {
  :root {
    --ds-text-display: 2.625rem;
    --ds-text-2xl: 1.625rem;
    --ds-text-xl: 1.25rem;
  }

  .modal-layer {
    align-items: flex-end;
    padding: max(8px, env(safe-area-inset-top)) 0 0;
  }

  .modal-panel {
    width: 100%;
    max-height: calc(var(--ds-overlay-height, 100dvh) - max(8px, env(safe-area-inset-top)));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0;
    padding-bottom: max(var(--ds-space-5), env(safe-area-inset-bottom));
  }

  th,
  td {
    padding: var(--ds-space-3);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --ds-pressed-scale: 1;
    --ds-duration-pressed: 0ms;
    --ds-duration-expand: 0ms;
    --ds-duration-page: 0ms;
    --ds-duration-sheet: 0ms;
  }
  [data-aeris-pressed="true"] { scale: 1; }
  .ds-tab-indicator { transition: none; }
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* Some Android WebViews do not map the real OS animator preference to media. */
html[data-android-reduced-motion="true"] {
  --ds-pressed-scale: 1;
  --ds-duration-pressed: 0ms;
  --ds-duration-expand: 0ms;
  --ds-duration-page: 0ms;
  --ds-duration-sheet: 0ms;
}
html[data-android-reduced-motion="true"] [data-aeris-pressed="true"] { scale: 1; }
html[data-android-reduced-motion="true"] .ds-tab-indicator { transition: none; }
html[data-android-reduced-motion="true"] *,
html[data-android-reduced-motion="true"] *::before,
html[data-android-reduced-motion="true"] *::after {
  scroll-behavior: auto !important;
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
}

/* ==========================================================================
 * Aeris V3 Unified Design System Foundation (P07-01A)
 * Governed by Task25 (p07_accessibility): Design Token -> Shared Components.
 * Unifies light-gray canvas, pure white cards/containers, clean borders,
 * standard Aeris blue primary actions, accessible states, and dark parity.
 * ========================================================================== */
html[data-p07-ui="enabled"] {
  scroll-padding-block-start: calc(var(--site-nav-height, 68px) + var(--ds-space-4));

  /* Unified V3 Cool Light-Gray Canvas & Pure White Surfaces */
  --ds-workspace-canvas: #f4f6f9;
  --ds-workspace-canvas-warm: #f4f6f9;
  --ds-stage: #f4f6f9;
  --ds-stage-surface: #ffffff;
  --ds-stage-surface-raised: #f1f5f9;
  --ds-stage-text: #0f172a;
  --ds-stage-text-secondary: #475569;
  --ds-stage-border: #e2e8f0;

  --ds-surface: #ffffff;
  --ds-surface-subtle: #f8fafc;
  --ds-surface-muted: #f1f5f9;
  --ds-surface-raised: #ffffff;
  --ds-surface-disabled: #edf2f7;

  /* Crisp Text & Divider Hierarchy (WCAG AA >= 4.5:1) */
  --ds-text: #0f172a;
  --ds-text-secondary: #475569;
  --ds-text-muted: #526075;
  --ds-text-disabled: #516072;
  --ds-border: #e2e8f0;
  --ds-border-strong: #cbd5e1;
  --ds-divider: #edf2f7;

  /* Standard Aeris Blue Primary & Semantic Tokens */
  --ds-brand: #2563eb;
  --ds-brand-hover: #1d4ed8;
  --ds-brand-pressed: #1e40af;
  --ds-brand-soft: #eff6ff;
  --ds-brand-border: #bfdbfe;
  --ds-on-brand: #ffffff;
  --ds-focus: #2563eb;
  --ds-focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.22);

  /* Unified Shape & Natural Layered Elevation */
  --ds-radius-xs: 6px;
  --ds-radius-sm: 8px;
  --ds-radius-md: 10px;
  --ds-radius-lg: 14px;
  --ds-radius-xl: 18px;
  --ds-shadow-card: 0 1px 3px rgba(15, 23, 42, 0.05), 0 6px 18px rgba(15, 23, 42, 0.04);
  --ds-shadow-raised: 0 4px 12px rgba(15, 23, 42, 0.07), 0 16px 36px rgba(15, 23, 42, 0.08);
  --ds-shadow-dialog: 0 16px 48px rgba(15, 23, 42, 0.16), 0 4px 12px rgba(15, 23, 42, 0.06);
  --ds-hover: rgba(15, 23, 42, 0.045);

  /* V3 Business Card Pastel Tints (Subtle Differentiation within Unified Token System) */
  --ds-card-learning-bg: linear-gradient(180deg, #eef6ff 0%, #f7fbff 100%);
  --ds-card-learning-surface: #eff6ff;
  --ds-card-learning-border: #cfe2ff;
  --ds-card-finance-bg: linear-gradient(180deg, #eefaf3 0%, #f7fcf9 100%);
  --ds-card-finance-surface: #eefaf3;
  --ds-card-finance-border: #ccebd7;
  --ds-card-tools-bg: linear-gradient(180deg, #f5f0ff 0%, #faf8ff 100%);
  --ds-card-tools-surface: #f5f0ff;
  --ds-card-tools-border: #dfd2fe;
}

html[data-p07-ui="enabled"][data-theme="dark"] {
  --ds-workspace-canvas: #0f1217;
  --ds-workspace-canvas-warm: #0f1217;
  --ds-stage: #0f1217;
  --ds-stage-surface: #171c24;
  --ds-stage-surface-raised: #1e2530;
  --ds-stage-text: #f4f7fb;
  --ds-stage-text-secondary: #b8c4d4;
  --ds-stage-border: #283140;

  --ds-surface: #171c24;
  --ds-surface-subtle: #131820;
  --ds-surface-muted: #1d2430;
  --ds-surface-raised: #1e2530;
  --ds-surface-disabled: #232b38;

  --ds-text: #f4f7fb;
  --ds-text-secondary: #b8c4d4;
  --ds-text-muted: #9fb0c4;
  --ds-text-disabled: #97a8bd;
  --ds-border: #283140;
  --ds-border-strong: #39465b;
  --ds-divider: #202734;

  --ds-brand: #6ea2ff;
  --ds-brand-hover: #8cb7ff;
  --ds-brand-pressed: #518bf5;
  --ds-brand-soft: rgba(110, 162, 255, 0.14);
  --ds-brand-border: rgba(110, 162, 255, 0.34);
  --ds-on-brand: #09111f;
  --ds-focus: #8cb7ff;
  --ds-focus-ring: 0 0 0 3px rgba(140, 183, 255, 0.28);

  --ds-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.28), 0 8px 24px rgba(0, 0, 0, 0.22);
  --ds-shadow-raised: 0 6px 18px rgba(0, 0, 0, 0.36), 0 20px 44px rgba(0, 0, 0, 0.32);
  --ds-shadow-dialog: 0 24px 64px rgba(0, 0, 0, 0.52);
  --ds-hover: rgba(255, 255, 255, 0.065);

  --ds-card-learning-bg: linear-gradient(180deg, #152238 0%, #131c2e 100%);
  --ds-card-learning-surface: #152238;
  --ds-card-learning-border: #28436d;
  --ds-card-finance-bg: linear-gradient(180deg, #132820 0%, #121f1a 100%);
  --ds-card-finance-surface: #132820;
  --ds-card-finance-border: #234d3b;
  --ds-card-tools-bg: linear-gradient(180deg, #211a36 0%, #191627 100%);
  --ds-card-tools-surface: #211a36;
  --ds-card-tools-border: #3d3066;
}

@media (prefers-color-scheme: dark) {
  html[data-p07-ui="enabled"]:not([data-theme]) {
    --ds-workspace-canvas: #0f1217;
    --ds-workspace-canvas-warm: #0f1217;
    --ds-stage: #0f1217;
    --ds-stage-surface: #171c24;
    --ds-stage-surface-raised: #1e2530;
    --ds-stage-text: #f4f7fb;
    --ds-stage-text-secondary: #b8c4d4;
    --ds-stage-border: #283140;
    --ds-surface: #171c24;
    --ds-surface-subtle: #131820;
    --ds-surface-muted: #1d2430;
    --ds-surface-raised: #1e2530;
    --ds-surface-disabled: #232b38;
    --ds-text: #f4f7fb;
    --ds-text-secondary: #b8c4d4;
    --ds-text-muted: #9fb0c4;
    --ds-text-disabled: #97a8bd;
    --ds-border: #283140;
    --ds-border-strong: #39465b;
    --ds-divider: #202734;
    --ds-brand: #6ea2ff;
    --ds-brand-hover: #8cb7ff;
    --ds-brand-pressed: #518bf5;
    --ds-brand-soft: rgba(110, 162, 255, 0.14);
    --ds-brand-border: rgba(110, 162, 255, 0.34);
    --ds-on-brand: #09111f;
    --ds-focus: #8cb7ff;
    --ds-focus-ring: 0 0 0 3px rgba(140, 183, 255, 0.28);
    --ds-card-learning-bg: linear-gradient(180deg, #152238 0%, #131c2e 100%);
    --ds-card-learning-surface: #152238;
    --ds-card-learning-border: #28436d;
    --ds-card-finance-bg: linear-gradient(180deg, #132820 0%, #121f1a 100%);
    --ds-card-finance-surface: #132820;
    --ds-card-finance-border: #234d3b;
    --ds-card-tools-bg: linear-gradient(180deg, #211a36 0%, #191627 100%);
    --ds-card-tools-surface: #211a36;
    --ds-card-tools-border: #3d3066;
  }
}

/* Unified Boot Splash (#entryScreen) & Session/Error Recovery (#sessionRecovery)
 * Ensures initial paint, loading, offline/error recovery, login and home share one canvas.
 */
body {
  background-color: var(--ds-workspace-canvas);
  background-image: none;
}

.entry-screen {
  background: var(--ds-workspace-canvas);
  color: var(--ds-text);
  transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1);
}

.entry-content {
  width: min(320px, calc(100vw - 40px));
  padding: 28px 24px 24px;
  gap: 14px;
  border: 1px solid var(--ds-border);
  border-radius: 18px;
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-card);
  color: var(--ds-text);
}

.entry-logo {
  width: 64px;
  height: 64px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--ds-border);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  filter: none;
}

.entry-content strong {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ds-text);
}

.entry-progress {
  width: 120px;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ds-brand) 16%, var(--ds-border));
}

.entry-progress::after {
  background: var(--ds-brand);
}

.session-recovery:not(.hidden) {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--ds-workspace-canvas);
}

.session-recovery-card {
  width: min(420px, calc(100vw - 32px));
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 32px 28px;
  border: 1px solid var(--ds-border);
  border-radius: 18px;
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-card);
  text-align: center;
}

.session-recovery-logo {
  width: 56px;
  height: 56px;
  padding: 5px;
  border: 1px solid var(--ds-border);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.session-recovery-card h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ds-text);
}

.session-recovery-card p {
  margin: 0;
  max-width: 34ch;
  color: var(--ds-text-secondary);
  font-size: var(--ds-text-sm);
  line-height: 1.6;
}

.session-recovery[data-recovery-state="error"] .session-recovery-card {
  border-color: color-mix(in srgb, var(--ds-error) 30%, var(--ds-border));
}

.session-recovery[data-recovery-state="error"] #sessionRecoveryMessage {
  color: var(--ds-error);
  font-weight: 500;
}

.session-recovery-bar {
  width: 136px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ds-brand) 16%, var(--ds-border));
}

.session-recovery-bar::after {
  content: "";
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--ds-brand);
  animation: dsSessionBarSlide 1.1s cubic-bezier(0.23, 1, 0.32, 1) infinite;
}

.session-recovery[data-recovery-state="error"] .session-recovery-bar {
  display: none;
}

@keyframes dsSessionBarSlide {
  from { transform: translateX(-100%); }
  to { transform: translateX(240%); }
}

.session-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.session-recovery-actions > button {
  min-height: 44px;
  padding-inline: 18px;
  border-radius: var(--ds-radius-md);
  font-size: var(--ds-text-sm);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .session-recovery-bar::after {
    animation: none;
    width: 65%;
    transform: none;
  }
}

/* Remove legacy muddy top gradient bleed; enforce one clean V3 canvas */
html[data-p07-ui="enabled"] body {
  background-color: var(--ds-workspace-canvas);
  background-image: none;
}

html[data-p07-ui="enabled"] :is(input, select, textarea, button, a, summary, [tabindex]) {
  scroll-margin-block: calc(var(--site-nav-height, 68px) + var(--ds-space-4)) var(--ds-space-4);
}

html[data-p07-ui="enabled"] label[data-p07-label] {
  display: block;
  margin-block: var(--ds-space-3) var(--ds-space-2);
  color: var(--ds-text-secondary);
  font-size: var(--ds-text-sm);
  font-weight: 600;
}

html[data-p07-ui="enabled"] :is(button, .button-link, .button-primary, .button-secondary) {
  min-width: var(--ds-touch-min);
  min-height: var(--ds-touch-min);
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

html[data-p07-ui="enabled"] :is(button.primary, .button-primary):not(:disabled) {
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.18);
}

html[data-p07-ui="enabled"] :is(button.primary, .button-primary):hover:not(:disabled) {
  box-shadow: 0 3px 8px rgba(29, 78, 216, 0.22);
}

html[data-p07-ui="enabled"] :is(.button-secondary, button:not(.primary):not(.button-ghost):not(.danger-button)):hover:not(:disabled) {
  border-color: var(--ds-border-strong);
  background: var(--ds-surface-subtle);
}

html[data-p07-ui="enabled"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
  border-color: var(--ds-border-strong);
  background: var(--ds-surface);
}

html[data-p07-ui="enabled"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):hover:not(:disabled):not(:focus) {
  border-color: #94a3b8;
}

html[data-p07-ui="enabled"] :is(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--ds-error);
  background: color-mix(in srgb, var(--ds-error-soft) 35%, var(--ds-surface));
}

html[data-p07-ui="enabled"] [role="tabpanel"] { min-width: 0; }
html:not([data-p07-ui="enabled"]) #workspace > .tabs .ds-tab-indicator { display: none; }
html[data-p07-ui="enabled"] [role="tabpanel"]:focus-visible {
  outline: 2px solid var(--ds-focus);
  outline-offset: 3px;
}

html[data-p07-ui="enabled"] .field-validation {
  margin-block: var(--ds-space-1) var(--ds-space-2);
  color: var(--ds-error);
  font-size: var(--ds-text-xs);
  font-weight: 500;
  line-height: 1.5;
}

html[data-p07-ui="enabled"] :is(.secret-input-row, .admin-secret-input-wrap) { min-width: 0; }
html[data-p07-ui="enabled"] .secret-input-row > input { min-width: 0; }
html[data-p07-ui="enabled"] .account-details :is(dd, code) { overflow-wrap: anywhere; }

/* Shared numeric alignment & loading/empty/error/modal/notice states */
html[data-p07-ui="enabled"] :is(output, .tabular-nums, .aeris-summary-number, .aeris-live-metrics output) {
  font-variant-numeric: tabular-nums;
}

html[data-p07-ui="enabled"] [aria-busy="true"] {
  opacity: 0.76;
}

html[data-p07-ui="enabled"] .modal-panel {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-dialog);
}

@media (max-height: 35rem) and (orientation: landscape) {
  html[data-p07-ui="enabled"] { scroll-padding-block-start: var(--ds-space-3); }
  html[data-p07-ui="enabled"] :is(input, select, textarea, button, a, summary, [tabindex]) { scroll-margin-block-start: var(--ds-space-3); }
  html[data-p07-ui="enabled"] .site-nav { position: relative; }
  html[data-p07-ui="enabled"] .modal-layer { align-items: flex-start; }
  html[data-p07-ui="enabled"] .modal-panel { max-height: calc(var(--ds-overlay-height, 100dvh) - 16px); }
}

@media (forced-colors: active) {
  :is(button, a, summary, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid Highlight;
    box-shadow: none;
  }
  [role="tab"][aria-selected="true"] { border-bottom: 2px solid Highlight; }
}

