/**
 * macOS Sonoma / Sequoia Visual Theme — Unified Production Layer
 * -----------------------------------------------------------------------------
 * 架构定位：统一视觉材质层（负责颜色、毛玻璃、光晕、微阴影、圆角）。
 * 协同规范：
 *   1. 统一布局层（typography.css / app.css / workspace.css）负责字号与栅格网格，本层绝不更改 font-size。
 *   2. 纯白不透光原则（Anti-Fatigue）：表格、题目、答题区、代码及微工具表单必须 100% 不透明纯白，杜绝视觉疲劳。
 *   3. 考场模式硬隔离：body.exam-focus 彻底豁免，严禁光晕与透光穿透。
 *   4. 零 !important 污染：通过特异性选择器平滑提升权重，方便后续 Codex 无缝扩展。
 * -----------------------------------------------------------------------------
 */

@media screen {
  :root {
    /* macOS 系统色彩 */
    --mac-bg: #f5f5f7;
    --mac-bg-alt: #fbfbfd;
    --mac-surface-solid: #ffffff;
    --mac-text: #1d1d1f;
    --mac-secondary: #6e6e73;
    --mac-tertiary: #86868b;
    --mac-line: #e3e3e8;
    --mac-line-light: rgba(227, 227, 232, 0.7);

    /* 苹果色彩矩阵 */
    --mac-blue: #0071e3;
    --mac-blue-hover: #0066cc;
    --mac-blue-subtle: rgba(0, 113, 227, 0.08);
    --mac-purple: #8944ab;
    --mac-teal: #009688;
    --mac-orange: #f56300;
    --mac-green: #34c759;
    --mac-red: #ff3b30;

    /* 苹果经典圆角体系 */
    --mac-radius-sm: 8px;
    --mac-radius: 12px;
    --mac-radius-card: 16px;
    --mac-radius-lg: 20px;

    /* 苹果多层细腻微阴影体系 */
    --mac-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --mac-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.03), 0 6px 16px rgba(29, 39, 51, 0.04);
    --mac-shadow-card-hover: 0 3px 8px rgba(0, 0, 0, 0.05), 0 12px 28px rgba(29, 39, 51, 0.07);
    --mac-shadow-float: 0 4px 16px rgba(0, 0, 0, 0.08), 0 16px 40px rgba(0, 0, 0, 0.06);

    /* 毛玻璃参数 */
    --mac-glass-bg: rgba(255, 255, 255, 0.82);
    --mac-glass-bg-dense: rgba(255, 255, 255, 0.92);
    --mac-glass-border: rgba(255, 255, 255, 0.65);
    --mac-glass-blur: blur(16px);
  }

  /* -----------------------------------------------------------------------
   * §1 全局基础与字体渲染
   * ----------------------------------------------------------------------- */
  html body {
    color: var(--mac-text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* 非考场页面全局背景 —— macOS Sonoma 蓝紫微光多层径向光晕 */
  html body:not(.exam-focus) {
    background-color: var(--mac-bg);
    background-image:
      radial-gradient(ellipse 65% 45% at 8% 0%, rgba(0, 113, 227, 0.08) 0%, transparent 70%),
      radial-gradient(ellipse 55% 40% at 92% 5%, rgba(137, 68, 171, 0.06) 0%, transparent 65%),
      radial-gradient(ellipse 50% 35% at 50% 100%, rgba(0, 150, 136, 0.04) 0%, transparent 70%),
      radial-gradient(circle 350px at 85% 85%, rgba(245, 99, 0, 0.03) 0%, transparent 70%);
    background-attachment: fixed;
    background-repeat: no-repeat;
  }

  /* 标题与字间距微调 */
  html body:not(.exam-focus) :is(h1, h2, h3) {
    color: var(--mac-text);
    letter-spacing: -0.022em;
  }
  html body:not(.exam-focus) :is(.muted, .hint, .work-secondary, .card-meta, .identity, .subsystem-badge) {
    color: var(--mac-secondary);
  }

  /* -----------------------------------------------------------------------
   * §2 允许毛玻璃材质（极度克制：仅限顶栏、侧栏、弹窗）
   * ----------------------------------------------------------------------- */
  /* 全局顶部导航条 —— 经典 Frosted Glass */
  html body:not(.exam-focus) .topbar {
    background: var(--mac-glass-bg);
    backdrop-filter: var(--mac-glass-blur);
    -webkit-backdrop-filter: var(--mac-glass-blur);
    border-bottom: 1px solid var(--mac-line);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  }

  html body:not(.exam-focus) .topbar .brand .brand-title {
    color: var(--mac-text);
    font-weight: 700;
    letter-spacing: -0.03em;
    text-shadow: none;
  }
  html body:not(.exam-focus) .topbar .brand .brand-ai {
    color: var(--mac-blue);
    background: none;
    -webkit-text-fill-color: var(--mac-blue);
  }
  html body:not(.exam-focus) .topbar .brand .brand-mark {
    box-shadow: 0 2px 6px rgba(0, 113, 227, 0.2);
    border-radius: 9px;
  }
  html body:not(.exam-focus) .topbar .top-actions .btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--mac-line);
    color: #424245;
  }
  html body:not(.exam-focus) .topbar .top-actions .btn:hover {
    background: #ffffff;
    color: var(--mac-text);
  }

  /* 管理后台左侧导航条 —— 拟 macOS Finder 侧边栏 */
  html body.admin-page:not(.exam-focus) #admin-nav {
    background: rgba(246, 246, 248, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--mac-line);
    box-shadow: none;
  }
  html body.admin-page:not(.exam-focus) #admin-nav button {
    color: #4b4b51;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--mac-radius-sm);
    box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  html body.admin-page:not(.exam-focus) #admin-nav button:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--mac-text);
    transform: none;
  }
  html body.admin-page:not(.exam-focus) #admin-nav button.active {
    color: var(--mac-blue);
    background: rgba(0, 113, 227, 0.12);
    border-color: rgba(0, 113, 227, 0.18);
    font-weight: 600;
    box-shadow: none;
  }
  html body.admin-page:not(.exam-focus) #admin-nav .admin-nav-heading {
    color: var(--mac-tertiary);

    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  /* 模态弹窗与下拉框 —— 浮动毛玻璃 */
  html body:not(.exam-focus) :is(dialog, .modal, .dropdown-menu, .popover) {
    background: var(--mac-glass-bg-dense);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--mac-glass-border);
    border-radius: var(--mac-radius-card);
    box-shadow: var(--mac-shadow-float);
  }
  html body:not(.exam-focus) dialog::backdrop {
    background: rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  /* -----------------------------------------------------------------------
   * §3 纯白不透光区（Anti-Fatigue 长时间阅读/操作绝对保护）
   * ----------------------------------------------------------------------- */
  /* 表格系统：坚决纯白底，杜绝透光 */
  html body:not(.exam-focus) :is(table, .table-wrap, .table-panel, .work-table-panel) {
    background: var(--mac-surface-solid);
    opacity: 1;
    border: 1px solid var(--mac-line);
    border-radius: var(--mac-radius-card);
    box-shadow: var(--mac-shadow-card);
  }
  html body:not(.exam-focus) table {


    color: #333336;
    font-variant-numeric: tabular-nums;
  }
  html body:not(.exam-focus) table th {
    background: #fafafc;
    color: var(--mac-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--mac-line);
  }
  html body:not(.exam-focus) table td {
    border-bottom: 1px solid #ededf1;
    background: var(--mac-surface-solid);
  }
  html body:not(.exam-focus) table tbody tr:hover td {
    background: #f7f9fc;
  }

  /* 通用容器、工作卡片、统计面板 —— 纯白不透光 + 细腻微阴影 */
  html body:not(.exam-focus) :is(
    .card,
    .panel,
    .work-card,
    .activity-card,
    .stat,
    .stat-action,
    .queue-panel,
    .class-journey,
    .work-section,
    .work-surface,
    .work-queue,
    .quick-work,
    .welcome-banner
  ) {
    background: var(--mac-surface-solid);
    opacity: 1;
    border: 1px solid var(--mac-line);
    border-radius: var(--mac-radius-card);
    box-shadow: var(--mac-shadow-card);
    transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  }

  html body:not(.exam-focus) :is(.card, .work-card, .activity-card, .stat-action):hover {
    box-shadow: var(--mac-shadow-card-hover);
  }

  /* 统计数字排版 */
  html body:not(.exam-focus) :is(.stat strong, .overview-stats strong) {
    color: var(--mac-text);
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    letter-spacing: -0.03em;
  }
  html body:not(.exam-focus) :is(.stat-label, .stat-action-label) {
    color: var(--mac-secondary);
  }

  /* 工作台过滤栏 */
  html body:not(.exam-focus) .work-filterbar {
    background: #f8f8fa;
    border: 1px solid var(--mac-line);
    border-radius: var(--mac-radius-card) var(--mac-radius-card) 0 0;
  }

  /* -----------------------------------------------------------------------
   * §4 苹果风格按钮与交互控件体系（剔除 !important，平滑特异性覆盖）
   * ----------------------------------------------------------------------- */
  /* 标准中性按钮 */
  html body:not(.exam-focus) .btn {
    color: #333336;
    background: linear-gradient(180deg, #ffffff 0%, #f6f7f9 100%);
    border: 1px solid #d6d7dc;
    border-radius: 9px;
    box-shadow: var(--mac-shadow-sm);
    transform: none;
    text-shadow: none;
    font-weight: 500;
    transition: all 0.12s ease;
  }
  html body:not(.exam-focus) .btn:hover {
    color: var(--mac-text);
    background: linear-gradient(180deg, #fbfbfd 0%, #ededf0 100%);
    border-color: #c4c6ce;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    transform: none;
  }
  html body:not(.exam-focus) .btn:active {
    background: #e5e6ea;
    transform: translateY(1px);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  }

  /* 苹果蓝主按钮 */
  html body:not(.exam-focus) .btn.primary {
    color: #ffffff;
    background: linear-gradient(180deg, #0a84ff 0%, #0071e3 100%);
    border-color: #0071e3;
    box-shadow: 0 1px 2px rgba(0, 113, 227, 0.28);
    font-weight: 600;
  }
  html body:not(.exam-focus) .btn.primary:hover {
    color: #ffffff;
    background: linear-gradient(180deg, #0077ed 0%, #0066cc 100%);
    border-color: #0066cc;
    box-shadow: 0 2px 6px rgba(0, 113, 227, 0.35);
  }
  html body:not(.exam-focus) .btn.primary:active {
    background: #005bb5;
    transform: translateY(1px);
  }

  /* 幽灵与次级按钮 */
  html body:not(.exam-focus) .btn.ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: #4b4b51;
  }
  html body:not(.exam-focus) .btn.ghost:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--mac-text);
    border-color: transparent;
    box-shadow: none;
  }

  /* 警示与危险按钮 */
  html body:not(.exam-focus) .btn.danger {
    color: #d70015;
    background: #fff5f5;
    border-color: #ffd2d2;
    box-shadow: var(--mac-shadow-sm);
  }
  html body:not(.exam-focus) .btn.danger:hover {
    color: #ffffff;
    background: #ff3b30;
    border-color: #ff3b30;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.3);
  }

  /* 禁用态按钮 */
  html body:not(.exam-focus) .btn:disabled,
  html body:not(.exam-focus) .btn[aria-disabled="true"] {
    opacity: 0.45;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
  }

  /* 表单控件（输入框、选择框、多行文本） */
  html body:not(.exam-focus) :is(input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), select, textarea) {
    color: var(--mac-text);
    background: var(--mac-surface-solid);
    border: 1px solid #ced0d6;
    border-radius: 9px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  html body:not(.exam-focus) :is(input, textarea)::placeholder {
    color: var(--mac-tertiary);
  }
  html body:not(.exam-focus) :is(input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), select, textarea):focus {
    border-color: var(--mac-blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
    outline: none;
  }
  html body:not(.exam-focus) input[type="checkbox"],
  html body:not(.exam-focus) input[type="radio"] {
    accent-color: var(--mac-blue);
  }

  /* 分段切换栏（Tabs / Segmented Control） */
  html body:not(.exam-focus) .tabs {
    background: #e9eaee;
    border: 1px solid #e0e1e6;
    border-radius: 10px;

    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
  }
  html body:not(.exam-focus) .tabs button {
    color: #66666d;
    background: transparent;
    border: 0;
    border-radius: 7px;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  html body:not(.exam-focus) .tabs button.active {
    color: var(--mac-text);
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    font-weight: 600;
  }

  /* -----------------------------------------------------------------------
   * §5 登录页专属卡片体系（苹果色彩矩阵注入）
   * ----------------------------------------------------------------------- */
  html body.login-page:not(.exam-focus) :is(.login-brand, .login-box) {
    background: var(--mac-surface-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--mac-radius-card);
    box-shadow: var(--mac-shadow-card);
  }

  html body.login-page:not(.exam-focus) .capability-card {
    background: #ffffff;
    border: 1px solid var(--mac-line);
    border-radius: 14px;
    box-shadow: var(--mac-shadow-card);
    transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  }
  html body.login-page:not(.exam-focus) .capability-card:hover {
    box-shadow: var(--mac-shadow-card-hover);
    transform: translateY(-2px);
  }

  /* 登录页 4 大功能卡片的苹果色彩标识（保持白底，仅点缀微渐变与徽标色彩） */
  html body.login-page:not(.exam-focus) .capability-card:nth-of-type(1) .feature-icon {
    background: linear-gradient(135deg, #0071e3, #42a5f5);
    color: #fff;
  }
  html body.login-page:not(.exam-focus) .capability-card:nth-of-type(2) .feature-icon {
    background: linear-gradient(135deg, #8944ab, #ba68c8);
    color: #fff;
  }
  html body.login-page:not(.exam-focus) .capability-card:nth-of-type(3) .feature-icon {
    background: linear-gradient(135deg, #009688, #4db6ac);
    color: #fff;
  }
  html body.login-page:not(.exam-focus) .capability-card:nth-of-type(4) .feature-icon {
    background: linear-gradient(135deg, #f56300, #ff9800);
    color: #fff;
  }

  /* -----------------------------------------------------------------------
   * §6 微工具箱页面扩展适配（8D, A3, SPC, OEE, Line Balance）
   * ----------------------------------------------------------------------- */
  html body.tool-locked:not(.exam-focus) {
    background-color: var(--mac-bg);
  }
  html body:not(.exam-focus) .tool-head h1 {

    letter-spacing: -0.025em;
  }
  html body:not(.exam-focus) .tool-section {
    background: var(--mac-surface-solid);
    border: 1px solid var(--mac-line);
    border-radius: var(--mac-radius-card);
    box-shadow: var(--mac-shadow-card);


  }
  html body:not(.exam-focus) .tool-section h2 {
    color: var(--mac-text);

    font-weight: 650;


    border-bottom: 1px solid #f0f0f3;

  }
  html body:not(.exam-focus) .tool-help {
    background: rgba(0, 113, 227, 0.05);
    border: 1px solid rgba(0, 113, 227, 0.15);
    border-radius: var(--mac-radius-sm);
    color: #2c3e50;


  }

  /* -----------------------------------------------------------------------
   * §7 考场模式（body.exam-focus）绝对隔离与高对比保障
   * ----------------------------------------------------------------------- */
  /* 考场整体背景强制纯净浅灰白，无任何光晕干扰 */
  html body.exam-focus {
    background: #f8fafc;
    background-image: none;
    color: #0f172a;
  }

  /* 考场顶栏/计时栏 */
  html body.exam-focus :is(.topbar, .exam-bar, .ai-exam-bar) {
    background: #ffffff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  }

  /* 答题卡、题面、AI 答辩与材料区 —— 100% 纯白坚实背景，AAA 级对比 */
  html body.exam-focus :is(
    .question-panel,
    .answer-card,
    .ai-task-brief,
    .ai-chat,
    .ai-answer,
    .ai-progress,
    .ai-candidate,
    .ai-material-card,
    .decision-content,
    .presentation-content
  ) {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }

  /* 选项卡片专注态 */
  html body.exam-focus .option {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
  }
  html body.exam-focus .option:has(input:checked) {
    background: #f0f7ff;
    border-color: #0071e3;
  }
}

/* -----------------------------------------------------------------------
 * §8 无障碍与辅助功能支持 (Accessibility)
 * ----------------------------------------------------------------------- */
@media screen and (prefers-reduced-motion: reduce) {
  html body * {
    transition: none;
    animation: none;
  }
}

@media screen and (prefers-reduced-transparency: reduce) {
  html body:not(.exam-focus) :is(.topbar, #admin-nav, dialog, .modal, .login-card) {
    background: #ffffff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media screen and (forced-colors: active) {
  html body .btn,
  html body .btn.primary,
  html body .btn.danger {
    background: ButtonFace;
    color: ButtonText;
    border-color: ButtonText;
    box-shadow: none;
  }
}

/* Component ownership: actual login/tool DOM, and ID-specific existing AI geometry remains unchanged. */
@media screen {
 html body.login-page:not(.exam-focus) :is(.login-brand,.login-box){background:#fff;backdrop-filter:none;-webkit-backdrop-filter:none;border-color:var(--mac-line);box-shadow:var(--mac-shadow-card)}
 html body.login-page:not(.exam-focus) .login-box{border-top-color:var(--mac-line)}
 html body:not(.exam-focus) :is(.tool-fields,.toolbox-card,.tool-result){background:#fff;backdrop-filter:none;-webkit-backdrop-filter:none}
 html body:not(.exam-focus) .toolbox-hero{background:#fff;border-color:var(--mac-line);box-shadow:var(--mac-shadow-card)}
 html body:not(.exam-focus) :is(.panel,.card,.work-surface,.table-wrap,table,.tool-section){backdrop-filter:none;-webkit-backdrop-filter:none}
 html body.exam-focus #student-main.ai-mode :is(.ai-exam-bar,.panel,.ai-person,.ai-progress-panel,.ai-task-brief,.ai-chat,.ai-answer,.ai-material-card,.ai-question-nav,.ai-chat-head,.ai-answer-footer,.ai-compose,.ai-section-heading){background:#fff;backdrop-filter:none;-webkit-backdrop-filter:none;border-color:#dce2e9;box-shadow:var(--mac-shadow-sm)}
 html body.exam-focus #student-main.ai-mode :is(.ai-question-nav,.ai-chat-head,.ai-section-heading,.ai-compose){box-shadow:none}
 html body:not(.exam-focus) :is(button,a,input,select,textarea,summary):focus-visible{outline:3px solid #0071e35c;outline-offset:3px}
 html body.login-page:not(.exam-focus) .capability-card.tools-card:active{transform:translateY(1px);box-shadow:inset 0 1px 3px #00000010}
}
@media screen and (prefers-reduced-transparency:reduce){
 html body:not(.exam-focus) :is(.topbar,#admin-nav,dialog,.modal,.dropdown-menu,.popover){background:#fff;backdrop-filter:none;-webkit-backdrop-filter:none}
 html body:not(.exam-focus) dialog::backdrop{backdrop-filter:none;-webkit-backdrop-filter:none}
}
@media screen and (forced-colors:active){
 html body:not(.exam-focus),html body:not(.exam-focus) :is(.topbar,#admin-nav,.panel,.card,.table-wrap,table,.tool-section,dialog){background:Canvas;color:CanvasText;border-color:CanvasText;backdrop-filter:none;-webkit-backdrop-filter:none;box-shadow:none}
 html body:not(.exam-focus) :is(.btn,.btn.primary,.btn.danger){background:ButtonFace;color:ButtonText;border-color:ButtonText;box-shadow:none}
 html body.exam-focus #student-main.ai-mode :is(.ai-exam-bar,.panel,.ai-person,.ai-progress-panel,.ai-task-brief,.ai-chat,.ai-answer,.ai-material-card,.ai-question-nav,.ai-chat-head,.ai-answer-footer,.ai-compose,.ai-section-heading){background:Canvas;color:CanvasText;border-color:CanvasText;box-shadow:none}
 html body:not(.exam-focus) .topbar .brand .brand-ai{background:none;color:LinkText;-webkit-text-fill-color:LinkText}
}
