:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1865f2;
  --primary-soft: #e8f0ff;
  --secondary: #3060ff;
  --accent: #f59e0b;
  --accent-soft: #fff7e6;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --shadow: rgba(24, 101, 242, 0.12);
  --shadow-soft: 0 10px 26px rgba(24, 101, 242, 0.10);
  --shadow-strong: 0 22px 60px rgba(15, 23, 42, 0.18);
  --gradient: linear-gradient(135deg, #1865f2 0%, #67a0ff 100%);
  --chrome-bg: rgba(255, 255, 255, 0.94);
  --sidebar-bg: rgba(255, 255, 255, 0.85);
  --sidebar-text: var(--text);
  --sidebar-muted: var(--muted);
  --sidebar-item-bg: rgba(255, 255, 255, 0.88);
  --sidebar-item-hover: var(--primary-soft);
  --sidebar-item-active: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --table-head: #f3f4f6;
  --table-stripe: #fafafa;
  --table-hover: var(--primary-soft);
  --input-bg: #ffffff;
  --input-focus: rgba(24, 101, 242, 0.22);
  --modal-bg: #ffffff;
  --modal-overlay: rgba(15, 23, 42, 0.34);
  --card-radius: 12px;
  --control-radius: 8px;
  --button-radius: 10px;
  --radius: 10px;
  --sidebar-width: 252px;
  --font-modal: var(--font-other);
  --font-size-table: 13px;
  --font-size-chrome: 14px;
  --font-size-sidebar: 14px;
  --font-entry-card: var(--font-other);
  --font-size-entry-card: 12px;
  --font-size-modal: 14px;
  --font-size-settings: 14px;
  --font-size-other: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-other);
  font-size: var(--font-size-other);
  color: var(--text);
  background: var(--bg-soft);
}

body {
  overflow: auto;
}

.interaction-tabs {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.interaction-tool[data-interaction-tool="witch"] {
  grid-template-rows: minmax(300px, 1fr) auto auto;
}

.witch-launcher-board {
  min-height: 0;
  height: 100%;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--primary) 26%, #14b8a6);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(22, 78, 99, 0.92)),
    var(--panel);
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(20, 184, 166, 0.16);
}

.witch-launcher-title {
  display: grid;
  gap: 6px;
  text-align: center;
}

.witch-launcher-title span {
  color: #99f6e4;
  font-size: 13px;
  font-weight: 900;
}

.witch-launcher-title strong {
  color: #f8fafc;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.1;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(20, 184, 166, 0.35);
}

.witch-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.witch-rule-grid div {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(45, 212, 191, 0.24);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
}

.witch-rule-grid strong {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #14b8a6;
  color: #042f2e;
  font-size: 14px;
  font-weight: 900;
}

.witch-rule-grid span {
  color: #e0f2fe;
  font-size: 13px;
  line-height: 1.55;
}

.witch-launcher-controls {
  align-items: end;
}

.witch-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, #050816 0%, #0f172a 46%, #052e2b 100%);
  color: #f8fafc;
  font-family: var(--font-body);
}

.witch-page button,
.witch-page input,
.witch-page select,
.witch-page textarea {
  font-family: inherit;
}

.witch-header,
.witch-status-card,
.witch-control-bar,
.witch-side-panel > section,
.witch-board-panel,
.witch-alert {
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: var(--card-radius);
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.26);
}

.witch-header {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
}

.witch-title {
  min-width: 0;
  text-align: center;
}

.witch-title span {
  color: #99f6e4;
  font-size: 12px;
  font-weight: 900;
}

.witch-title h1 {
  margin: 2px 0 0;
  color: #f8fafc;
  font-size: clamp(26px, 3.2vw, 44px);
  line-height: 1.1;
  letter-spacing: 0;
  text-shadow: 0 0 22px rgba(45, 212, 191, 0.28);
}

.witch-clock,
.witch-back-link {
  position: relative;
  z-index: 1;
}

.witch-clock {
  justify-self: end;
  min-width: 136px;
  padding: 8px 10px;
  border: 1px solid rgba(45, 212, 191, 0.28);
  border-radius: var(--control-radius);
  background: rgba(2, 6, 23, 0.58);
  color: #ccfbf1;
  font-weight: 900;
  text-align: center;
}

.witch-alert {
  padding: 12px 14px;
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(127, 29, 29, 0.38);
  color: #fecaca;
  font-weight: 900;
}

.witch-status-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.witch-status-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.witch-status-card span,
.witch-panel-head span,
.witch-board-head span,
.witch-result-stats span {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 900;
}

.witch-status-card strong {
  min-width: 0;
  overflow: hidden;
  color: #f8fafc;
  font-size: 17px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.witch-status-card strong b {
  color: #5eead4;
  font-size: 22px;
}

.witch-status-card.accent {
  border-color: rgba(45, 212, 191, 0.42);
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.2), rgba(15, 23, 42, 0.82));
}

.witch-status-card.accent strong {
  color: #5eead4;
  font-weight: 900;
}

.witch-control-bar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  align-items: end;
  gap: 12px;
  padding: 12px;
}

.witch-control-bar label {
  color: #cbd5e1;
  font-weight: 800;
}

.witch-control-bar input {
  border-color: rgba(45, 212, 191, 0.34);
  background: rgba(2, 6, 23, 0.76);
  color: #f8fafc;
}

.witch-control-bar input:focus {
  border-color: #5eead4;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

.witch-control-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.witch-lab-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
}

.witch-side-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
}

.witch-side-panel > section {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.witch-panel-head,
.witch-board-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.witch-panel-head strong,
.witch-board-head strong {
  min-width: 0;
  color: #f8fafc;
  font-size: 16px;
  font-weight: 900;
}

.witch-rule-list {
  display: grid;
  gap: 8px;
}

.witch-rule-list div {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.42);
}

.witch-rule-list strong {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #a7f3d0;
  color: #052e16;
  font-size: 13px;
  font-weight: 900;
}

.witch-rule-list span {
  color: #dbeafe;
  font-size: 13px;
  line-height: 1.55;
}

.witch-counter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.witch-counter-grid div,
.witch-result-stats div {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(45, 212, 191, 0.18);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.48);
}

.witch-counter-grid strong,
.witch-result-stats strong {
  min-width: 0;
  overflow: hidden;
  color: #5eead4;
  font-size: 20px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.witch-board-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.witch-board-panel::before {
  content: none;
}

.witch-board-head,
.witch-clue-list,
.witch-pill-grid {
  position: relative;
  z-index: 1;
}

.witch-board-head em {
  flex: 0 0 auto;
  color: #99f6e4;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.witch-clue-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  grid-row: 1;
}

.witch-clue-card {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(45, 212, 191, 0.24);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.58);
}

.witch-clue-card:nth-child(4n + 1) {
  border-color: rgba(45, 212, 191, 0.38);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.24), rgba(2, 6, 23, 0.7));
}

.witch-clue-card:nth-child(4n + 2) {
  border-color: rgba(96, 165, 250, 0.38);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.24), rgba(2, 6, 23, 0.7));
}

.witch-clue-card:nth-child(4n + 3) {
  border-color: rgba(251, 191, 36, 0.4);
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.25), rgba(2, 6, 23, 0.7));
}

.witch-clue-card:nth-child(4n) {
  border-color: rgba(244, 114, 182, 0.38);
  background: linear-gradient(135deg, rgba(190, 24, 93, 0.24), rgba(2, 6, 23, 0.7));
}

.witch-clue-card span {
  color: #99f6e4;
  font-size: 11px;
  font-weight: 900;
}

.witch-clue-card strong {
  min-width: 0;
  color: #e0f2fe;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.witch-pill-grid {
  min-width: 0;
  display: grid;
  grid-row: 2;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 2px;
  scrollbar-gutter: stable;
}

.witch-pill {
  position: relative;
  contain: layout paint;
  isolation: isolate;
  min-width: 0;
  min-height: 82px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px solid rgba(45, 212, 191, 0.26);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.94);
  color: #e2e8f0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: none;
}

.witch-pill:hover:not(:disabled),
.witch-pill:focus-visible:not(:disabled) {
  border-color: #5eead4;
  outline: 2px solid rgba(94, 234, 212, 0.48);
  outline-offset: -3px;
}

.witch-pill:focus-visible {
  outline: 3px solid rgba(94, 234, 212, 0.5);
  outline-offset: 2px;
}

.witch-pill:disabled {
  cursor: default;
}

.witch-pill-shape {
  width: 42px;
  height: 22px;
  display: block;
  border-radius: 999px;
  background: #67e8f9;
  box-shadow: none;
  transform: none;
  pointer-events: none;
}

.witch-pill-shape i {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: 999px 0 0 999px;
  background: #bef264;
  pointer-events: none;
}

.witch-pill strong {
  color: #f8fafc;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
  pointer-events: none;
}

.witch-pill em {
  color: #94a3b8;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  pointer-events: none;
}

.witch-pill.is-safe {
  border-color: rgba(74, 222, 128, 0.55);
  background: rgba(20, 83, 45, 0.94);
}

.witch-pill.is-safe .witch-pill-shape {
  background: #22c55e;
  box-shadow: none;
}

.witch-pill.is-safe em {
  color: #bbf7d0;
}

.witch-pill.is-poison {
  border-color: rgba(244, 63, 94, 0.76);
  background: rgba(127, 29, 29, 0.95);
  box-shadow: none;
}

.witch-pill.is-poison .witch-pill-shape {
  background: #fb7185;
  box-shadow: none;
}

.witch-pill.is-poison em {
  color: #fecdd3;
}

.witch-pill.is-found-poison {
  border-color: #fbbf24;
  background: #9f1239;
  outline: 2px solid rgba(251, 191, 36, 0.78);
  outline-offset: -4px;
}

.witch-pill.is-found-poison .witch-pill-shape {
  background: #fbbf24;
}

.witch-pill.is-found-poison em {
  color: #fde68a;
}

.witch-pill.is-locked {
  opacity: 0.55;
  background: rgba(15, 23, 42, 0.74);
}

.witch-pill.is-hit {
  animation: witch-hit .32s ease both;
}

@keyframes witch-hit {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

.witch-modal-layer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
}

.witch-modal-card {
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(8, 47, 73, 0.96));
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.38);
  color: #f8fafc;
  animation: witch-modal-in .2s ease both;
}

@keyframes witch-modal-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.witch-modal-head {
  min-width: 0;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.witch-modal-head span {
  color: #99f6e4;
  font-size: 12px;
  font-weight: 900;
}

.witch-modal-head h2 {
  margin: 4px 0 0;
  color: #f8fafc;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.1;
  letter-spacing: 0;
}

.witch-modal-head > strong {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid rgba(45, 212, 191, 0.32);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.56);
  color: #5eead4;
  font-size: 18px;
  font-weight: 900;
}

.witch-modal-card p {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.7;
}

.witch-result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.witch-result-stats [data-witch-result-poison] {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
}

.witch-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.witch-page.is-failed .witch-status-card.accent,
.witch-page.is-failed .witch-board-panel {
  border-color: rgba(244, 63, 94, 0.48);
}

.witch-page.is-success .witch-status-card.accent,
.witch-page.is-success .witch-board-panel {
  border-color: rgba(74, 222, 128, 0.5);
}

@media (max-width: 980px) {
  .witch-status-grid,
  .witch-lab-shell {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .witch-lab-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .witch-side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (orientation: portrait) {
  .interaction-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .witch-rule-grid,
  .witch-side-panel,
  .witch-result-stats {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .witch-page {
    min-height: 100svh;
    grid-template-rows: auto auto auto auto;
    padding: 10px;
  }

  .witch-header,
  .witch-control-bar,
  .witch-modal-head,
  .witch-modal-actions {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    flex-direction: column;
  }

  .witch-header {
    text-align: center;
  }

  .witch-clock {
    justify-self: stretch;
  }

  .witch-status-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .witch-control-actions,
  .witch-control-actions button,
  .witch-modal-actions button {
    width: 100%;
  }

  .witch-board-panel {
    padding: 10px;
  }

  .witch-board-head {
    align-items: stretch;
    flex-direction: column;
  }

  .witch-pill-grid {
    grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
    gap: 7px;
    overflow: visible;
  }

  .witch-pill {
    min-height: 68px;
    gap: 3px;
  }

  .witch-pill-shape {
    width: 34px;
    height: 18px;
  }

  .witch-pill strong {
    font-size: 12px;
  }

  .witch-pill em {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .witch-pill,
  .witch-modal-card {
    transition: none;
    animation: none !important;
  }
}

@media (orientation: portrait) {
  .interaction-rule-layer {
    padding: 10px;
  }

  .interaction-rule-card {
    width: 100%;
    max-height: calc(100vh - 40px);
    padding: 14px;
  }

  .interaction-rule-head,
  .interaction-rule-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .interaction-rule-meta,
  .interaction-rule-param-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .interaction-rule-actions button {
    width: 100%;
  }
}

/* 部门数据分析最终桌面版覆盖：固定单屏，不使用滚动容器。 */
body.app-shell .department-analysis-layer {
  display: grid !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 120 !important;
  padding: 24px !important;
  overflow: hidden !important;
  background: rgba(15, 23, 42, 0.42) !important;
}

body.app-shell .department-analysis-card {
  box-sizing: border-box !important;
  width: min(1480px, calc(100vw - 48px)) !important;
  height: min(820px, calc(100vh - 48px)) !important;
  max-width: calc(100vw - 48px) !important;
  max-height: calc(100vh - 48px) !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  padding: 18px 20px 14px !important;
  overflow: hidden !important;
  border-radius: 10px !important;
}

body.app-shell .department-analysis-card .department-analysis-head,
body.app-shell .department-analysis-card .department-analysis-toolbar,
body.app-shell .department-analysis-card .department-analysis-summary,
body.app-shell .department-analysis-card .department-analysis-actions {
  flex: 0 0 auto !important;
}

body.app-shell .department-analysis-card .department-analysis-head {
  min-height: 42px !important;
}

body.app-shell .department-analysis-card .department-analysis-toolbar {
  grid-template-columns: minmax(280px, 1fr) 180px 180px auto !important;
  min-height: 64px !important;
  padding: 10px 12px !important;
}

body.app-shell .department-analysis-card .department-analysis-table-wrap {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  display: block !important;
  overflow: hidden !important;
}

body.app-shell .department-analysis-card .department-analysis-table {
  width: 100% !important;
  height: 100% !important;
  table-layout: fixed !important;
  font-size: 13px !important;
}

body.app-shell .department-analysis-card .department-analysis-table th,
body.app-shell .department-analysis-card .department-analysis-table td {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

body.app-shell .department-analysis-card .department-analysis-actions {
  min-height: 38px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex-direction: row !important;
  gap: 8px !important;
}

body.app-shell .department-analysis-card .department-analysis-actions button {
  width: auto !important;
  min-width: 96px !important;
  min-height: 36px !important;
  padding: 0 16px !important;
  white-space: nowrap !important;
}

@media (max-width: 1024px), (pointer: coarse) {
  body.app-shell .department-analysis-layer,
  body.app-shell .context-menu button[data-context-action="department-analysis"] {
    display: none !important;
  }
}

/* 部门数据分析是桌面统计表，保持单屏展示，不参与通用移动端弹窗规则。 */
body.app-shell .department-analysis-layer {
  z-index: 120;
  padding: 16px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.42);
}

body.app-shell .department-analysis-card {
  box-sizing: border-box;
  width: min(1280px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: hidden;
}

body.app-shell .department-analysis-card .department-analysis-head {
  flex: 0 0 auto;
}

body.app-shell .department-analysis-card .department-analysis-toolbar {
  flex: 0 0 auto;
}

body.app-shell .department-analysis-card .department-analysis-summary {
  flex: 0 0 auto;
}

body.app-shell .department-analysis-card .department-analysis-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body.app-shell .department-analysis-card .department-analysis-actions {
  flex: 0 0 auto;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

body.app-shell .department-analysis-card .department-analysis-actions button {
  width: auto;
  min-width: 96px;
  min-height: 36px;
  padding: 0 16px;
  white-space: nowrap;
}

body.app-shell .department-analysis-card .department-analysis-table {
  width: 100%;
  height: 100%;
  table-layout: fixed;
  font-size: 12px;
}

body.app-shell .department-analysis-card .department-analysis-table th,
body.app-shell .department-analysis-card .department-analysis-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.app-shell .department-analysis-card .department-analysis-table th {
  padding: 6px 4px;
}

body.app-shell .department-analysis-card .department-analysis-table td {
  padding: 5px 4px;
}

body.app-shell .department-analysis-card .department-analysis-table thead tr:first-child {
  height: 34px;
}

body.app-shell .department-analysis-card .department-analysis-table thead tr:last-child {
  height: 30px;
}

@media (max-width: 860px) {
  body.app-shell .department-analysis-layer,
  body.app-shell .context-menu button[data-context-action="department-analysis"] {
    display: none !important;
  }
}

@media (max-width: 1024px), (pointer: coarse) {
  body.app-shell .department-analysis-layer,
  body.app-shell .context-menu button[data-context-action="department-analysis"] {
    display: none !important;
  }
}

.department-analysis-layer {
  z-index: 120;
  padding: 16px;
  background: rgba(15, 23, 42, 0.42);
}

.department-analysis-card {
  width: min(1280px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  min-height: 560px;
  padding: 20px;
  gap: 14px;
  overflow: hidden;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.department-analysis-head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.department-analysis-head h2 {
  margin: 0;
  color: #0f172a;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.department-analysis-head p {
  margin: 5px 0 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.department-analysis-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 170px auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid #dbe5f0;
  border-radius: 8px;
  background: #f8fbff;
}

.department-analysis-toolbar label,
.department-analysis-period {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.department-analysis-toolbar label span,
.department-analysis-period span {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.department-analysis-period strong {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid #dbe5f0;
  border-radius: 6px;
  background: #fff;
  color: #1e293b;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.department-analysis-toolbar input {
  width: 100%;
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
}

.department-analysis-toolbar .primary-btn {
  min-height: 36px;
  white-space: nowrap;
}

.department-analysis-summary {
  min-height: 18px;
  color: #2563eb;
  font-size: 12px;
  font-weight: 800;
}

.department-analysis-table-wrap {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.department-analysis-table {
  width: 100%;
  height: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  color: #1e293b;
  font-size: 13px;
}

.department-analysis-table th,
.department-analysis-table td {
  border: 1px solid #b9c6d6;
  padding: 8px 6px;
  text-align: center;
  vertical-align: middle;
  line-height: 1.25;
}

.department-analysis-table thead th {
  background: #eaf2ff;
  color: #17365f;
  font-weight: 900;
}

.department-analysis-table thead tr:first-child th:not(:first-child) {
  background: #dceaff;
  font-size: 14px;
}

.department-analysis-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.department-analysis-table tbody td:first-child {
  width: 18%;
  color: #0f172a;
  font-weight: 800;
}

.department-analysis-table td.is-number {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.department-analysis-table tbody tr.is-total {
  background: #e5efff;
}

.department-analysis-table tbody tr.is-total td {
  color: #0f3d89;
  font-weight: 900;
}

.department-analysis-empty {
  display: grid;
  gap: 7px;
  padding: 36px 20px;
  color: #64748b;
  text-align: center;
}

.department-analysis-empty strong {
  color: #1e3a5f;
  font-size: 16px;
  font-weight: 900;
}

.department-analysis-empty span {
  font-size: 12px;
  font-weight: 600;
}

.department-analysis-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.department-analysis-actions button {
  min-width: 104px;
}

@media (max-width: 860px) {
  .department-analysis-card {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
    min-height: 0;
    padding: 12px;
    gap: 9px;
  }

  .department-analysis-head h2 {
    font-size: 17px;
  }

  .department-analysis-toolbar {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    padding: 8px;
  }

  .department-analysis-period {
    grid-column: 1 / -1;
  }

  .department-analysis-toolbar .primary-btn {
    width: 100%;
  }

  .department-analysis-table {
    font-size: 10px;
  }

  .department-analysis-table th,
  .department-analysis-table td {
    padding: 5px 2px;
  }

  .department-analysis-table thead tr:first-child th:not(:first-child) {
    font-size: 11px;
  }

  .department-analysis-table tbody td:first-child {
    width: 17%;
  }

  .department-analysis-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .department-analysis-actions button {
    min-width: 0;
    width: 100%;
    padding: 7px 4px;
    font-size: 12px;
  }
}

/* 规则弹窗：带挑战者的小游戏使用紧凑参数行 */
.interaction-rule-layer.is-compact-rule .interaction-rule-config {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(112px, 132px) minmax(0, 1fr);
  gap: 12px 14px;
  align-items: end;
}

.interaction-rule-layer.is-bomb-rule .interaction-rule-config {
  grid-template-columns: minmax(220px, 260px) minmax(96px, 112px) minmax(96px, 112px) minmax(0, 1fr);
}

.interaction-rule-layer.is-compact-rule [data-interaction-rule-challenger-field] {
  min-width: 0;
  grid-column: 1 / 2;
  grid-row: 1;
}

.interaction-rule-layer.is-compact-rule .interaction-rule-param-grid {
  display: contents;
}

.interaction-rule-layer.is-compact-rule .interaction-rule-param-grid > label,
.interaction-rule-layer.is-compact-rule .interaction-rule-param-grid input,
.interaction-rule-layer.is-compact-rule .interaction-rule-param-grid select {
  min-width: 0;
}

.interaction-rule-layer.is-bomb-rule .interaction-rule-bomb-min-field {
  grid-column: 2 / 3;
  grid-row: 1;
}

.interaction-rule-layer.is-bomb-rule .interaction-rule-bomb-max-field {
  grid-column: 3 / 4;
  grid-row: 1;
}

.interaction-rule-layer.is-twentyfour-rule .interaction-rule-24-difficulty-field,
.interaction-rule-layer.is-order-puzzle-rule .interaction-rule-order-puzzle-mode-field,
.interaction-rule-layer.is-sudoku-rule .interaction-rule-sudoku-mode-field,
.interaction-rule-layer.is-witch-rule .interaction-rule-poison-count-field {
  grid-column: 2 / 3;
  grid-row: 1;
}

.interaction-rule-layer.is-sudoku-rule .interaction-rule-note-row {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
}

.interaction-rule-layer.is-witch-rule .interaction-rule-clue-toggle,
.interaction-rule-layer.is-witch-rule .interaction-rule-find-all-toggle {
  min-height: 44px;
  align-self: center;
  justify-self: start;
}

.interaction-rule-layer.is-witch-rule .interaction-rule-clue-toggle {
  grid-column: 1 / 2;
  grid-row: 2;
}

.interaction-rule-layer.is-witch-rule .interaction-rule-find-all-toggle {
  grid-column: 2 / -1;
  grid-row: 2;
}

.interaction-rule-layer.is-witch-rule .interaction-rule-note-row {
  grid-column: 1 / -1;
  grid-row: 3;
  width: 100%;
  white-space: nowrap;
}

@media (orientation: portrait) {
  .interaction-rule-layer.is-compact-rule .interaction-rule-config {
    grid-template-columns: minmax(0, 1fr);
  }

  .interaction-rule-layer.is-compact-rule [data-interaction-rule-challenger-field],
  .interaction-rule-layer.is-bomb-rule .interaction-rule-bomb-min-field,
  .interaction-rule-layer.is-bomb-rule .interaction-rule-bomb-max-field,
  .interaction-rule-layer.is-twentyfour-rule .interaction-rule-24-difficulty-field,
  .interaction-rule-layer.is-order-puzzle-rule .interaction-rule-order-puzzle-mode-field,
  .interaction-rule-layer.is-sudoku-rule .interaction-rule-sudoku-mode-field,
  .interaction-rule-layer.is-witch-rule .interaction-rule-poison-count-field,
  .interaction-rule-layer.is-witch-rule .interaction-rule-clue-toggle,
  .interaction-rule-layer.is-witch-rule .interaction-rule-find-all-toggle,
  .interaction-rule-layer.is-witch-rule .interaction-rule-note-row {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .interaction-rule-layer.is-witch-rule .interaction-rule-note-row {
    white-space: normal;
  }
}

/* 课堂互动工具箱：游戏入口卡片版 */
.interaction-card {
  grid-template-rows: auto minmax(0, 1fr);
}

.interaction-card .interaction-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  overflow: hidden;
}

.interaction-card .interaction-panel.interaction-tools {
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 48px);
  border: 0;
  background: transparent;
  box-shadow: none;
}

.interaction-card .interaction-stage {
  display: none;
}

.interaction-card .interaction-tabs {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: repeat(5, minmax(132px, 168px));
  justify-content: center;
  align-content: center;
  gap: 18px;
}

body.app-shell .interaction-card .interaction-tabs .interaction-game-card,
.interaction-card .interaction-tabs .interaction-game-card {
  width: 168px;
  height: 136px;
  min-height: 136px;
  display: grid;
  grid-template-rows: 58px auto;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 18px 14px;
  border: 1px solid color-mix(in srgb, var(--game-color) 38%, var(--border));
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-bg) 84%, #fff), #fff),
    var(--panel);
  color: var(--game-color);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--game-color) 13%, transparent);
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

body.app-shell .interaction-card .interaction-tabs .interaction-game-card:hover,
body.app-shell .interaction-card .interaction-tabs .interaction-game-card:focus-visible,
.interaction-card .interaction-tabs .interaction-game-card:hover,
.interaction-card .interaction-tabs .interaction-game-card:focus-visible {
  border-color: var(--game-color);
  background: color-mix(in srgb, var(--game-bg) 78%, #fff);
  box-shadow: 0 14px 32px color-mix(in srgb, var(--game-color) 22%, transparent);
  outline: none;
}

body.app-shell .interaction-card .interaction-tabs .interaction-game-card.active,
.interaction-card .interaction-tabs .interaction-game-card.active {
  border-color: var(--game-color);
  background: color-mix(in srgb, var(--game-bg) 72%, #fff);
  color: var(--game-color);
}

.interaction-game-card img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  pointer-events: none;
}

body.app-shell .interaction-card .interaction-tabs .interaction-game-card span,
.interaction-card .interaction-tabs .interaction-game-card span {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--game-color);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interaction-game-card-random {
  --game-color: #2563eb;
  --game-bg: #dbeafe;
}

.interaction-game-card-bomb {
  --game-color: #dc2626;
  --game-bg: #fee2e2;
}

.interaction-game-card-detective {
  --game-color: #4338ca;
  --game-bg: #e0e7ff;
}

.interaction-game-card-twentyfour {
  --game-color: #ca8a04;
  --game-bg: #fef3c7;
}

.interaction-game-card-daydream {
  --game-color: #7c3aed;
  --game-bg: #ede9fe;
}

.interaction-game-card-witch {
  --game-color: #ea580c;
  --game-bg: #ffedd5;
}

.interaction-game-card-order-puzzle {
  --game-color: #0f766e;
  --game-bg: #ccfbf1;
}

.interaction-game-card-huarong {
  --game-color: #be123c;
  --game-bg: #ffe4e6;
}

.interaction-game-card-sudoku {
  --game-color: #0e7490;
  --game-bg: #cffafe;
}

.interaction-game-card-picado {
  --game-color: #111827;
  --game-bg: #f3f4f6;
}

.interaction-rule-param-grid .interaction-rule-note-row {
  grid-column: 1 / -1;
}

@media (orientation: portrait) {
  .interaction-card {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .interaction-card .interaction-panel.interaction-tools {
    padding: 16px 8px;
  }

  .interaction-card .interaction-tabs {
    grid-template-columns: repeat(2, minmax(136px, 152px));
    gap: 12px;
  }

  body.app-shell .interaction-card .interaction-tabs .interaction-game-card,
  .interaction-card .interaction-tabs .interaction-game-card {
    width: 152px;
    height: 124px;
    min-height: 124px;
    padding: 14px 10px;
  }

  .interaction-game-card img {
    width: 48px;
    height: 48px;
  }
}

/* 课堂互动工具箱：仅保留游戏入口，名单设置进入随机点名弹窗 */
.interaction-layout {
  grid-template-columns: minmax(0, 1fr);
}

.interaction-tools {
  min-width: 0;
}

.interaction-rule-student-list {
  grid-column: 1 / -1;
  max-height: min(360px, 38vh);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  overflow: auto;
  padding: 2px;
}

.interaction-rule-student {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 58px;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}

.interaction-rule-student input[type="checkbox"] {
  width: auto;
}

.interaction-rule-student input[type="number"] {
  min-height: 30px;
  padding: 4px 7px;
  border-radius: 7px;
}

.interaction-rule-student span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.interaction-rule-student strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interaction-rule-student em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.classroom-game-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  overflow-x: hidden;
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font-body);
}

.classroom-game-header,
.classroom-game-status-card,
.classroom-game-alert,
.classroom-game-side,
.classroom-game-board {
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.classroom-game-header {
  position: relative;
  min-width: 0;
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
}

.classroom-game-header.has-best-record {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.classroom-game-heading-pack {
  position: relative;
  min-width: 0;
  justify-self: center;
  display: inline-grid;
  place-items: center;
}

.classroom-game-title {
  min-width: 0;
  text-align: center;
}

.classroom-game-header.has-best-record .classroom-game-title {
  min-width: 0;
}

.classroom-best-slot {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  min-width: 0;
  width: 184px;
  max-width: 184px;
}

.classroom-game-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.classroom-game-title h1 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1.1;
  letter-spacing: 0;
}

.classroom-best-bubble {
  position: relative;
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 5px 8px 5px 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
  border-radius: 12px 12px 12px 5px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 76%, var(--panel)), var(--panel));
  box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--text);
  text-align: left;
}

.classroom-best-bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-left: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
  background: color-mix(in srgb, var(--primary-soft) 76%, var(--panel));
  transform: rotate(45deg);
}

.classroom-best-bubble time,
.classroom-best-bubble span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classroom-best-bubble strong {
  min-width: 0;
  overflow: hidden;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classroom-best-bubble em {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classroom-best-bubble.is-empty strong {
  color: var(--muted);
}

.classroom-game-clock {
  justify-self: end;
  min-width: 136px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--input-bg);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.classroom-game-alert {
  padding: 12px 14px;
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  color: var(--danger);
  font-weight: 800;
}

.classroom-game-status-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.classroom-game-status-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.classroom-game-status-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.classroom-game-status-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classroom-game-status-card.accent {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 82%, var(--panel)), var(--panel));
}

.classroom-game-action-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.classroom-game-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.classroom-game-actions button {
  min-height: 34px;
  padding: 0 12px;
}

.classroom-game-page.is-running .classroom-game-actions {
  display: none;
}

.classroom-game-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
}

.classroom-game-side,
.classroom-game-board {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.classroom-game-panel-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.classroom-game-panel-head strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
}

.classroom-game-panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.random-call-roster {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 7px;
  overflow: auto;
}

.random-call-roster span {
  min-width: 0;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.random-call-board {
  place-items: center;
}

.random-call-spotlight {
  width: 100%;
  min-height: min(520px, 58vh);
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 72%, #fff), #fff);
  color: var(--primary);
  font-size: clamp(34px, 6vw, 76px);
  font-weight: 900;
  text-align: center;
}

.random-call-spotlight.is-rolling {
  animation: random-roll-pulse .45s ease-in-out infinite alternate;
}

.number-bomb-board,
.speed24-board {
  min-height: 0;
  place-items: center;
  align-content: center;
}

.number-bomb-board {
  min-height: 0;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  align-items: stretch;
  place-items: stretch;
  align-content: stretch;
}

.number-bomb-range-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.number-bomb-range {
  width: 100%;
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--danger) 24%, var(--border));
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, #fff7ed, #fee2e2);
  color: #991b1b;
  font-size: clamp(42px, 8vw, 110px);
  font-weight: 900;
}

.number-bomb-keypad {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 54%, var(--panel)), var(--panel));
}

.number-bomb-keypad-display {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.number-bomb-keypad-display input {
  pointer-events: none;
  user-select: none;
  caret-color: transparent;
  min-height: 58px;
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
  background: var(--input-bg);
  color: var(--text);
  font-size: clamp(24px, 4vw, 42px);
  font-weight: 900;
  text-align: center;
}

.number-bomb-keypad-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(58px, 1fr));
  gap: 10px;
}

.number-bomb-keypad-grid button {
  min-width: 0;
  min-height: 58px;
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: clamp(20px, 2.2vw, 30px);
  font-weight: 900;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.number-bomb-keypad-grid button:hover:not(:disabled),
.number-bomb-keypad-grid button:focus-visible:not(:disabled) {
  border-color: color-mix(in srgb, var(--primary) 60%, var(--border));
  background: color-mix(in srgb, var(--primary-soft) 62%, var(--panel));
  box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 16%, transparent);
}

.number-bomb-keypad-grid button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.number-bomb-keypad-clear {
  color: var(--muted) !important;
}

.number-bomb-keypad-submit {
  border-color: color-mix(in srgb, var(--primary) 62%, var(--border)) !important;
  background: var(--primary) !important;
  color: var(--primary-contrast, #fff) !important;
}

.number-detective-board {
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
}

.number-detective-history-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, #4338ca 22%, var(--border));
  border-radius: var(--card-radius);
  background:
    radial-gradient(circle at 16% 12%, color-mix(in srgb, #818cf8 22%, transparent), transparent 32%),
    linear-gradient(180deg, color-mix(in srgb, #eef2ff 62%, var(--panel)), var(--panel));
  overflow: hidden;
}

.number-detective-latest {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, #4338ca 26%, var(--border));
  border-radius: var(--control-radius);
  background: var(--panel);
  box-shadow: 0 14px 28px rgba(67, 56, 202, .1);
  color: var(--text);
}

.number-detective-latest span,
.number-detective-history-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.number-detective-latest strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #3730a3;
  font-size: clamp(30px, 5vw, 62px);
  line-height: 1.08;
  font-weight: 900;
}

.number-detective-latest p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.number-detective-latest.is-zero {
  border-color: color-mix(in srgb, var(--muted) 28%, var(--border));
  background: color-mix(in srgb, var(--muted) 8%, var(--panel));
}

.number-detective-latest.is-cool {
  border-color: color-mix(in srgb, #2563eb 34%, var(--border));
  background: linear-gradient(180deg, #eff6ff, var(--panel));
}

.number-detective-latest.is-warm {
  border-color: color-mix(in srgb, #0891b2 38%, var(--border));
  background: linear-gradient(180deg, #ecfeff, var(--panel));
}

.number-detective-latest.is-hot,
.number-detective-latest.is-win {
  border-color: color-mix(in srgb, #16a34a 42%, var(--border));
  background: linear-gradient(180deg, #ecfdf5, var(--panel));
}

.number-detective-latest.is-hot strong,
.number-detective-latest.is-win strong {
  color: #15803d;
}

.number-detective-history-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.number-detective-history-head em {
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.number-detective-history-list {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.number-detective-history-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  border-radius: var(--control-radius);
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .06);
}

.number-detective-history-card span,
.number-detective-history-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.number-detective-history-card strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.number-detective-history-card.is-zero {
  opacity: .72;
  background: color-mix(in srgb, var(--muted) 7%, var(--panel));
}

.number-detective-history-card.is-cool {
  border-color: color-mix(in srgb, #2563eb 26%, var(--border));
}

.number-detective-history-card.is-warm {
  border-color: color-mix(in srgb, #0891b2 32%, var(--border));
  background: linear-gradient(180deg, #ecfeff, var(--panel));
}

.number-detective-history-card.is-hot,
.number-detective-history-card.is-win {
  border-color: color-mix(in srgb, #16a34a 40%, var(--border));
  background: linear-gradient(180deg, #ecfdf5, var(--panel));
}

.number-detective-history-card.is-hot strong,
.number-detective-history-card.is-win strong {
  color: #15803d;
}

.number-detective-keypad .number-bomb-keypad-display input {
  letter-spacing: 0;
}

.number-detective-result-layer {
  position: fixed;
  inset: 0;
  z-index: 2300;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .48);
}

.number-detective-result-layer[hidden] {
  display: none !important;
}

.number-detective-result-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid color-mix(in srgb, #16a34a 38%, var(--border));
  border-radius: var(--card-radius);
  background: var(--modal-bg);
  box-shadow: var(--shadow-strong);
  color: var(--text);
  text-align: center;
}

.number-detective-result-card span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.number-detective-result-card h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

.number-detective-result-card strong {
  overflow-wrap: anywhere;
  color: #15803d;
  font-size: clamp(34px, 7vw, 64px);
  line-height: 1;
  font-weight: 900;
}

.number-detective-result-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.number-detective-result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.number-huarong-board {
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 310px);
  align-items: stretch;
  place-items: stretch;
  align-content: stretch;
}

.number-huarong-play-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.number-huarong-board-wrap {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.number-huarong-grid {
  --huarong-size: 4;
  width: min(100%, 680px, 72vh);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, #be123c 26%, var(--border));
  border-radius: var(--card-radius);
  background:
    radial-gradient(circle at 22% 18%, rgba(251, 113, 133, .2), transparent 32%),
    linear-gradient(145deg, #fff1f2, color-mix(in srgb, var(--panel) 88%, #ffe4e6));
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, .62), 0 22px 42px rgba(15, 23, 42, .12);
  touch-action: manipulation;
}

.number-huarong-tile,
.number-huarong-blank {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% / var(--huarong-size));
  height: calc(100% / var(--huarong-size));
  transform: translate(0, 0);
}

.number-huarong-tile {
  z-index: 2;
  display: grid;
  place-items: center;
  border: clamp(3px, .7vw, 7px) solid transparent;
  border-radius: clamp(10px, 1.7vw, 18px);
  background:
    linear-gradient(145deg, #fff, #ffe4e6) padding-box,
    linear-gradient(145deg, rgba(190, 18, 60, .32), rgba(251, 113, 133, .18)) border-box;
  color: #881337;
  box-shadow: inset 0 -6px 0 rgba(190, 18, 60, .12), 0 14px 24px rgba(190, 18, 60, .14);
  cursor: pointer;
  font-size: clamp(20px, 4.6vw, 48px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  transition:
    transform .14s cubic-bezier(.22, 1, .36, 1),
    box-shadow .16s ease,
    filter .16s ease,
    opacity .16s ease;
  will-change: transform;
}

.number-huarong-tile:hover:not(:disabled),
.number-huarong-tile:focus-visible:not(:disabled) {
  filter: brightness(1.03);
  box-shadow: inset 0 -6px 0 rgba(190, 18, 60, .12), 0 18px 32px rgba(190, 18, 60, .2);
  outline: none;
}

.number-huarong-tile:active:not(:disabled) {
  filter: brightness(.98);
  box-shadow: inset 0 -3px 0 rgba(190, 18, 60, .16), 0 10px 18px rgba(190, 18, 60, .12);
}

.number-huarong-tile:disabled {
  cursor: default;
}

.number-huarong-blank {
  z-index: 1;
  border: clamp(4px, .8vw, 8px) solid transparent;
  border-radius: clamp(10px, 1.7vw, 18px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .48), rgba(251, 113, 133, .1)) padding-box;
  box-shadow: inset 0 0 18px rgba(190, 18, 60, .18);
  transition: transform .14s cubic-bezier(.22, 1, .36, 1);
}

.number-huarong-side {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, #be123c 20%, var(--border));
  border-radius: var(--card-radius);
  background:
    radial-gradient(circle at 86% 12%, rgba(251, 113, 133, .18), transparent 30%),
    linear-gradient(180deg, #fff1f2, var(--panel));
}

.number-huarong-stat {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, #be123c 18%, var(--border));
  border-radius: var(--control-radius);
  background: var(--panel);
}

.number-huarong-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.number-huarong-stat strong {
  min-width: 0;
  overflow: hidden;
  color: #9f1239;
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 900;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.number-huarong-stat em {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.4;
}

.number-huarong-answer-btn {
  position: fixed;
  right: clamp(14px, 2.2vw, 28px);
  bottom: clamp(14px, 2.2vw, 28px);
  z-index: 1200;
  min-width: 112px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid color-mix(in srgb, #be123c 42%, var(--border));
  border-radius: 999px;
  background: #be123c;
  color: #fff;
  box-shadow: 0 16px 34px rgba(190, 18, 60, .28);
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.number-huarong-answer-btn:hover:not(:disabled),
.number-huarong-answer-btn:focus-visible:not(:disabled) {
  background: #9f1239;
  border-color: #9f1239;
  box-shadow: 0 20px 42px rgba(190, 18, 60, .34);
  outline: none;
}

.number-huarong-answer-btn:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.number-huarong-result-layer {
  position: fixed;
  inset: 0;
  z-index: 2300;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .48);
}

.number-huarong-result-layer[hidden] {
  display: none !important;
}

.number-huarong-result-card {
  width: min(540px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid color-mix(in srgb, #be123c 36%, var(--border));
  border-radius: var(--card-radius);
  background: var(--modal-bg);
  box-shadow: var(--shadow-strong);
  color: var(--text);
  text-align: center;
}

.number-huarong-result-card span {
  color: #be123c;
  font-size: 12px;
  font-weight: 900;
}

.number-huarong-result-card h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

.number-huarong-result-card strong {
  overflow-wrap: anywhere;
  color: #9f1239;
  font-size: clamp(30px, 6vw, 54px);
  line-height: 1;
  font-weight: 900;
}

.number-huarong-result-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.number-huarong-result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.number-huarong-answer-layer {
  position: fixed;
  inset: 0;
  z-index: 2310;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .48);
}

.number-huarong-answer-layer[hidden] {
  display: none !important;
}

.number-huarong-answer-card {
  width: min(760px, 100%);
  max-height: min(78vh, 720px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 22px;
  border: 1px solid color-mix(in srgb, #be123c 32%, var(--border));
  border-radius: var(--card-radius);
  background: var(--modal-bg);
  box-shadow: var(--shadow-strong);
  color: var(--text);
}

.number-huarong-answer-card span {
  color: #be123c;
  font-size: 12px;
  font-weight: 900;
}

.number-huarong-answer-card h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.number-huarong-answer-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.number-huarong-answer-list {
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  overflow: auto;
  padding: 4px 2px 2px;
}

.number-huarong-answer-list span {
  min-width: 54px;
  min-height: 46px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, #be123c 24%, var(--border));
  border-radius: 10px;
  background: linear-gradient(145deg, #fff, #fff1f2);
  color: #881337;
}

.number-huarong-answer-list em {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ffe4e6;
  color: #9f1239;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.number-huarong-answer-list strong {
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
}

.number-huarong-answer-loading {
  width: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 1px solid color-mix(in srgb, #be123c 18%, var(--border));
  border-radius: var(--control-radius);
  background:
    radial-gradient(circle at 50% 24%, rgba(251, 113, 133, .14), transparent 34%),
    linear-gradient(180deg, #fff, #fff1f2);
  color: #881337;
  text-align: center;
}

.number-huarong-answer-loading i {
  width: 44px;
  height: 44px;
  border: 4px solid #ffe4e6;
  border-top-color: #be123c;
  border-radius: 999px;
  animation: huarong-answer-spin .8s linear infinite;
}

.number-huarong-answer-loading strong {
  font-size: 22px;
  font-weight: 900;
}

.number-huarong-answer-loading span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.number-huarong-answer-loading.is-error {
  background: linear-gradient(180deg, #fff7ed, #fff);
  color: #9a3412;
}

@keyframes huarong-answer-spin {
  to {
    transform: rotate(360deg);
  }
}

.picado-board {
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 310px);
  align-items: stretch;
  place-items: stretch;
}

.picado-field-wrap {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8px;
  border: 1px solid color-mix(in srgb, #111827 14%, var(--border));
  border-radius: var(--card-radius);
  background:
    radial-gradient(circle at 16% 14%, rgba(239, 68, 68, .12), transparent 28%),
    radial-gradient(circle at 82% 84%, rgba(17, 24, 39, .12), transparent 28%),
    linear-gradient(180deg, #fff, #f8fafc);
}

.picado-field {
  --picado-rows: 7;
  --picado-cols: 13;
  --picado-dot-size: clamp(16px, 1.65vw, 24px);
  --picado-line-thickness: clamp(6px, .72vw, 10px);
  --picado-aspect: 2;
  width: min(100%, 1320px, calc(92vh * var(--picado-aspect)));
  max-width: 100%;
  aspect-ratio: var(--picado-aspect) / 1;
  display: grid;
  align-items: stretch;
  justify-items: stretch;
  gap: 0;
  padding: clamp(12px, 1.5vw, 20px);
  border: 1px solid color-mix(in srgb, #111827 22%, var(--border));
  border-radius: var(--card-radius);
  background: #fff;
  box-shadow: inset 0 0 0 4px rgba(15, 23, 42, .035), 0 18px 30px rgba(15, 23, 42, .08);
  contain: layout paint;
  touch-action: manipulation;
}

.picado-dot {
  align-self: center;
  justify-self: center;
  position: relative;
  z-index: 2;
  width: var(--picado-dot-size);
  height: var(--picado-dot-size);
  border-radius: 999px;
  background: #0891b2;
  box-shadow: 0 0 0 4px #fff, 0 4px 10px rgba(8, 145, 178, .2);
}

.picado-line {
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(148, 163, 184, .28);
  cursor: pointer;
  transition: background .1s ease, opacity .1s ease;
}

.picado-line.horizontal {
  align-self: center;
  justify-self: stretch;
  width: calc(100% + var(--picado-dot-size));
  height: var(--picado-line-thickness);
  margin-inline: calc(var(--picado-dot-size) / -2);
}

.picado-line.vertical {
  align-self: stretch;
  justify-self: center;
  width: var(--picado-line-thickness);
  height: calc(100% + var(--picado-dot-size));
  margin-block: calc(var(--picado-dot-size) / -2);
}

.picado-line:hover:not(:disabled),
.picado-line:focus-visible:not(:disabled) {
  background: rgba(17, 24, 39, .38);
  outline: none;
}

.picado-line.is-owned.red {
  background: #dc2626;
  box-shadow: none;
}

.picado-line.is-owned.black {
  background: #111827;
  box-shadow: none;
}

.picado-line.is-last-move {
  z-index: 3;
  filter: brightness(1.08);
}

.picado-line.is-last-move.red {
  --picado-last-glow: rgba(220, 38, 38, .28);
  box-shadow: 0 0 0 5px rgba(220, 38, 38, .2);
}

.picado-line.is-last-move.black {
  --picado-last-glow: rgba(17, 24, 39, .24);
  box-shadow: 0 0 0 5px rgba(17, 24, 39, .18);
}

.picado-box {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: clamp(6px, 1vw, 12px);
  color: #fff;
  opacity: .1;
  transition: opacity .16s ease, background .16s ease, transform .16s ease;
}

.picado-box.is-owned {
  opacity: 1;
  transform: scale(.96);
}

.picado-box.is-owned.red {
  background: rgba(220, 38, 38, .1);
}

.picado-box.is-owned.red .picado-flag {
  filter: none;
}

.picado-box.is-owned.black {
  background: rgba(17, 24, 39, .08);
}

.picado-box.is-owned.black .picado-flag {
  filter: none;
}

.picado-flag {
  display: block;
  width: min(76%, 58px);
  height: auto;
  object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
  .picado-line,
  .picado-box {
    transition: none;
  }
}

.picado-side {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, #111827 18%, var(--border));
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.picado-score-card,
.picado-info-card {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--panel);
}

.picado-score-card span,
.picado-info-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.picado-score-card strong,
.picado-info-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(20px, 2.8vw, 34px);
  font-weight: 900;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picado-score-card em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
}

.picado-score-card.red {
  border-color: rgba(220, 38, 38, .28);
}

.picado-score-card.red strong {
  color: #dc2626;
}

.picado-score-card.black {
  border-color: rgba(17, 24, 39, .26);
}

.picado-score-card.black strong {
  color: #111827;
}

.picado-score-card.is-active {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .1), 0 14px 28px rgba(15, 23, 42, .08);
}

.picado-score-card.black.is-active {
  box-shadow: 0 0 0 3px rgba(17, 24, 39, .1), 0 14px 28px rgba(15, 23, 42, .08);
}

.picado-result-layer {
  position: fixed;
  inset: 0;
  z-index: 2300;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .5);
}

.picado-result-layer[hidden] {
  display: none !important;
}

.picado-result-card {
  width: min(540px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid color-mix(in srgb, #111827 28%, var(--border));
  border-radius: var(--card-radius);
  background: var(--modal-bg);
  box-shadow: var(--shadow-strong);
  color: var(--text);
  text-align: center;
}

.picado-result-card span {
  color: #dc2626;
  font-size: 12px;
  font-weight: 900;
}

.picado-result-card h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

.picado-result-card strong {
  color: #111827;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
  font-weight: 900;
}

.picado-result-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.picado-result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.number-bomb-guess-row {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.number-bomb-board p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.speed24-number-grid {
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.speed24-number-grid span {
  min-height: 150px;
  display: grid;
  place-items: center;
  border-radius: var(--card-radius);
  font-size: clamp(42px, 7vw, 88px);
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(15, 23, 42, .08), 0 14px 30px rgba(15, 23, 42, .08);
}

.speed24-answer-card {
  width: min(720px, 100%);
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}

.order-puzzle-page {
  position: relative;
}

.order-puzzle-board {
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  place-items: stretch;
  overflow: hidden;
}

.order-puzzle-feedback {
  min-width: 0;
  overflow: hidden;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  border-radius: var(--control-radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 74%, var(--panel)), var(--panel));
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-puzzle-grid {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(54px, 1fr));
  gap: 10px;
  align-content: center;
  align-items: center;
}

.order-puzzle-tile {
  position: relative;
  min-width: 0;
  min-height: clamp(92px, 13vw, 170px);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 10px;
  border: 2px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  border-radius: var(--card-radius);
  background:
    radial-gradient(circle at 30% 18%, color-mix(in srgb, var(--accent-soft) 54%, transparent), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 42%, var(--panel)), var(--panel));
  box-shadow: inset 0 -5px 0 rgba(15, 23, 42, .08), 0 14px 26px rgba(15, 23, 42, .08);
  cursor: pointer;
  transform: translate(0, 0);
  transition:
    transform .4s cubic-bezier(.25, 1, .5, 1),
    border-color .18s ease,
    box-shadow .18s ease,
    opacity .18s ease,
    background .18s ease;
  will-change: transform;
}

.order-puzzle-tile:hover:not(:disabled),
.order-puzzle-tile:focus-visible:not(:disabled) {
  border-color: var(--primary);
  box-shadow: inset 0 -5px 0 rgba(15, 23, 42, .08), 0 18px 34px color-mix(in srgb, var(--primary) 18%, transparent);
  outline: none;
}

.order-puzzle-tile img {
  width: min(76%, 118px);
  height: min(76%, 118px);
  object-fit: contain;
  pointer-events: none;
}

.order-puzzle-tile span {
  position: absolute;
  right: 10px;
  bottom: 8px;
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.order-puzzle-tile.is-selected {
  border-color: var(--primary);
  background:
    radial-gradient(circle at 30% 18%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 38%),
    linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 72%, var(--panel)), var(--panel));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 34%, transparent), 0 18px 38px color-mix(in srgb, var(--primary) 22%, transparent);
}

.order-puzzle-tile.is-locked {
  cursor: not-allowed;
  filter: grayscale(.8);
  opacity: .58;
  border-color: color-mix(in srgb, var(--muted) 34%, var(--border));
  background: color-mix(in srgb, var(--muted) 12%, var(--panel));
}

.order-puzzle-tile.is-moving {
  z-index: 5;
  pointer-events: none;
}

.order-puzzle-confirm {
  justify-self: center;
  width: min(520px, 100%);
  min-height: 52px;
  font-size: 17px;
  font-weight: 900;
}

.order-puzzle-result-layer {
  position: fixed;
  inset: 0;
  z-index: 2300;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .46);
}

.order-puzzle-result-layer[hidden] {
  display: none !important;
}

.order-puzzle-result-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
  border-radius: var(--card-radius);
  background: var(--modal-bg);
  box-shadow: var(--shadow-strong);
  color: var(--text);
  text-align: center;
}

.order-puzzle-result-card span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.order-puzzle-result-card h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

.order-puzzle-result-card strong {
  color: var(--primary);
  font-size: clamp(32px, 6vw, 58px);
  line-height: 1;
}

.order-puzzle-result-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.order-puzzle-result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.sudoku-page {
  position: relative;
}

.sudoku-board {
  grid-template-columns: minmax(0, 2.35fr) minmax(0, 4.65fr) minmax(0, 3fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  align-items: stretch;
  align-content: stretch;
  justify-content: stretch;
  overflow: hidden;
}

.sudoku-side-panel,
.sudoku-keypad {
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: stretch;
  gap: 10px;
}

.sudoku-side-panel {
  width: 100%;
  justify-self: stretch;
  align-self: stretch;
  grid-auto-rows: minmax(0, 1fr);
}

.sudoku-info-card {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  border-radius: var(--control-radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 38%, var(--panel)), var(--panel));
}

.sudoku-info-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.sudoku-info-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(20px, 2.4vw, 32px);
  font-weight: 900;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sudoku-info-card em {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sudoku-restart-btn {
  width: 100%;
  min-height: 76px;
  border: 1px solid color-mix(in srgb, #d97706 58%, var(--border));
  border-radius: 14px;
  background:
    linear-gradient(180deg, #fff7ed 0%, #fcd34d 56%, #f59e0b 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .82),
    inset 0 -9px 0 rgba(146, 64, 14, .28),
    0 16px 0 rgba(146, 64, 14, .14),
    0 22px 30px rgba(217, 119, 6, .24);
  color: #7c2d12;
  font-size: 16px;
  font-weight: 900;
  transform: translateY(0);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.sudoku-restart-btn:hover:not(:disabled),
.sudoku-restart-btn:focus-visible:not(:disabled) {
  border-color: color-mix(in srgb, #f59e0b 68%, var(--border));
  background:
    linear-gradient(180deg, #fffaf0, color-mix(in srgb, #fbbf24 48%, var(--panel)));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .86),
    inset 0 -9px 0 rgba(146, 64, 14, .3),
    0 16px 0 rgba(146, 64, 14, .16),
    0 24px 32px color-mix(in srgb, #f59e0b 30%, transparent);
}

.sudoku-restart-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .72),
    inset 0 -3px 0 color-mix(in srgb, #92400e 22%, rgba(15, 23, 42, .08)),
    0 7px 14px color-mix(in srgb, #f59e0b 20%, transparent);
}

.sudoku-answer-btn {
  width: 100%;
  min-height: 44px;
}

.sudoku-grid-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: auto;
  height: min(100%, calc(100vh - 150px), 760px);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  justify-self: center;
  align-self: center;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  border-radius: var(--card-radius);
  background:
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--accent-soft) 42%, transparent), transparent 34%),
    linear-gradient(135deg, color-mix(in srgb, var(--panel) 88%, var(--primary-soft)), var(--bg-soft));
}

.sudoku-start-panel,
.sudoku-loading {
  width: min(100%, 360px);
  display: grid;
  gap: 8px;
  place-items: center;
  padding: 28px 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: var(--card-radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  text-align: center;
}

.sudoku-start-panel strong {
  color: var(--primary);
  font-size: clamp(26px, 4vw, 44px);
  font-weight: 900;
  line-height: 1.1;
}

.sudoku-start-panel span {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.6;
}

.sudoku-start-panel[hidden],
.sudoku-loading[hidden],
.sudoku-grid[hidden],
.sudoku-result-layer[hidden],
.sudoku-answer-layer[hidden] {
  display: none;
}

.sudoku-loading strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.sudoku-loading span {
  color: var(--muted);
  font-weight: 800;
}

.sudoku-grid {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  overflow: hidden;
  border: 3px solid color-mix(in srgb, var(--text) 78%, var(--primary));
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 74%, var(--border));
  box-shadow: 0 18px 38px rgba(15, 23, 42, .14);
}

.sudoku-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--text) 34%, var(--border));
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.sudoku-cell.thick-top {
  border-top-width: 3px;
}

.sudoku-cell.thick-left {
  border-left-width: 3px;
}

.sudoku-cell.thick-right {
  border-right-width: 3px;
}

.sudoku-cell.thick-bottom {
  border-bottom-width: 3px;
}

.sudoku-cell.is-given {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 66%, var(--panel)), color-mix(in srgb, var(--panel) 88%, var(--primary-soft)));
  cursor: default;
}

.sudoku-cell.is-editable {
  background: color-mix(in srgb, var(--panel) 92%, #fff);
}

.sudoku-cell.is-preview-filled {
  background: color-mix(in srgb, var(--panel) 96%, #fff);
}

.sudoku-cell.is-related {
  background: color-mix(in srgb, var(--primary-soft) 46%, var(--panel));
}

.sudoku-cell.is-selected {
  z-index: 1;
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, var(--panel));
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--primary) 46%, transparent);
}

.sudoku-cell.is-drop-target {
  z-index: 2;
  border-color: color-mix(in srgb, var(--primary) 72%, var(--border));
  background: color-mix(in srgb, var(--primary-soft) 74%, var(--panel));
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--primary) 46%, transparent);
}

.sudoku-cell.is-wrong {
  background: color-mix(in srgb, var(--danger) 16%, var(--panel));
  color: var(--danger);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--danger) 54%, transparent);
}

.sudoku-cell:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 44%, transparent);
  outline-offset: -3px;
}

.sudoku-cell img {
  width: min(76%, 52px);
  height: min(76%, 52px);
  object-fit: contain;
  pointer-events: none;
}

.sudoku-cell span {
  color: var(--text);
  font-size: clamp(18px, 3.1vw, 38px);
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.sudoku-keypad {
  width: 100%;
  justify-self: stretch;
  align-self: stretch;
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: stretch;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 54%, var(--panel)), var(--panel));
}

.sudoku-keypad-grid {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sudoku-keypad-grid button,
.sudoku-keypad-actions button {
  min-width: 0;
  min-height: 0;
  border-radius: 10px;
  font-size: clamp(20px, 2.2vw, 30px);
  font-weight: 900;
  cursor: pointer;
}

.sudoku-keypad-grid button {
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
  background: var(--panel);
  color: var(--text);
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
  touch-action: none;
}

.sudoku-keypad-grid button.is-touch-dragging {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-soft) 72%, var(--panel));
  box-shadow: 0 14px 26px color-mix(in srgb, var(--primary) 24%, transparent);
}

.sudoku-keypad-grid button:hover:not(:disabled),
.sudoku-keypad-grid button:focus-visible:not(:disabled) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-soft) 62%, var(--panel));
  box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 16%, transparent);
  outline: none;
}

.sudoku-keypad-grid button:disabled,
.sudoku-keypad-actions button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.sudoku-keypad-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sudoku-keypad-actions button {
  min-height: 68px;
}

.sudoku-keypad-actions .primary-btn {
  background: var(--primary);
  color: var(--primary-contrast, #fff);
}

.sudoku-result-layer,
.sudoku-answer-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .56);
  backdrop-filter: blur(8px);
}

.sudoku-result-card,
.sudoku-answer-card {
  width: min(460px, 100%);
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: var(--card-radius);
  background:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--accent-soft) 58%, transparent), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 50%, var(--panel)), var(--panel));
  box-shadow: 0 24px 62px rgba(15, 23, 42, .26);
  color: var(--text);
  text-align: center;
}

.sudoku-answer-card {
  width: min(620px, 100%);
}

.sudoku-result-card > span,
.sudoku-answer-card > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.sudoku-result-card h2,
.sudoku-answer-card h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.1;
}

.sudoku-result-card strong {
  color: var(--primary);
  font-size: clamp(34px, 7vw, 62px);
  font-weight: 900;
  line-height: 1;
}

.sudoku-result-card p,
.sudoku-answer-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.sudoku-answer-grid {
  width: min(100%, 480px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  overflow: hidden;
  border: 3px solid color-mix(in srgb, var(--text) 72%, var(--primary));
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 68%, var(--border));
}

.sudoku-answer-cell {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--text) 30%, var(--border));
  background: var(--panel);
  color: var(--text);
  font-size: clamp(16px, 3vw, 30px);
  font-weight: 900;
}

.sudoku-answer-cell.is-given {
  background: color-mix(in srgb, var(--primary-soft) 60%, var(--panel));
  color: var(--primary);
}

.sudoku-answer-cell.is-filled {
  background: color-mix(in srgb, var(--accent-soft) 46%, var(--panel));
}

.sudoku-answer-cell.thick-top {
  border-top-width: 3px;
}

.sudoku-answer-cell.thick-left {
  border-left-width: 3px;
}

.sudoku-answer-cell.thick-right {
  border-right-width: 3px;
}

.sudoku-answer-cell.thick-bottom {
  border-bottom-width: 3px;
}

.sudoku-result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

@media (orientation: portrait) {
  .classroom-game-page {
    min-height: 100svh;
    gap: 10px;
    padding: 10px;
  }

  .classroom-game-header {
    grid-template-columns: minmax(0, 1fr);
    text-align: center;
  }

  .classroom-game-header.has-best-record {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .classroom-game-heading-pack {
    width: 100%;
    display: grid;
    gap: 8px;
  }

  .classroom-best-slot,
  .classroom-best-bubble {
    width: 100%;
    min-width: 0;
  }

  .classroom-best-slot {
    position: static;
    transform: none;
    justify-self: stretch;
    width: 100%;
    max-width: none;
  }

  .classroom-best-bubble {
    text-align: center;
  }

  .classroom-best-bubble::before {
    left: 50%;
    top: -7px;
    transform: translateX(-50%) rotate(135deg);
  }

  .classroom-game-clock {
    justify-self: stretch;
    margin-left: 0;
  }

  .classroom-game-status-grid,
  .classroom-game-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .number-bomb-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .number-huarong-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .sudoku-board {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .sudoku-side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sudoku-restart-btn {
    grid-column: 1 / -1;
  }

  .sudoku-answer-btn {
    grid-column: 1 / -1;
  }

  .sudoku-grid-wrap {
    padding: 8px;
  }

  .sudoku-grid {
    width: min(100%, 92vw, 560px);
  }

  .sudoku-keypad-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sudoku-keypad-grid button,
  .sudoku-keypad-actions button {
    min-height: 50px;
  }

  .picado-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .picado-field-wrap {
    padding: 8px;
  }

  .picado-field {
    --picado-dot-size: clamp(12px, 3.8vw, 17px);
    --picado-line-thickness: clamp(6px, 2.2vw, 9px);
    width: 100%;
    aspect-ratio: var(--picado-aspect) / 1;
    gap: 0;
    padding: 8px;
  }

  .picado-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .picado-info-card strong,
  .picado-score-card strong {
    font-size: 22px;
  }

  .number-huarong-grid {
    width: min(100%, 430px);
  }

  .number-huarong-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .number-detective-history-panel {
    min-height: 300px;
  }

  .number-detective-latest {
    padding: 14px;
  }

  .number-detective-latest strong {
    font-size: clamp(26px, 9vw, 42px);
  }

  .number-detective-history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .number-bomb-range {
    min-height: 220px;
  }

  .number-bomb-keypad-grid {
    grid-template-rows: repeat(4, 56px);
  }

  .classroom-game-action-row,
  .number-bomb-guess-row {
    align-items: stretch;
    grid-template-columns: minmax(0, 1fr);
    flex-direction: column;
  }

  .classroom-game-actions,
  .classroom-game-actions button,
  .number-bomb-guess-row button {
    width: 100%;
  }

  .random-call-roster {
    max-height: 180px;
  }

  .random-call-spotlight {
    min-height: 260px;
  }

  .speed24-number-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .speed24-number-grid span {
    min-height: 110px;
  }

  .order-puzzle-board {
    gap: 10px;
  }

  .order-puzzle-feedback {
    white-space: normal;
  }

  .order-puzzle-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .order-puzzle-tile {
    min-height: clamp(68px, 18vw, 96px);
    padding: 7px;
  }

  .order-puzzle-tile span {
    right: 6px;
    bottom: 5px;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .order-puzzle-result-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .number-detective-result-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .sudoku-result-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .sudoku-answer-card {
    max-height: calc(100svh - 32px);
    overflow: auto;
  }

  .number-huarong-result-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
}

.page-watermark {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--watermark-col, 105px), 1fr));
  gap: var(--watermark-gap-y, 24px) var(--watermark-gap-x, 28px);
  align-content: start;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
  opacity: 0.12;
  mix-blend-mode: multiply;
}

.page-watermark span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  color: rgba(30, 41, 59, 0.34);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  white-space: nowrap;
  transform: rotate(-24deg);
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: none;
  min-height: 120px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.toast-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2400;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  color: #fff;
  font-size: 14px;
}

.toast-success { background: linear-gradient(135deg, #16a34a, #22c55e); }
.toast-error { background: linear-gradient(135deg, #dc2626, #f97316); }

.install-screen,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: var(--font-chrome);
  font-size: var(--font-size-chrome);
}

.login-screen {
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.install-card,
.login-panel {
  width: min(980px, 100%);
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.75);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.12);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  padding: 28px;
}

.install-card {
  width: min(860px, 100%);
}

.login-screen {
  background: var(--bg-soft);
  position: relative;
  overflow: hidden;
}

.login-wallpaper {
  position: absolute;
  inset: 0;
  background-image: var(--login-bg);
  background-size: cover;
  background-position: center;
  filter: saturate(0.98);
  opacity: 0.52;
}

.login-panel {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  margin: 0 auto;
}

.login-brand,
.install-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.login-brand img {
  width: clamp(118px, 28vw, 156px);
  height: 54px;
  object-fit: contain;
}

.login-brand > div {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.install-brand .brand-logo {
  width: clamp(126px, 18vw, 184px);
  height: 64px;
  object-fit: contain;
  flex: 0 0 auto;
}

.login-brand h1,
.install-brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  color: var(--text);
}

.login-brand p,
.install-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form,
.install-form {
  display: grid;
  gap: 14px;
}

.install-section-compact {
  gap: 8px;
}

.install-inline-note {
  min-height: 42px;
  display: flex;
  align-items: center;
}

.login-input-pill {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.76);
  box-shadow: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.login-input-pill:focus-within {
  border-color: rgba(24, 101, 242, 0.36);
  background: rgba(248, 250, 252, 0.76);
  box-shadow: none;
}

.login-input-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.login-input-icon img {
  width: 23px;
  height: 23px;
  object-fit: contain;
  opacity: 0.74;
}

.login-input-pill input {
  width: 100%;
  min-width: 0;
  height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #1f2937;
  font-size: 14px;
  font-weight: 650;
}

.login-input-pill input::placeholder {
  color: #9aa3af;
  font-weight: 500;
}

.login-input-pill input:-webkit-autofill,
.login-input-pill input:-webkit-autofill:hover,
.login-input-pill input:-webkit-autofill:focus {
  -webkit-text-fill-color: #1f2937;
  box-shadow: 0 0 0 1000px rgba(248, 250, 252, 0.76) inset;
  transition: background-color 9999s ease-out 0s;
}

.login-remember {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: fit-content;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  cursor: pointer;
}

.login-remember input {
  width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.api-settings-card {
  display: grid;
  gap: 14px;
}

.api-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.api-key-actions {
  margin: 0;
  justify-content: flex-end;
}

.api-doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.api-doc-card {
  display: grid;
  gap: 10px;
  align-content: start;
}

.api-doc-card h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.api-doc-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.api-code {
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.api-param-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.api-param-list span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.wecom-bot-card {
  display: grid;
  gap: 14px;
}

.wecom-bot-status {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.wecom-bot-status > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.wecom-bot-status strong {
  color: var(--text);
  font-size: 15px;
}

.wecom-bot-status span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.wecom-bot-card textarea {
  min-height: 150px;
  resize: vertical;
}

.wecom-head-toggles {
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.wecom-head-toggles .checkbox-item {
  min-height: 38px;
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.92);
}

.wecom-head-tools {
  flex: 1 1 640px;
  align-self: center;
  display: grid;
  grid-template-columns: repeat(6, minmax(86px, 1fr));
  gap: 8px;
  max-width: 860px;
}

.wecom-head-tools .secondary-btn {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.wecom-bot-layout {
  display: grid;
  gap: 16px;
}

.wecom-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.wecom-config-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 100%;
}

.wecom-config-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
}

.wecom-config-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.wecom-start-card .api-code {
  align-self: end;
}

.wecom-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.wecom-steps code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.wecom-identity-fields {
  display: grid;
  gap: 12px;
}

.wecom-guide {
  display: grid;
  gap: 10px;
}

.wecom-guide strong {
  color: var(--text);
  font-size: 13px;
}

.wecom-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.wecom-card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.wecom-card-save {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: auto;
  padding-top: 2px;
}

.wecom-variable-modal[hidden] {
  display: none !important;
}

.wecom-variable-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
}

.wecom-variable-dialog {
  width: min(620px, 100%);
  max-height: min(640px, calc(100vh - 48px));
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.wecom-config-dialog {
  width: min(760px, 100%);
  display: grid;
  gap: 14px;
}

.wecom-variable-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.wecom-variable-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
}

.wecom-variable-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.wecom-variable-head .modal-close-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.wecom-variable-head .modal-close-btn:hover {
  border-color: rgba(24, 101, 242, 0.26);
  background: var(--primary-soft);
  color: var(--primary);
}

.wecom-variable-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.wecom-variable-grid div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
  background: #f8fafc;
}

.wecom-variable-grid strong {
  color: var(--primary);
  font-size: 13px;
}

.wecom-variable-grid span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.wecom-command-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.wecom-command-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.wecom-command-table th,
.wecom-command-table td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.wecom-command-table td {
  padding: 9px 10px;
}

.wecom-command-table th {
  padding: 8px 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.wecom-command-table tr:last-child td {
  border-bottom: 0;
}

.wecom-command-table th:nth-child(1),
.wecom-command-table td:nth-child(1) {
  width: 104px;
}

.wecom-command-table th:nth-child(2),
.wecom-command-table td:nth-child(2) {
  width: 160px;
}

.wecom-command-table th:nth-child(4),
.wecom-command-table td:nth-child(4) {
  width: 270px;
}

.wecom-command-table th:nth-child(5),
.wecom-command-table td:nth-child(5) {
  width: 148px;
  text-align: center;
}

.wecom-command-table input[type="text"],
.wecom-command-table textarea,
.wecom-command-table select {
  width: 100%;
}

.wecom-command-cell {
  display: grid;
  gap: 7px;
  align-content: start;
}

.wecom-command-cell select {
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 12px;
}

.wecom-command-table textarea {
  min-height: 74px;
  resize: vertical;
}

.wecom-command-status .checkbox-item {
  min-height: 30px;
  padding: 0 8px;
  justify-content: flex-start;
  background: #fff;
  white-space: nowrap;
}

.wecom-command-permissions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.wecom-command-permissions .checkbox-item {
  box-sizing: border-box;
  width: 100%;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  gap: 5px;
  border-radius: 7px;
  font-size: 12px;
  background: #fff;
  white-space: nowrap;
}

.wecom-command-permissions .checkbox-item input {
  flex: 0 0 auto;
}

.wecom-command-permissions .checkbox-item span {
  min-width: 0;
}

.wecom-command-actions {
  text-align: center;
  white-space: nowrap;
}

.wecom-command-action-stack {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 74px;
}

.wecom-command-action-stack .tool-link {
  width: 64px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 12px;
}

.wecom-command-row.is-locked {
  background: #f8fafc;
}

.wecom-command-row.is-locked input[aria-disabled="true"],
.wecom-command-row.is-locked textarea[aria-disabled="true"],
.wecom-command-row.is-locked select[aria-disabled="true"] {
  pointer-events: none;
}

.wecom-command-row.is-locked .checkbox-item {
  pointer-events: none;
}

.wecom-command-row.is-locked input[readonly],
.wecom-command-row.is-locked textarea[readonly] {
  background: #f8fafc;
  color: var(--muted);
}

.wecom-command-row.is-locked [data-toggle-wecom-command-lock] {
  border-color: rgba(24, 101, 242, 0.28);
  background: var(--primary-soft);
  color: var(--primary);
}

.tool-link-danger {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.24);
  background: #fff;
}

.wecom-save-actions {
  margin: 0;
}

.install-section {
  display: grid;
  gap: 10px;
}

.section-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.db-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.db-choice-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.db-choice-card.is-active,
.db-choice-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 12px 26px var(--shadow);
}

.db-choice-card input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.db-choice-card strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
}

.db-choice-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.install-fixed-note {
  border: 1px dashed var(--border);
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.install-fixed-note strong {
  color: var(--text);
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.install-notice {
  align-self: stretch;
  border: 1px dashed var(--border);
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.primary-btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 22px var(--shadow);
  font-weight: 700;
}

.primary-btn.full {
  width: 100%;
}

.login-hint,
.bing-credit {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.bing-credit a {
  color: var(--primary);
}

.site-icp-link {
  color: color-mix(in srgb, var(--text) 62%, var(--muted));
  text-decoration: none;
  white-space: nowrap;
}

.site-icp-link:hover,
.site-icp-link:focus-visible {
  color: var(--primary);
  text-decoration: underline;
  outline: none;
}

.login-icp-link {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 1;
  transform: translateX(-50%);
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.app-frame {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg-soft);
}

.app-frame[data-page="entry"],
.app-frame[data-page="processing"] {
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  padding: 18px 16px;
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  overflow: hidden;
  font-family: var(--font-sidebar);
  font-size: var(--font-size-sidebar);
  min-width: 0;
}

.mobile-sidebar-toggle,
.mobile-sidebar-backdrop {
  display: none;
}

.mobile-sidebar-toggle {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 8px 18px rgba(15,23,42,0.08);
}

.mobile-sidebar-toggle span {
  display: block;
  width: 17px;
  height: 2px;
  border-radius: 99px;
  background: var(--text);
}

.app-frame > .topbar {
  grid-column: 1 / -1;
}

.app-frame > .bottom-bar {
  grid-column: 1 / -1;
}

.sidebar-brand,
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.sidebar-brand strong {
  display: block;
  font-size: calc(var(--font-size-sidebar) + 4px);
}

.sidebar-brand span {
  display: block;
  color: var(--muted);
  font-size: max(11px, calc(var(--font-size-sidebar) - 2px));
  margin-top: 2px;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary-soft);
}

.user-hi {
  font-weight: 700;
  margin-bottom: 2px;
}

.user-role {
  color: var(--muted);
  font-size: max(11px, calc(var(--font-size-sidebar) - 2px));
  line-height: 1.45;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
  align-content: start;
}

.sidebar-bottom {
  display: grid;
  align-content: end;
  gap: 10px;
  min-width: 0;
}

.version-chip {
  width: 100%;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255,255,255,0.96), var(--bg-soft));
  color: var(--muted);
  font-family: var(--font-table);
  font-size: var(--font-size-table);
  font-weight: 800;
  user-select: none;
}

.version-text {
  flex: 0 0 auto;
}

.version-author {
  margin-left: auto;
  color: var(--text);
  font-weight: 800;
}

.version-icon,
.result-count-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  line-height: 1;
  flex: 0 0 auto;
}

.version-icon {
  font-size: max(11px, calc(var(--font-size-table) - 2px));
}

.result-count-icon {
  font-size: max(11px, calc(var(--font-size-sidebar) - 2px));
}

.nav-item {
  position: relative;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px 8px 14px;
  background: rgba(255,255,255,0.88);
  color: var(--text);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.nav-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--primary);
  opacity: 0.38;
}

.nav-item:hover {
  border-color: rgba(24,101,242,0.26);
  background: var(--primary-soft);
  box-shadow: 0 6px 14px rgba(15,23,42,0.06);
}

.nav-item.active {
  color: var(--primary);
  background: #fff;
  border-color: rgba(24,101,242,0.30);
  box-shadow: 0 8px 18px rgba(24,101,242,0.10);
}

.nav-item.active::before {
  background: var(--primary);
  opacity: 1;
}

.nav-icon {
  width: 31px;
  height: 31px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #334155;
  border: 1px solid rgba(15,23,42,0.08);
  line-height: 1;
  flex: 0 0 auto;
}

.nav-icon img {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
}

.nav-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: max(12px, calc(var(--font-size-sidebar) - 1px));
  line-height: 1;
  letter-spacing: 0;
}

.nav-item.active .nav-icon {
  background: var(--primary);
  border-color: var(--primary);
}

.sidebar-meta {
  color: var(--muted);
  font-size: max(11px, calc(var(--font-size-sidebar) - 2px));
  line-height: 1.6;
  display: grid;
  gap: 6px;
}

.sidebar-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.excel-export-status {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 10px;
  border: 1px solid rgba(24, 101, 242, 0.18);
  border-radius: 10px;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
  color: var(--text);
  font-family: var(--font-sidebar);
  font-size: var(--font-size-sidebar);
  overflow: hidden;
}

.excel-export-status strong {
  font-size: max(12px, calc(var(--font-size-sidebar) - 1px));
  line-height: 1.2;
}

.excel-export-status span,
.excel-export-status small {
  color: var(--muted);
  font-size: max(11px, calc(var(--font-size-sidebar) - 2px));
  line-height: 1.5;
  min-width: 0;
  overflow-wrap: anywhere;
}

.excel-export-status.is-done {
  border-color: rgba(22, 163, 74, 0.24);
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
}

.excel-export-status.is-error {
  border-color: rgba(220, 38, 38, 0.22);
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
}

.excel-export-download,
.excel-export-retry {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: max(11px, calc(var(--font-size-sidebar) - 2px));
  text-align: center;
  white-space: normal;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.theme-toggle.logout {
  background: #fee2e2;
  color: #b91c1c;
}

.content {
  display: grid;
  grid-template-rows: 1fr;
  min-width: 0;
  overflow: auto;
  font-family: var(--font-other);
  font-size: var(--font-size-other);
}

.app-frame[data-page="entry"] .content {
  overflow: hidden;
}

.app-frame[data-page="processing"] .content {
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.94);
  font-family: var(--font-chrome);
  font-size: var(--font-size-chrome);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 8px;
  min-width: 230px;
}

.topbar-brand img {
  width: 112px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 auto;
}

.topbar-brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.15;
}

.topbar-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.badge,
.tool-link,
.more-btn,
.pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.tool-link {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

.more-btn {
  position: relative;
  gap: 7px;
  min-width: 82px;
  padding: 0 14px 0 9px;
  border: 0;
  isolation: isolate;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.24), rgba(255,255,255,0) 42%),
    linear-gradient(135deg, #1d4ed8 0%, #2563eb 45%, #4f46e5 100%);
  color: #fff;
  box-shadow:
    0 12px 26px rgba(37, 99, 235, 0.28),
    inset 0 1px 0 rgba(255,255,255,0.32);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.more-btn::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,0.18);
  pointer-events: none;
  z-index: -1;
}

.more-btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow:
    0 15px 30px rgba(37, 99, 235, 0.34),
    inset 0 1px 0 rgba(255,255,255,0.38);
}

.more-btn-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22);
  flex: 0 0 auto;
}

.more-btn-icon img {
  width: 17px;
  height: 17px;
  object-fit: contain;
  display: block;
}

.workspace {
  display: grid;
  gap: 14px;
  padding: 12px 18px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  font-family: var(--font-other);
  font-size: var(--font-size-other);
}

.workspace.processing-mode {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  align-content: stretch;
}

.entry-layout {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

@media (min-width: 1281px) and (max-width: 1440px) {
  .app-frame[data-page="entry"] .entry-layout {
    zoom: 0.93;
  }
}

@media (min-width: 1121px) and (max-width: 1280px) {
  .app-frame[data-page="entry"] .entry-layout {
    zoom: 0.86;
  }
}

.entry-panel,
.preview-panel,
.records-panel {
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15,23,42,0.05);
  min-width: 0;
}

.entry-panel {
  padding: 10px;
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
  gap: 12px;
  align-content: stretch;
  font-family: var(--font-entry-card);
  font-size: var(--font-size-entry-card);
}

.entry-panel button,
.entry-panel input,
.entry-panel select,
.entry-panel textarea {
  font-family: inherit;
}

.entry-fields {
  display: grid;
  gap: 11px;
}

.entry-field-card {
  position: relative;
  display: grid;
  min-height: 34px;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  color: var(--text);
}

.entry-field-label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 3px 6px 3px 5px;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.025);
}

.entry-field-label strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  font-size: var(--font-size-entry-card);
  line-height: 1;
  color: #0f172a;
  font-weight: 900;
}

.entry-icon-wrap {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e8fbf6;
  border: 1px solid #99f6e4;
}

.entry-icon-wrap img {
  width: 15px;
  height: 15px;
  object-fit: contain;
  display: block;
}

.entry-field-control {
  display: flex;
  align-items: stretch;
  min-width: 0;
  margin-left: -8px;
  border: 1px solid #d7dee8;
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: #fff;
  overflow: hidden;
}

.entry-field-control input,
.entry-field-control select {
  height: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 4px 9px 4px 17px;
  font-weight: 800;
  font-size: var(--font-size-entry-card);
  color: var(--text);
}

.entry-field-control input.is-readonly {
  background: #f8fafc;
  color: #64748b;
  cursor: default;
}

.entry-field-control input:focus,
.entry-field-control select:focus {
  box-shadow: inset 0 0 0 1px var(--primary-soft);
}

.grid-two.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grid-three.compact {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.two-textareas {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-self: stretch;
  min-height: 0;
  height: 100%;
}

.roster-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 260px;
  height: 100%;
  padding-top: 16px;
  color: var(--text);
  --roster-mask-top: 17px;
  --roster-mask-height: 24px;
  --roster-mask-left: 2px;
  --roster-mask-right: 20px;
}

.roster-card::before {
  content: "";
  position: absolute;
  left: var(--roster-mask-left);
  right: var(--roster-mask-right);
  top: var(--roster-mask-top);
  height: var(--roster-mask-height);
  z-index: 1;
  border-radius: 10px 0 0 0;
  background: #fff;
  pointer-events: none;
}

.roster-title {
  position: absolute;
  left: 14px;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: calc(100% - 18px);
}

.roster-icon-wrap {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.045);
}

.roster-icon-wrap img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.roster-title strong {
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  font-size: var(--font-size-entry-card);
  line-height: 1;
  font-weight: 900;
  color: #0b2f3f;
  background: #fff;
  padding: 2px 5px;
}

.roster-card textarea {
  position: relative;
  z-index: 0;
  min-height: 240px;
  height: 100%;
  padding: 29px 10px 10px;
  border: 1px solid #d7dee8;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  font-size: var(--font-size-entry-card);
  line-height: 1.6;
  text-align: center;
  text-align-last: center;
}

.entry-panel .primary-btn.full {
  align-self: end;
  min-height: 46px;
  font-size: max(14px, calc(var(--font-size-entry-card) + 2px));
}

.preview-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.preview-panel h2,
.records-panel h2 {
  margin: 0;
  font-size: 16px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.preview-grid > div {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 10px;
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.preview-grid span {
  color: var(--muted);
  font-size: 12px;
}

.preview-grid strong {
  font-size: 14px;
  word-break: break-all;
}

.preview-note {
  color: var(--muted);
  font-size: 12px;
}

.records-panel {
  padding: 0;
  display: grid;
  min-height: 0;
}

.entry-records-panel {
  align-self: stretch;
  display: grid;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.entry-records-panel .table-wrap {
  border-radius: 14px 14px 0 0;
}

.panel-head {
  padding: 0 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-meta {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  min-height: 0;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--font-size-table);
  font-family: var(--font-table);
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: #f3f4f6;
  z-index: 1;
  font-weight: 700;
  padding-right: 18px;
}

.data-table thead th.is-sortable {
  position: sticky;
  cursor: pointer;
  user-select: none;
}

.data-table thead th::after {
  content: "↕";
  position: absolute;
  right: 5px;
  top: 50%;
  width: 10px;
  text-align: center;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
}

.data-table thead th.is-sortable::after {
  opacity: 1;
}

.data-table thead th.is-sortable:hover,
.data-table thead th.is-sort-active {
  background: #eaf2ff;
  color: var(--primary);
}

.data-table thead th.is-sort-active::after {
  content: "↑";
  color: var(--primary);
}

.data-table thead th.is-sort-active[data-sort-direction="desc"]::after {
  content: "↓";
}

.data-table th,
.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tbody td {
  font-weight: 400;
}

.data-table th:last-child,
.data-table td:last-child {
  border-right: 0;
}

.empty-row td {
  height: 72px;
  color: var(--muted);
  background: #fff;
}

.data-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.data-table tbody tr:hover {
  background: var(--primary-soft);
}

[data-processing-row] {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.data-table tbody tr.is-new {
  background: #fff7d6;
  box-shadow: inset 4px 0 0 var(--primary);
}

.data-table tbody tr.is-new td {
  font-weight: 800;
}

.data-table-tight td,
.data-table-tight th {
  font-size: 12px;
  padding: 4px 5px;
  line-height: 1.18;
  height: 26px;
}

.data-table-tight[data-readonly-processing="1"] td,
.data-table-tight[data-readonly-processing="1"] th {
  padding: 3px 5px;
  line-height: 1.12;
  height: 24px;
}

.name-cell {
  text-align: left !important;
  max-width: 0;
  white-space: nowrap !important;
  line-height: 1.18;
  word-break: normal;
}

.data-table-tight[data-readonly-processing="1"] .name-cell {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap !important;
  line-height: 1.12;
}

.summary-data-table .col-summary-topic { width: 16%; }
.summary-data-table .col-summary-count { width: 8%; }
.summary-data-table .col-summary-flag { width: 5%; }

.summary-topic-cell {
  text-align: center !important;
}

.summary-ok {
  color: #15803d;
  font-weight: 800 !important;
}

.summary-empty {
  color: var(--muted);
  font-weight: 800 !important;
}

.bottom-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 30px;
  padding: 5px 18px;
  color: #74310f;
  font-family: var(--font-chrome);
  font-size: max(11px, calc(var(--font-size-chrome) - 2px));
  letter-spacing: 0;
  font-weight: 700;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.94);
}

.result-count-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text);
  white-space: nowrap;
}

.bottom-left,
.bottom-center,
.bottom-right {
  min-width: 0;
}

.bottom-center {
  justify-self: center;
  color: var(--muted);
  font-size: max(10px, calc(var(--font-size-chrome) - 3px));
  line-height: 1.4;
}

.bottom-right {
  justify-self: end;
  text-align: right;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.processing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 36px;
}

.department-processing-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 0;
}

.role-title {
  color: #c81e1e;
  font-weight: 800;
}

.teacher-rating {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 13px 3px 8px;
  border: 1px solid rgba(236,107,68,0.28);
  border-radius: 9px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffffff 54%, #eef6ff 100%);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(236,107,68,0.13);
  white-space: nowrap;
}

.processing-metrics {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.view-toggle-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-left: auto;
  margin-right: 16px;
  padding-left: 14px;
  border-left: 1px solid rgba(148, 163, 184, 0.28);
}

.view-toggle-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px 5px 9px;
  border: 1px solid rgba(148, 163, 184, 0.36);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, var(--bg-soft) 100%);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  white-space: nowrap;
  cursor: pointer;
}

.view-toggle-btn img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.excel-export-trigger {
  border-color: rgba(22, 163, 74, 0.24);
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
  color: #166534;
  margin-right: 4px;
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.12);
}

.teacher-rating.lesson-fee-card {
  border-color: rgba(40, 167, 69, 0.26);
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 54%, #fff7d6 100%);
  box-shadow: 0 10px 24px rgba(40, 167, 69, 0.12);
}

.teacher-rating img {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: block;
}

.teacher-rating span {
  line-height: 1;
  letter-spacing: 0;
}

.scope-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: 0;
}

.department-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  width: auto;
  min-width: 0;
  flex: 1 1 520px;
  flex-wrap: wrap;
}

.department-filter .department-entry-field {
  width: min(260px, calc(50% - 5px));
  max-width: 280px;
  min-width: 220px;
  grid-template-columns: 86px minmax(0, 1fr);
}

.department-filter .department-entry-field .entry-field-label {
  background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
}

.department-filter .department-entry-field .entry-icon-wrap {
  background: #eef6ff;
  border-color: #bfdbfe;
}

.department-filter .department-entry-field .entry-field-control select {
  width: 100%;
  min-width: 0;
}

.department-processing-head .scope-pills {
  flex: 0 0 auto;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 6px;
}

.pill {
  background: #eef2ff;
  color: #2f4fd7;
  min-height: 30px;
  border-radius: 8px;
  padding: 0 12px;
}

.processing-head .pill {
  min-height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 800;
}

.pill.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
}

.query-menu {
  position: relative;
}

.query-options {
  position: absolute;
  left: auto;
  right: 0;
  top: calc(100% + 6px);
  width: 166px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(15,23,42,0.12);
  padding: 6px;
  display: grid;
  gap: 4px;
  z-index: 7;
}

.query-options a,
.query-options button {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  text-align: left;
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 7px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
}

.query-options a:hover,
.query-options button:hover {
  background: #eef4ff;
  color: var(--primary);
  font-weight: 800;
}

.query-icon {
  position: relative;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  color: currentColor;
}

.query-icon::before,
.query-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.query-icon-range::before,
.query-icon-month::before,
.query-icon-year::before {
  inset: 1px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.query-icon-range::after {
  left: 3px;
  right: 3px;
  top: 5px;
  border-top: 1.5px solid currentColor;
}

.query-icon-yesterday::before,
.query-icon-return::before {
  left: 2px;
  top: 3px;
  width: 8px;
  height: 8px;
  border-left: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(45deg);
}

.query-icon-yesterday::after,
.query-icon-return::after {
  left: 5px;
  top: 6px;
  width: 7px;
  border-top: 1.7px solid currentColor;
}

.query-icon-week::before {
  left: 2px;
  top: 2px;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}

.query-icon-week::after {
  left: 4px;
  top: 5px;
  width: 6px;
  height: 5px;
  border-top: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}

.query-icon-month::after {
  left: 4px;
  top: 4px;
  width: 2px;
  height: 2px;
  box-shadow: 4px 0 0 currentColor, 0 4px 0 currentColor, 4px 4px 0 currentColor;
  background: currentColor;
}

.query-icon-year::after {
  left: 3px;
  top: 4px;
  width: 8px;
  height: 6px;
  border-top: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}

.custom-range {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.custom-range input {
  padding: 8px;
}

.full-height {
  min-height: 0;
  display: grid;
}

.processing-mode .records-panel {
  align-self: stretch;
  min-height: 0;
}

.processing-mode .table-wrap {
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 10px;
}

.processing-mode .data-table {
  min-width: 0;
}

.processing-mode .data-table-tight td,
.processing-mode .data-table-tight th {
  padding: 3px 5px;
  font-size: 12px;
  line-height: 1.16;
  height: 26px;
}

.processing-mode .data-table tbody tr {
  transition: background-color 0.14s ease, box-shadow 0.14s ease;
}

.processing-mode .data-table tbody tr:hover {
  background: #edf4ff;
  box-shadow: inset 3px 0 0 var(--primary);
  font-weight: 800;
}

.processing-mode .data-table .name-cell {
  padding-left: 6px;
  padding-right: 6px;
  text-align: center !important;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.16;
}

.processing-mode .data-table .tool-link-mini {
  min-height: 22px;
  padding: 0 7px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1;
}

.processing-mode .col-campus { width: 8.5%; }
.processing-mode .col-class { width: 5.5%; }
.processing-mode .col-textbook { width: 5.5%; }
.processing-mode .col-grade { width: 5.5%; }
.processing-mode .col-subject { width: 4.8%; }
.processing-mode .col-date { width: 8%; }
.processing-mode .col-time { width: 8%; }
.processing-mode .col-count { width: 3.8%; }
.processing-mode .col-actual-names { width: 28.6%; }
.processing-mode .col-trial-names { width: 14.2%; }

.student-mode {
  grid-template-rows: minmax(0, 1fr);
}

.student-profile-shell {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.student-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15,23,42,0.05);
}

.student-profile-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1.2;
}

.student-profile-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.student-profile-actions,
.student-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.student-search-form input,
.student-search-form select {
  width: auto;
  min-width: 128px;
  height: 34px;
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.student-search-form input {
  min-width: 230px;
}

.student-profile-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 12px;
}

.student-list-panel {
  min-height: 0;
  display: grid;
  overflow: hidden;
}

.student-table-wrap {
  min-height: 0;
  overflow: auto;
}

.student-profile-table th,
.student-profile-table td {
  height: 32px;
  padding: 5px 7px;
}

.student-profile-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-profile-side {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.student-side-block {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15,23,42,0.04);
}

.student-side-block strong {
  color: var(--text);
  font-size: 13px;
}

.student-side-block span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  font-weight: 700;
}

.student-profile-modal-card .modal-head {
  align-items: flex-start;
}

.student-profile-modal-card .modal-head h2,
.student-organizer-card .modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.student-profile-modal-card .modal-head p,
.student-organizer-card .modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.student-form-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  min-width: 0;
}

.student-form-tabs button {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.student-form-tabs button.active {
  background: var(--primary);
  color: #fff;
}

.student-form-body {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}

.student-form-section {
  display: none;
}

.student-form-section.active {
  display: block;
}

.student-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.student-form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* 宽屏下增加列数，避免宽弹窗里字段被拉得过宽、纵向滚动过长 */
@media (min-width: 1281px) {
  .student-form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .student-form-grid.compact {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .guardian-row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .guardian-row [data-remove-guardian] {
    justify-self: start;
    width: auto;
    min-width: 96px;
  }
}

.student-field {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.student-field span {
  line-height: 1;
}

.student-field input,
.student-field select,
.student-field textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
}

.student-field textarea {
  min-height: 88px;
  resize: vertical;
  text-align: left;
  text-align-last: auto;
  line-height: 1.5;
}

.student-check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.student-check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.guardian-editor {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.guardian-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  min-width: 0;
}

.guardian-row input {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px;
}

.guardian-row label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
}

.guardian-row .secondary-btn {
  min-width: 0;
  padding: 8px 10px;
}

.guardian-row label input {
  width: 15px;
  height: 15px;
}

.student-duplicate-panel {
  max-height: 140px;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
}

.student-duplicate-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, auto);
  gap: 8px;
  align-items: center;
  color: #9a3412;
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
}

.student-organizer-card {
  width: min(1100px, calc(100vw - 40px));
  height: min(720px, calc(100vh - 40px));
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.student-organizer-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
}

.student-organizer-list,
.student-organizer-detail {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.organizer-name-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-align: left;
}

.organizer-name-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.organizer-name-item em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.organizer-candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.organizer-candidate strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.organizer-candidate span,
.organizer-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  font-weight: 700;
}

.organizer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .student-profile-grid,
  .student-organizer-layout {
    grid-template-columns: 1fr;
  }

  .student-profile-side {
    display: none;
  }

  .student-form-grid,
  .student-form-grid.compact {
    grid-template-columns: 1fr;
  }

  .guardian-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (orientation: portrait) {
  .student-profile-modal-layer {
    padding: 10px;
    align-items: stretch;
  }

  .student-profile-modal-card {
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
    padding: 12px;
  }

  .student-form-grid,
  .student-form-grid.compact,
  .guardian-row,
  .student-duplicate-item {
    grid-template-columns: 1fr;
  }

  .student-form-tabs button {
    flex: 1 1 calc(33.333% - 6px);
    padding: 0 8px;
  }

  .student-profile-modal-card .modal-actions {
    flex-wrap: wrap;
  }

  .student-profile-modal-card .modal-actions button {
    flex: 1 1 120px;
  }
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 92;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.34);
}

.modal-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 22px 60px rgba(15,23,42,0.2);
  padding: 16px;
  display: grid;
  gap: 14px;
  font-family: var(--font-modal);
  font-size: var(--font-size-modal);
}

.modal-layer button,
.modal-layer input,
.modal-layer select,
.modal-layer textarea {
  font-family: inherit;
}

/* 学生档案弹窗（新建 / 查看）：桌面宽屏尺寸。
   必须排在 .modal-card 之后，否则会被 .modal-card 的窄宽度覆盖。 */
.student-profile-modal-card {
  width: min(1440px, calc(100vw - 56px));
  max-width: calc(100vw - 56px);
  height: min(840px, calc(100vh - 56px));
  max-height: calc(100vh - 56px);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  box-sizing: border-box;
}

.app-download-card {
  width: min(960px, calc(100vw - 40px));
  gap: 16px;
  padding: 18px;
}

.app-download-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-download-title img {
  width: 44px;
  height: 44px;
  padding: 9px;
  border-radius: 12px;
  background: var(--primary-soft);
  object-fit: contain;
}

.app-download-title h2 {
  margin: 0;
}

.app-download-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.app-download-body {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.app-platform-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

.app-platform-android {
  background: linear-gradient(180deg, #ffffff 0%, #f3fbff 100%);
  border-color: rgba(24, 101, 242, 0.18);
}

.app-platform-ios {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.app-platform-wecom {
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
  border-color: rgba(22, 163, 74, 0.2);
}

.app-platform-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-platform-head strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
}

.app-platform-head span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.app-qr-wrap {
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  background: #fff;
}

.app-qr-wrap canvas {
  width: 232px;
  height: 232px;
  max-width: 100%;
  border-radius: 8px;
  image-rendering: pixelated;
}

.app-bot-qr-wrap {
  min-height: 258px;
}

.app-bot-qr {
  width: 232px;
  height: 232px;
  max-width: 100%;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
}

.app-ios-placeholder {
  min-height: 258px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.46);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.app-ios-placeholder img {
  width: 50px;
  height: 50px;
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.app-ios-placeholder b {
  color: var(--text);
  font-size: 18px;
}

.app-ios-placeholder small {
  max-width: 190px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (orientation: portrait) {
  .app-download-card {
    width: 100%;
    max-width: 100%;
  }

  .app-download-body {
    grid-template-columns: 1fr;
  }

  .app-ios-placeholder {
    min-height: 180px;
  }

  .app-bot-qr-wrap {
    min-height: auto;
  }
}

@media (hover: none) and (pointer: coarse) {
  .app-download-trigger {
    display: none !important;
  }
}

.line-chart-card {
  width: min(1180px, calc(100vw - 40px));
  gap: 14px;
  padding: 18px;
}

.line-chart-card .modal-head {
  align-items: flex-start;
}

.line-chart-card h2 {
  margin: 0;
}

.line-chart-card .modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.line-chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.line-chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.line-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 18px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.legend-actual { background: #16a34a; }
.legend-expected { background: #2563eb; }

.line-chart-canvas-wrap {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.line-chart-canvas-wrap canvas {
  display: block;
  width: 1120px;
  max-width: 100%;
  min-width: 720px;
  height: auto;
}

.record-edit-card {
  width: min(900px, calc(100vw - 32px));
  gap: 12px;
  padding: 14px;
}

.record-edit-scroll,
.lesson-summary-scroll {
  display: contents;
}

.excel-export-card {
  width: min(760px, calc(100vw - 32px));
  gap: 14px;
  padding: 16px;
}

.excel-export-card .modal-head {
  align-items: flex-start;
}

.excel-export-card .modal-head h2 {
  margin: 0;
}

.excel-export-card .modal-head p {
  margin: 6px 0 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.7;
}

.excel-export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.excel-export-grid label,
.excel-export-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.excel-export-grid input,
.excel-export-field textarea {
  min-height: 38px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
}

.excel-export-grid input[readonly],
.excel-export-field textarea[readonly] {
  background: #f8fafc;
  color: #475569;
}

.excel-section-checks {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.excel-section-checks label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.excel-section-checks input {
  width: auto;
}

.lesson-summary-card {
  width: min(1320px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: visible;
  gap: 8px;
  padding: 12px;
}

.lesson-summary-card .modal-head {
  align-items: flex-start;
}

.lesson-summary-card .modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-record-strip,
.summary-students {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: linear-gradient(135deg, var(--bg-soft), #ffffff);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}

.summary-record-strip span,
.summary-students span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.28);
  white-space: nowrap;
}

.summary-students strong {
  color: var(--primary);
}

.summary-students em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
  color: var(--text);
  text-align: left;
}

.summary-students strong::after {
  content: "：";
  color: var(--muted);
  margin-left: 2px;
}

.summary-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.summary-form-grid .entry-field-card {
  grid-template-columns: 96px minmax(0, 1fr);
}

.summary-form-grid .entry-field-label {
  justify-content: flex-start;
}

.summary-form-grid .entry-field-control {
  align-items: stretch;
}

.summary-form-grid .entry-field-control input,
.summary-form-grid .entry-field-control textarea {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
  text-align: left;
}

.summary-form-grid .entry-field-control input {
  min-height: 34px;
  padding: 4px 9px 4px 17px;
}

.summary-roster-card {
  min-height: 164px;
  padding-top: 14px;
  --roster-mask-top: 17px;
  --roster-mask-height: 20px;
  --roster-mask-right: 22px;
}

.summary-roster-card .roster-title {
  left: 12px;
  justify-content: flex-start;
}

.summary-roster-card .roster-title strong {
  text-align: left;
}

.summary-roster-card textarea {
  min-height: 124px;
  height: 124px;
  padding: 25px 11px 9px;
  text-align: left;
  text-align-last: auto;
  resize: vertical;
}

.summary-detail-roster {
  min-height: 260px;
}

.summary-detail-roster::before {
  z-index: 3;
}

.summary-detail-roster textarea {
  min-height: 240px;
  height: 240px;
  font-weight: 600;
}

.summary-detail-roster .roster-title {
  right: 12px;
  z-index: 4;
  max-width: none;
}

.summary-math-toggle {
  margin-left: auto;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(24, 101, 242, 0.18);
  border-radius: 7px;
  background: #eef5ff;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: none;
}

.summary-math-toggle:hover {
  border-color: rgba(24, 101, 242, 0.32);
  background: #e4efff;
}

.summary-detail-roster.is-math-view::before {
  right: 126px;
}

.summary-detail-roster.is-math-view textarea {
  opacity: 0;
  pointer-events: none;
}

.summary-math-view {
  position: absolute;
  left: 0;
  right: 0;
  top: 16px;
  bottom: 0;
  z-index: 2;
  overflow: auto;
  padding: 31px 12px 12px;
  border: 1px solid #d7dee8;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.9;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.summary-math-view mjx-container {
  display: inline-block;
  line-height: 0;
  text-align: left;
  text-indent: 0;
  vertical-align: middle !important;
}

mjx-assistive-mml,
.summary-math-view mjx-assistive-mml {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  white-space: nowrap !important;
  border: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
}

.summary-math-view mjx-container[jax="SVG"] > svg {
  display: inline-block;
  overflow: visible;
  transform: translateY(-0.08em);
  vertical-align: middle !important;
}

.summary-math-view mjx-container[jax="SVG"] svg {
  vertical-align: middle;
}

.summary-math-view mjx-container[display="true"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  overflow-x: auto;
}

.summary-math-preview {
  margin-top: 10px;
  border: 1px solid #d7dee8;
  border-radius: 10px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
  overflow: hidden;
}

.summary-math-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #e5eaf2;
  background: rgba(248, 250, 252, 0.86);
}

.summary-math-preview-head strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.summary-math-preview-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.summary-math-preview-body {
  max-height: 180px;
  overflow: auto;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.8;
}

.math-inline,
.math-block {
  font-family: Georgia, "Times New Roman", "Microsoft YaHei", serif;
}

.math-inline {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 0 3px;
  color: #0f172a;
  vertical-align: middle;
  white-space: nowrap;
}

.math-block {
  display: flex;
  justify-content: center;
  max-width: 100%;
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  overflow-x: auto;
}

.math-frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  min-width: 18px;
  margin: 0 2px;
  line-height: 1.1;
  vertical-align: middle;
}

.math-num {
  width: 100%;
  padding: 0 3px 2px;
  border-bottom: 1px solid currentColor;
  text-align: center;
}

.math-den {
  padding: 2px 3px 0;
  text-align: center;
}

.math-sqrt {
  display: inline-flex;
  align-items: stretch;
  margin: 0 2px;
  vertical-align: middle;
}

.math-radical {
  padding-right: 2px;
  font-size: 1.1em;
  line-height: 1.1;
}

.math-root-body {
  padding: 0 3px;
  border-top: 1px solid currentColor;
}

.math-overline {
  display: inline-block;
  padding: 0 2px;
  text-decoration: overline;
}

.math-boxed {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid currentColor;
  border-radius: 4px;
}

.math-text {
  font-family: var(--font-modal);
}

.summary-top-row,
.summary-detail-field {
  grid-column: 1 / -1;
  position: relative;
}

.summary-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
}

.summary-word-limit-field {
  grid-template-columns: 92px minmax(0, 1fr) !important;
}

.student-mention-popover {
  position: fixed;
  z-index: 3;
  width: min(360px, calc(100vw - 20px));
  max-height: min(260px, calc(100vh - 24px));
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 38px rgba(15,23,42,0.16);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.student-mention-popover button {
  width: 100%;
  border: 0;
  min-width: 0;
  min-height: 30px;
  border-radius: 8px;
  padding: 5px 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-mention-popover button:hover,
.student-mention-popover button.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.lesson-summary-actions .ai-summary-btn {
  color: var(--primary);
  border-color: var(--primary-soft);
  background: var(--primary-soft);
}

.lesson-summary-actions {
  justify-content: space-between;
  align-items: center;
}

.lesson-summary-action-right {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.poster-generate-btn {
  color: #0f766e;
  border-color: rgba(20, 184, 166, 0.22);
  background: #ecfdf5;
}

.summary-poster-card {
  width: min(1120px, calc(100vw - 32px));
  gap: 12px;
  padding: 16px;
}

.summary-poster-card .modal-head {
  align-items: flex-start;
}

.summary-poster-card .modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.poster-options {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.poster-option-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  margin-right: 2px;
}

.poster-font-field {
  width: min(260px, 100%);
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.poster-font-field select {
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 12px;
}

.summary-poster-preview-wrap {
  min-height: 0;
  max-height: calc(100vh - 210px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  display: grid;
  place-items: start center;
  padding: 14px;
}

.summary-poster-preview-wrap canvas {
  display: block;
  width: min(100%, 640px);
  height: auto;
  border-radius: 12px;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.14);
}

.range-modal-card {
  width: min(460px, 100%);
}

.student-filter-card {
  width: min(420px, 100%);
}

.student-filter-card label {
  gap: 7px;
  font-weight: 800;
}

.student-filter-card input {
  min-height: 38px;
  font-weight: 800;
}

.temp-access-card {
  width: min(360px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.record-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.record-edit-fields {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px 12px;
}

.record-edit-fields .entry-field-card {
  grid-template-columns: 104px minmax(0, 1fr);
}

.record-edit-rosters {
  min-height: 210px;
}

.record-edit-rosters .roster-card {
  min-height: 210px;
  padding-top: 15px;
  --roster-mask-top: 15px;
}

.record-edit-rosters .roster-card textarea {
  min-height: 196px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.secondary-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.context-menu {
  position: fixed;
  z-index: 95;
  min-width: 176px;
  padding: 8px;
  display: grid;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 46px rgba(15,23,42,0.18);
  font-family: var(--font-other);
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.context-menu button:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

[data-record-context-menu] {
  min-width: 292px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

[data-record-context-menu] button {
  min-width: 0;
  justify-content: flex-start;
  white-space: nowrap;
}

.context-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #fff;
  color: currentColor;
  position: relative;
  flex: 0 0 auto;
}

.context-icon::before,
.context-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.context-icon-fill::before {
  width: 11px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.context-icon-fill::after {
  width: 8px;
  height: 2px;
  background: currentColor;
  transform: translate(2px, -1px);
}

.context-icon-summary::before {
  width: 12px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.context-icon-summary::after {
  width: 7px;
  height: 5px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(1px);
}

.context-icon-interaction::before {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.context-icon-interaction::after {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    -7px -5px 0 -1px currentColor,
    7px -5px 0 -1px currentColor;
}

.context-icon-report::before {
  width: 12px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.context-icon-report::after {
  width: 7px;
  height: 7px;
  right: 3px;
  bottom: 3px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  box-shadow: -1px -4px 0 -2px currentColor;
}

.context-icon-edit::before {
  width: 12px;
  height: 4px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-35deg);
}

.context-icon-edit::after {
  width: 5px;
  height: 5px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  right: 4px;
  bottom: 4px;
}

.context-icon-delete::before {
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-top: 0;
  bottom: 3px;
}

.context-icon-delete::after {
  width: 13px;
  height: 2px;
  background: currentColor;
  top: 4px;
}

.context-menu .danger {
  color: #8b1a1a;
}

.context-menu .danger:hover {
  color: #7f1d1d;
  background: #fee2e2;
}

.settings-drawer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.34);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 90;
}

.drawer-panel {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 18px 50px rgba(15,23,42,0.18);
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--font-modal);
  font-size: var(--font-size-modal);
}

.drawer-panel.drawer-large {
  width: min(780px, calc(100vw - 40px));
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-form textarea {
  min-height: 84px;
}

.privacy-toggle-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}

.privacy-toggle-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.appearance-toggle-box .privacy-toggle-actions {
  grid-template-columns: 1fr;
}

.privacy-toggle-box strong,
.privacy-toggle-box span {
  display: block;
}

.privacy-toggle-box strong {
  color: var(--text);
  font-size: 13px;
}

.privacy-toggle-box span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.settings-select-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 800;
}

.settings-select-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
}

.system-admin-role-box {
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  align-items: end;
}

.system-admin-role-select {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.lookup-extra-fields {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-soft);
}

.context-icon-copy::before {
  width: 10px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 2px;
  left: 4px;
  top: 3px;
  box-shadow: 3px 3px 0 -1px #fff, 3px 3px 0 0 currentColor;
}

.context-icon-filter::before {
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  top: 3px;
}

.context-icon-filter::after {
  width: 2px;
  height: 7px;
  background: currentColor;
  top: 10px;
}

.context-icon-chart::before {
  left: 3px;
  bottom: 4px;
  width: 12px;
  height: 9px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.context-icon-chart::after {
  left: 5px;
  top: 6px;
  width: 10px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: skew(-22deg) rotate(-18deg);
}

.context-icon-temporary-remove::before {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.context-icon-temporary-remove::after {
  width: 9px;
  height: 2px;
  background: currentColor;
  transform: rotate(-18deg);
}

.admin-shell {
  /* 固定侧边栏：整页高度锁定，只有右侧内容区滚动。 */
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  background: var(--bg-soft);
  overflow: hidden;
  font-family: var(--font-other);
  font-size: var(--font-size-other);
}

.admin-sidebar {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px 16px;
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,0.92);
  font-family: var(--font-sidebar);
  font-size: var(--font-size-sidebar);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.admin-brand {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.admin-brand img {
  width: 112px;
  height: 44px;
  object-fit: contain;
}

.admin-brand-text {
  display: grid;
  gap: 4px;
}

.admin-brand strong {
  display: block;
  font-size: calc(var(--font-size-sidebar) + 2px);
  line-height: 1.15;
}

.admin-brand span,
.admin-nav-item span {
  color: var(--muted);
  font-size: max(11px, calc(var(--font-size-sidebar) - 2px));
}

.admin-nav {
  display: grid;
  gap: 10px;
}

.admin-nav-item {
  display: grid;
  gap: 4px;
  padding: 12px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.admin-nav-item strong {
  font-size: var(--font-size-sidebar);
}

.admin-nav-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.admin-back-link {
  width: 100%;
  border-radius: 10px;
}

.admin-content {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 14px;
  padding: 18px;
  overflow: auto;
  align-content: start;
}

.account-capabilities {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  align-items: center;
}

.settings-form .account-capabilities .checkbox-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.account-capabilities input[type="checkbox"] {
  flex: 0 0 16px;
}

.admin-section-page {
  min-height: 0;
  display: grid;
  gap: 14px;
  align-content: start;
}

.admin-section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: stretch;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 10px 30px rgba(15,23,42,0.05);
}

.admin-section-head h2 {
  margin: 5px 0 6px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
}

.admin-section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-section-head > div:first-child {
  min-width: 0;
}

.admin-section-head > .tool-link {
  align-self: stretch;
  min-width: 104px;
  border-radius: 10px;
  font-weight: 800;
}

.admin-section-head > .lookup-cleanup-btn {
  color: #b45309;
  background: #fff7ed;
  border-color: #fed7aa;
}

.admin-section-head > .lookup-cleanup-btn:hover {
  color: #92400e;
  background: #ffedd5;
}

.admin-form-card {
  width: 100%;
  max-width: none;
}

.system-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.system-field,
.login-method-field {
  min-width: 0;
}

.login-method-field {
  grid-column: 1 / -1;
}

.system-field-wide,
.system-logo-uploader {
  grid-column: 1 / -1;
}

.system-inline-fields {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 1fr);
  gap: 10px;
  align-items: end;
}

.system-inline-fields > label:not(.checkbox-item) {
  min-width: 0;
}

.system-checkbox-field {
  min-height: 42px;
  margin: 0;
}

.system-calendar-card {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}

.system-classroom-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.system-classroom-setting-row .checkbox-item {
  min-width: 0;
}

.danger-outline-btn {
  border-color: color-mix(in srgb, var(--danger) 46%, var(--border));
  color: var(--danger);
}

.danger-outline-btn:hover,
.danger-outline-btn:focus-visible {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
}

.system-calendar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.system-calendar-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.system-calendar-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  font-weight: 700;
}

.system-calendar-head span {
  max-width: min(460px, 50%);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.calendar-events-field textarea {
  min-height: 168px;
  resize: vertical;
  line-height: 1.7;
  font-family: var(--font-settings);
}

.system-logo-uploader {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.system-logo-preview {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.system-logo-preview img {
  max-width: 100%;
  max-height: 68px;
  object-fit: contain;
}

.system-logo-controls {
  display: grid;
  gap: 8px;
  align-content: center;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

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

.watermark-density-field {
  display: grid;
  gap: 10px;
}

.watermark-density-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: center;
}

.watermark-density-control input[type="range"] {
  padding: 0;
}

.watermark-density-control span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.watermark-preview {
  --preview-watermark-col: 105px;
  --preview-watermark-gap-y: 18px;
  --preview-watermark-gap-x: 22px;
  height: 150px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--preview-watermark-col), 1fr));
  gap: var(--preview-watermark-gap-y) var(--preview-watermark-gap-x);
  align-content: start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.watermark-preview span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  color: rgba(30, 41, 59, 0.28);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  transform: rotate(-24deg);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(86px, 1fr));
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.checkbox-item input {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--primary);
}

.admin-form-actions {
  display: flex;
  justify-content: flex-start;
}

.admin-shell label {
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-shell input,
.admin-shell select,
.admin-shell textarea {
  color: var(--text);
  font-size: 13px;
}

.admin-shell input,
.admin-shell select {
  height: 40px;
  min-height: 40px;
  padding: 8px 10px;
}

.admin-shell input[type="file"] {
  height: auto;
  min-height: 40px;
  padding: 8px 10px;
}

.admin-shell textarea {
  min-height: 94px;
  padding: 10px;
  line-height: 1.55;
  resize: vertical;
}

.admin-shell .tool-link,
.admin-shell .primary-btn {
  border-radius: 8px;
  min-height: 34px;
}

.admin-shell .tool-link-mini {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.admin-shell .tool-link-mini.danger {
  color: #8b1a1a;
  border-color: #fecaca;
  background: #fff7f7;
}

.admin-shell .muted-cell {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
}

@media (orientation: portrait) {
  body {
    overflow: auto;
  }

  .app-frame,
  .app-frame[data-page="entry"],
  .app-frame[data-page="processing"],
  .app-frame[data-page="department"] {
    height: auto;
    min-height: 100vh;
    overflow: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, auto) auto;
  }

  .app-frame[data-page="entry"] .content,
  .app-frame[data-page="processing"] .content,
  .app-frame[data-page="department"] .content {
    overflow: auto;
  }

  .sidebar {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .entry-layout {
    grid-template-columns: 1fr;
  }

  .workspace,
  .workspace.processing-mode {
    min-height: 0;
    overflow: visible;
  }

  .records-panel.full-height {
    min-height: 420px;
  }

  .processing-mode .records-panel {
    min-height: 420px;
  }

  .processing-mode .table-wrap {
    overflow: auto;
  }

  .admin-grid-wide,
  .admin-grid-bottom {
    grid-template-columns: 1fr;
  }

  .admin-accounts-card {
    min-height: 0;
  }

  .admin-accounts-card .admin-table,
  .admin-groups-card .admin-table,
  .lookup-categories {
    max-height: none;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

@media (orientation: portrait) {
  .modal-layer,
  .settings-drawer {
    padding: 10px;
    align-items: stretch;
    place-items: stretch;
  }

  .modal-card,
  .drawer-panel,
  .drawer-panel.drawer-large,
  .line-chart-card,
  .record-edit-card,
  .excel-export-card,
  .lesson-summary-card,
  .summary-poster-card,
  .range-modal-card,
  .temp-access-card,
  .password-modal-card,
  .student-profile-modal-card {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 20px);
    min-height: 0;
    padding: 12px;
    border-radius: 12px;
    overflow: auto;
  }

  .range-modal-card {
    align-self: center;
    justify-self: center;
    width: min(420px, calc(100vw - 28px));
    max-height: none;
    padding: 12px;
    gap: 12px;
    overflow: visible;
  }

  .range-modal-card .modal-actions {
    flex-direction: row;
    gap: 8px;
  }

  .range-modal-card .modal-actions button {
    flex: 1 1 0;
    width: auto;
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .student-filter-card {
    width: min(360px, calc(100vw - 28px));
  }

  .student-filter-card .modal-head h2 {
    font-size: 15px;
  }

  .student-filter-card .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }

  .student-filter-card label {
    gap: 6px;
    font-size: 12px;
  }

  .student-filter-card input {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .record-edit-card,
  .lesson-summary-card,
  .summary-poster-card,
  .line-chart-card,
  .student-profile-modal-card {
    height: calc(100vh - 20px);
    grid-template-rows: auto minmax(0, auto) auto;
  }

  .modal-head {
    align-items: flex-start;
    gap: 10px;
  }

  .modal-head h2 {
    font-size: 16px;
    line-height: 1.25;
  }

  .modal-head p {
    font-size: 11px;
    line-height: 1.5;
  }

  .icon-btn,
  .icon-close {
    flex: 0 0 auto;
  }

  .modal-actions,
  .lesson-summary-actions,
  .lesson-summary-action-right,
  .line-chart-toolbar,
  .poster-options {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions button,
  .lesson-summary-actions button,
  .lesson-summary-action-right button,
  .poster-options button,
  .line-chart-toolbar button {
    width: 100%;
  }

  .record-edit-fields,
  .summary-form-grid,
  .excel-export-grid,
  .summary-top-row,
  .record-edit-rosters,
  .excel-section-checks {
    grid-template-columns: 1fr;
  }

  .record-edit-fields .entry-field-card,
  .summary-form-grid .entry-field-card,
  .summary-word-limit-field {
    grid-template-columns: 1fr !important;
    gap: 5px;
  }

  .record-edit-fields .entry-field-control,
  .summary-form-grid .entry-field-control {
    margin-left: 0;
    border-left: 1px solid #d7dee8;
    border-radius: 8px;
  }

  .summary-record-strip,
  .summary-students {
    align-items: stretch;
    gap: 6px;
  }

  .summary-record-strip span,
  .summary-students span {
    width: 100%;
    justify-content: flex-start;
    border-radius: 8px;
    white-space: normal;
  }

  .student-mention-popover {
    width: calc(100vw - 24px);
    max-height: min(230px, calc(100vh - 40px));
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-chart-canvas-wrap,
  .summary-poster-preview-wrap {
    max-height: calc(100vh - 260px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .line-chart-canvas-wrap canvas {
    width: 920px;
    min-width: 920px;
    max-width: none;
  }

  .summary-poster-preview-wrap canvas {
    width: 560px;
    max-width: none;
  }

  .learning-report-card,
  .interaction-card,
  .student-organizer-card {
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
    overflow: auto;
  }

  .learning-report-card {
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 12px;
  }

  .learning-report-head,
  .learning-report-panel-head,
  .learning-report-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .learning-report-layout,
  .student-organizer-layout,
  .interaction-layout {
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }

  .learning-report-panel,
  .learning-report-chat {
    min-height: 360px;
  }

  .learning-report-student-select {
    width: 100%;
  }

  .learning-report-version-list {
    justify-content: flex-start;
  }

  .interaction-card {
    grid-template-rows: auto minmax(0, 1fr);
    padding: 12px;
  }

  .interaction-topbar,
  .tool-control-row,
  .tool-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .interaction-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .poster-font-field {
    width: 100%;
    grid-template-columns: 1fr;
    padding: 8px 10px;
  }

  .context-menu,
  [data-record-context-menu] {
    max-width: calc(100vw - 16px);
    min-width: min(248px, calc(100vw - 16px));
    grid-template-columns: 1fr;
    max-height: calc(100vh - 24px);
    gap: 4px;
    padding: 6px;
    border-radius: 10px;
    overflow: auto;
  }

  .context-menu button,
  [data-record-context-menu] button {
    min-height: 28px;
    padding: 5px 8px;
    border-radius: 7px;
    font-size: 12px;
    white-space: normal;
  }

  .context-menu .context-icon,
  [data-record-context-menu] .context-icon {
    width: 15px;
    height: 15px;
  }

  .student-mode {
    grid-template-rows: auto;
  }

  .student-profile-shell {
    min-height: 0;
    gap: 10px;
  }

  .student-profile-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .student-profile-head h2 {
    font-size: 17px;
  }

  .student-profile-head p {
    font-size: 11px;
    line-height: 1.5;
  }

  .student-profile-actions,
  .student-search-form {
    width: 100%;
    justify-content: stretch;
  }

  .student-search-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .student-search-form input,
  .student-search-form select,
  .student-search-form button,
  .student-profile-actions > .primary-btn {
    width: 100%;
    min-width: 0;
  }

  .student-profile-grid {
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
  }

  .student-list-panel {
    overflow: visible;
    min-width: 0;
  }

  .table-wrap,
  .admin-table,
  .student-table-wrap,
  .audit-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
  }

  .table-wrap .data-table,
  .admin-table .data-table,
  .student-table-wrap .data-table {
    width: max-content;
    min-width: 760px;
    table-layout: auto;
  }

  .table-wrap .summary-data-table {
    min-width: 980px;
  }

  .processing-mode .table-wrap .data-table {
    min-width: 1080px;
  }

  .entry-records-panel .table-wrap .data-table {
    min-width: 760px;
  }

  .entry-records-panel .table-wrap {
    max-height: 520px;
  }

  .student-table-wrap .student-profile-table {
    min-width: 920px;
  }

  .audit-table {
    min-width: 1180px;
  }

  .grid-two,
  .grid-two.compact,
  .grid-three.compact,
  .privacy-toggle-box,
  .privacy-toggle-actions,
  .two-textareas,
  .db-choice-grid,
  .preview-grid,
  .record-edit-fields,
  .record-edit-grid {
    grid-template-columns: 1fr;
  }

  .entry-field-card {
    grid-template-columns: minmax(106px, 46%) minmax(0, 1fr);
  }

  .entry-field-label strong {
    font-size: var(--font-size-entry-card);
  }

  .entry-icon-wrap {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .entry-icon-wrap img {
    width: 15px;
    height: 15px;
  }

  .install-screen,
  .login-screen {
    padding: 16px;
  }

  .install-card,
  .login-panel {
    padding: 20px;
  }

  .install-brand {
    align-items: flex-start;
  }

  .install-brand .brand-logo {
    width: min(150px, 42vw);
    height: 54px;
  }

  .topbar,
  .processing-head {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-bar {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 4px;
  }

  .system-calendar-head {
    display: grid;
  }

  .system-calendar-head span {
    max-width: none;
  }

  .bottom-right {
    justify-self: stretch;
    text-align: left;
  }

  .bottom-center {
    justify-self: stretch;
    text-align: left;
  }

  .topbar {
    gap: 10px;
    padding: 10px 12px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
    gap: 8px;
  }

  .topbar-brand {
    width: 100%;
    min-width: 0;
    margin-right: 0;
  }

  .topbar-brand img {
    width: 96px;
    height: 36px;
  }

  .topbar-brand strong {
    font-size: 14px;
  }

  .badge {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 0;
    padding: 0 8px;
    font-size: 12px;
  }

  .tool-link,
  .more-wrap {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .tool-link,
  .more-btn {
    width: 100%;
    padding: 0 9px;
    font-size: 12px;
  }

  .more-btn {
    min-height: 38px;
    gap: 6px;
    padding: 0 12px 0 8px;
  }

  .more-btn-icon {
    width: 23px;
    height: 23px;
  }

  .more-btn-icon img {
    width: 16px;
    height: 16px;
  }

  .app-download-trigger {
    display: none !important;
  }

  .resource-shortcut-link {
    display: none !important;
  }

  .more-menu {
    right: 0;
    left: auto;
    min-width: 148px;
  }

  .workspace {
    padding: 10px 12px;
    gap: 10px;
  }

  .entry-layout {
    gap: 10px;
  }

  .entry-panel {
    grid-template-rows: auto auto auto;
    gap: 10px;
  }

  .entry-field-card {
    grid-template-columns: 1fr;
    gap: 5px;
    min-height: 0;
  }

  .entry-field-label {
    min-height: 32px;
    border-radius: 8px;
  }

  .entry-field-control {
    min-height: 36px;
    margin-left: 0;
    border-left: 1px solid #d7dee8;
    border-radius: 8px;
  }

  .entry-field-control input,
  .entry-field-control select {
    min-height: 36px;
    padding: 5px 10px;
  }

  .app-frame[data-page="entry"] .entry-fields .entry-field-card {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 0;
    min-height: 31px;
  }

  .app-frame[data-page="entry"] .entry-fields .entry-field-label {
    min-height: 31px;
    padding: 2px 5px;
    border-radius: 8px;
  }

  .app-frame[data-page="entry"] .entry-fields .entry-field-label strong {
    font-size: max(11px, calc(var(--font-size-entry-card) - 1px));
  }

  .app-frame[data-page="entry"] .entry-fields .entry-icon-wrap {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
  }

  .app-frame[data-page="entry"] .entry-fields .entry-icon-wrap img {
    width: 12px;
    height: 12px;
  }

  .app-frame[data-page="entry"] .entry-fields .entry-field-control {
    min-height: 31px;
    margin-left: -8px;
    border-left: 0;
    border-radius: 0 8px 8px 0;
  }

  .app-frame[data-page="entry"] .entry-fields .entry-field-control input,
  .app-frame[data-page="entry"] .entry-fields .entry-field-control select {
    min-height: 31px;
    padding: 3px 7px 3px 14px;
    font-size: var(--font-size-entry-card);
  }

  .roster-card {
    min-height: 190px;
  }

  .roster-card textarea {
    min-height: 178px;
  }

  .processing-head {
    gap: 10px;
  }

  .processing-metrics,
  .view-toggle-wrap,
  .scope-pills {
    width: 100%;
  }

  .processing-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .teacher-rating {
    justify-content: center;
    min-width: 0;
    padding-right: 8px;
    font-size: 12px;
  }

  .view-toggle-wrap {
    justify-content: stretch;
    margin: 0;
    padding-left: 0;
    border-left: 0;
    gap: 8px;
  }

  .view-toggle-btn {
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
    padding: 5px 8px;
    font-size: 12px;
  }

  .scope-pills {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    justify-content: stretch;
  }

  .scope-pills .pill,
  .query-menu,
  .query-menu > .pill {
    width: 100%;
    min-width: 0;
  }

  .query-menu {
    position: relative;
  }

  .department-filter {
    flex: 0 0 auto;
    width: 100%;
    flex-direction: row;
    align-items: stretch;
    gap: 7px;
    min-height: 0;
  }

  .department-filter .department-entry-field {
    flex: 1 1 calc(50% - 4px);
    width: auto;
    min-width: 0;
    max-width: none;
    min-height: 30px;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 0;
  }

  .department-filter .department-entry-field .entry-field-label {
    min-height: 30px;
    padding: 2px 5px;
  }

  .department-filter .department-entry-field .entry-field-label strong {
    font-size: 11px;
  }

  .department-filter .department-entry-field .entry-icon-wrap {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
  }

  .department-filter .department-entry-field .entry-icon-wrap img {
    width: 12px;
    height: 12px;
  }

  .department-filter .department-entry-field .entry-field-control {
    min-height: 30px;
  }

  .department-filter .department-entry-field .entry-field-control select {
    min-height: 30px;
    padding: 3px 7px 3px 13px;
    font-size: 12px;
  }

  .department-processing-head .scope-pills {
    flex-wrap: wrap;
    width: 100%;
  }

  .lesson-summary-actions,
  .lesson-summary-action-right,
  .poster-options {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-poster-preview-wrap {
    max-height: calc(100vh - 260px);
    padding: 10px;
  }

  .query-options {
    position: absolute;
    left: auto;
    right: 0;
    top: calc(100% + 8px);
    width: 100%;
    max-width: min(190px, calc(100vw - 28px));
    margin-top: 0;
    z-index: 30;
  }

  .custom-range {
    grid-template-columns: 1fr;
  }

  .system-settings-grid,
  .system-logo-uploader,
  .system-inline-fields,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .login-panel {
    margin: 0 auto;
  }
}

.tool-link-icon {
  gap: 6px;
}

.tool-link-icon img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.app-download-trigger {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-color: rgba(24, 101, 242, 0.28);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.96), rgba(232,240,255,0.98) 55%, rgba(239,248,255,0.96));
  color: var(--primary);
  font-weight: 900;
  box-shadow:
    0 8px 20px rgba(24, 101, 242, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

.app-download-trigger::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.62), rgba(255,255,255,0) 58%);
  pointer-events: none;
}

.app-download-trigger img {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 2px 4px rgba(24, 101, 242, 0.16));
}

@media (hover: hover) {
  .app-download-trigger:hover {
    border-color: rgba(24, 101, 242, 0.42);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow:
      0 12px 26px rgba(24, 101, 242, 0.16),
      inset 0 1px 0 rgba(255,255,255,0.95);
  }
}

.more-wrap {
  position: relative;
}

.more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 160px;
  box-shadow: 0 16px 40px rgba(15,23,42,0.12);
  padding: 8px;
  display: grid;
  gap: 6px;
  z-index: 6;
}

.more-menu-link,
.more-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: max(12px, calc(var(--font-size-chrome) - 1px));
  font-weight: 700;
}

.more-menu button {
  border: 0;
}

.more-menu-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.sidebar-clock {
  font-weight: 800;
  color: #e11d48;
  font-size: calc(var(--font-size-sidebar) + 14px);
  line-height: 1;
}

.admin-page {
  min-height: 100vh;
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
  background: var(--bg-soft);
  overflow: auto;
}

.admin-card h2 {
  margin: 0;
}

.admin-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.admin-grid-wide {
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  align-items: stretch;
}

.admin-grid-bottom {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  align-items: start;
}

.admin-card {
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
  box-shadow: 0 10px 30px rgba(15,23,42,0.05);
}

.audit-console {
  display: grid;
  gap: 16px;
}

.audit-console-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: stretch;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 10px 30px rgba(15,23,42,0.05);
}

.audit-console-head h2 {
  margin: 5px 0 6px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
}

.audit-console-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.audit-console-kicker {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.audit-console-side {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.audit-console-metrics {
  min-width: 112px;
  display: grid;
  place-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}

.audit-console-metrics span {
  font-size: 12px;
  color: var(--muted);
}

.audit-console-metrics strong {
  font-size: 26px;
  line-height: 1;
  color: var(--primary);
}

.audit-clear-btn {
  min-width: 86px;
  border: 1px solid rgba(239,68,68,0.32);
  border-radius: 10px;
  background: rgba(239,68,68,0.08);
  color: #dc2626;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.audit-clear-btn:hover {
  background: rgba(239,68,68,0.13);
}

.audit-filter-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 10px 30px rgba(15,23,42,0.04);
}

.audit-filter-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.audit-filter-panel input,
.audit-filter-panel select {
  height: 36px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.audit-filter-panel input:focus,
.audit-filter-panel select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.audit-filter-wide {
  grid-column: span 2;
}

.audit-filter-actions {
  grid-column: span 2;
  display: flex;
  gap: 10px;
  align-items: end;
}

.audit-filter-actions .primary-btn,
.audit-filter-actions .secondary-btn {
  height: 36px;
  border-radius: 8px;
  padding: 0 16px;
}

.audit-filter-actions .secondary-btn {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.audit-table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.96);
  overflow: auto;
  box-shadow: 0 10px 30px rgba(15,23,42,0.05);
}

.audit-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: max(11px, calc(var(--font-size-table) - 2px));
  font-family: var(--font-table);
}

.audit-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: #f3f4f6;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
}

.audit-table td {
  max-width: 280px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  line-height: 1.32;
}

.audit-table tr:nth-child(even) td {
  background: rgba(248,250,252,0.88);
}

.audit-table tr:hover td {
  background: var(--primary-soft);
}

.audit-table td strong,
.audit-table td span {
  display: block;
}

.audit-table td span {
  margin-top: 2px;
  color: var(--muted);
}

.audit-table code {
  color: var(--primary);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
}

.audit-time {
  min-width: 148px;
  color: var(--muted);
  white-space: nowrap;
}

.audit-summary {
  min-width: 220px;
  color: var(--text);
  line-height: 1.35;
}

.audit-pill {
  display: inline-grid;
  min-width: 54px;
  place-items: center;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.audit-result-success {
  background: #dcfce7;
  color: #15803d;
}

.audit-result-failure {
  background: #fee2e2;
  color: #b91c1c;
}

.audit-risk-normal {
  background: #dbeafe;
  color: #1d4ed8;
}

.audit-risk-medium {
  background: #ffedd5;
  color: #c2410c;
}

.audit-risk-high {
  background: #f3e8ff;
  color: #7e22ce;
}

.audit-detail-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}

.audit-detail-btn:hover {
  background: var(--primary-soft);
}

.audit-empty {
  padding: 30px 12px;
  color: var(--muted);
  text-align: center;
}

.audit-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.audit-pagination a,
.audit-pagination span {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
}

.audit-pagination a.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.audit-detail-modal[hidden] {
  display: none;
}

.audit-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2,6,23,0.78);
  backdrop-filter: blur(8px);
}

.audit-detail-panel {
  width: min(920px, 96vw);
  max-height: 88vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 30px 100px rgba(15,23,42,0.24);
}

.audit-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.audit-detail-head span {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.audit-detail-head strong {
  color: var(--text);
  font-size: 18px;
}

.audit-detail-body {
  display: grid;
  gap: 12px;
  padding: 16px;
  overflow: auto;
  font-family: var(--font-table);
  font-size: var(--font-size-table);
}

.audit-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.audit-detail-item,
.audit-detail-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px 12px;
}

.audit-detail-item span,
.audit-detail-block span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.audit-detail-item strong {
  color: var(--text);
  font-size: 13px;
  word-break: break-word;
}

.audit-detail-block pre {
  max-height: 230px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .audit-filter-panel {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .audit-filter-wide,
  .audit-filter-actions {
    grid-column: span 3;
  }
}

@media (orientation: portrait) {
  .audit-console-head,
  .admin-section-head {
    display: grid;
  }

  .audit-filter-panel,
  .audit-detail-grid {
    grid-template-columns: 1fr;
  }

  .audit-filter-wide,
  .audit-filter-actions {
    grid-column: span 1;
  }
}

.admin-card h2 {
  font-size: 22px;
  line-height: 1.15;
}

.admin-system-card {
  align-self: start;
}

.admin-accounts-card {
  min-height: 560px;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: stretch;
}

.admin-groups-card,
.admin-lookups-card {
  min-height: 360px;
}

.admin-page .card-head {
  align-items: center;
}

.admin-page .grid-two {
  gap: 10px 12px;
}

.admin-page label {
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-page input,
.admin-page select,
.admin-page textarea {
  color: var(--text);
  font-size: 13px;
}

.admin-page input,
.admin-page select {
  height: 40px;
  min-height: 40px;
  padding: 8px 10px;
}

.admin-page textarea {
  min-height: 94px;
  padding: 10px;
  line-height: 1.55;
  resize: vertical;
}

.admin-page select[multiple] {
  height: 104px;
  min-height: 104px;
  padding: 8px 10px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 10px;
  align-items: center;
  align-self: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.search-row input,
.search-row select,
.search-row button {
  height: 40px;
  min-height: 40px;
}

.account-filter-row {
  grid-template-columns: minmax(220px, 1fr) 180px auto;
}

.scope-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.scope-filter-tab {
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.scope-filter-tab.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.account-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}

.account-group-panel {
  min-width: 0;
  min-height: 220px;
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15,23,42,0.05);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease, background .16s ease;
}

.account-group-panel[draggable="true"] {
  cursor: grab;
}

.account-group-panel.is-drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.account-group-panel.is-source-group {
  border-color: #f6c453;
  background: #fffaf0;
  box-shadow: 0 18px 44px rgba(180, 120, 0, 0.18);
}

.account-group-panel.is-group-dragging {
  opacity: 0.72;
  transform: translateY(-4px) scale(1.015);
  box-shadow: 0 24px 60px rgba(15,23,42,0.18);
}

.account-group-panel.is-ungrouped {
  border-style: dashed;
}

.account-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.account-group-head strong,
.account-group-head span {
  display: block;
}

.account-group-head strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.3;
}

.account-group-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.account-group-head em {
  flex: 0 0 auto;
  min-width: 46px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  text-align: center;
}

.account-card-list {
  min-height: 112px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-content: start;
}

.account-person-card {
  position: relative;
  min-height: 36px;
  display: grid;
  align-items: center;
  padding: 6px 26px 6px 9px;
  border: 1px solid #dbe4f3;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  cursor: pointer;
  user-select: none;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease, opacity .16s ease;
}

.account-person-card[draggable="true"] {
  cursor: grab;
}

.account-person-card.is-dragging {
  z-index: 4;
  opacity: 0.76;
  border-color: var(--primary);
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 18px 38px rgba(24,101,242,0.22);
}

.account-person-card strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-person-card.is-supervisor {
  border-color: #f6c453;
  background: linear-gradient(180deg, #fffdf5 0%, #fff7dc 100%);
}

.account-card-remove {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: #fff7f7;
  color: #8b1a1a;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.account-empty-slot {
  min-height: 56px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 520px) {
  .account-card-list {
    grid-template-columns: 1fr;
  }
}

.admin-page .tool-link,
.admin-page .primary-btn {
  border-radius: 8px;
  min-height: 34px;
}

.admin-page .tool-link-mini {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.admin-page .tool-link-mini.danger {
  color: #8b1a1a;
  border-color: #fecaca;
  background: #fff7f7;
}

.admin-page .muted-cell {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-table {
  min-height: 0;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.admin-section-page > .admin-table {
  align-self: start;
}

.admin-accounts-card .admin-table {
  max-height: 420px;
}

.admin-groups-card .admin-table {
  max-height: 286px;
}

.admin-page .data-table {
  font-size: 12px;
}

.admin-page .data-table th,
.admin-page .data-table td {
  padding: 9px 7px;
}

.data-table tbody tr:hover {
  background: var(--primary-soft);
  font-weight: 800;
}

.admin-accounts-card .data-table th:nth-child(1),
.admin-accounts-card .data-table td:nth-child(1) {
  width: 9%;
}

.admin-accounts-card .data-table th:nth-child(2),
.admin-accounts-card .data-table td:nth-child(2),
.admin-accounts-card .data-table th:nth-child(3),
.admin-accounts-card .data-table td:nth-child(3),
.admin-accounts-card .data-table th:nth-child(4),
.admin-accounts-card .data-table td:nth-child(4),
.admin-accounts-card .data-table th:nth-child(5),
.admin-accounts-card .data-table td:nth-child(5) {
  width: 9%;
}

.admin-accounts-card .data-table th:nth-child(6),
.admin-accounts-card .data-table td:nth-child(6),
.admin-accounts-card .data-table th:nth-child(7),
.admin-accounts-card .data-table td:nth-child(7) {
  width: 10%;
}

.admin-accounts-card .data-table th:nth-child(8),
.admin-accounts-card .data-table td:nth-child(8),
.admin-accounts-card .data-table th:nth-child(9),
.admin-accounts-card .data-table td:nth-child(9) {
  width: 11%;
}

.admin-accounts-card .data-table th:nth-child(10),
.admin-accounts-card .data-table td:nth-child(10) {
  width: 10%;
}

.admin-groups-card .data-table th:nth-child(4),
.admin-groups-card .data-table td:nth-child(4),
.admin-groups-card .data-table th:nth-child(6),
.admin-groups-card .data-table td:nth-child(6) {
  width: 18%;
}

.lookup-categories {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-height: none;
  min-width: 0;
  overflow: visible;
  padding: 0;
  align-self: start;
}

.lookup-category {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(112px, 148px) minmax(0, 1fr);
  gap: 10px 14px;
  align-items: start;
  align-content: start;
}

.lookup-title {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 56px;
  padding: 9px 8px;
  border-radius: 8px;
  background: var(--bg-soft);
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
}

.lookup-title span {
  display: block;
  line-height: 1.2;
}

.lookup-title-icon {
  width: 22px;
  height: 22px;
  stroke: var(--primary);
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.lookup-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  align-items: stretch;
  overflow: visible;
}

.lookup-item {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  background: #eef3fb;
  border: 1px solid #d7e0ee;
}

.lookup-item:hover {
  border-color: var(--border);
  background: var(--primary-soft);
  font-weight: 800;
}

.lookup-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.lookup-item small {
  display: block;
  grid-column: 1;
  color: var(--muted);
  font-size: 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lookup-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.lookup-add-btn {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border-radius: 8px;
  justify-content: center;
  gap: 6px;
  background: #e6eefc;
  border-color: #cad8f0;
  color: var(--primary);
}

.lookup-add-icon {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

@media (max-width: 1380px) {
  .lookup-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (orientation: portrait) {
  .lookup-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .lookup-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .lookup-list {
    grid-template-columns: 1fr;
  }
}

.settings-page {
  min-height: 100vh;
  padding: 18px;
  display: grid;
  gap: 16px;
  background: var(--bg-soft);
  font-family: var(--font-settings);
  font-size: var(--font-size-settings);
}

.settings-page-wide {
  align-content: start;
}

.settings-shell {
  font-family: var(--font-settings);
  font-size: var(--font-size-settings);
  height: 100vh;
}

.settings-shell .settings-sidebar,
.settings-shell .settings-content,
.settings-shell .settings-card {
  font-family: var(--font-settings);
  font-size: var(--font-size-settings);
}

.settings-shell .admin-brand strong {
  font-size: calc(var(--font-size-settings) + 2px);
}

.settings-shell .admin-brand span,
.settings-shell .admin-nav-item span {
  font-size: max(11px, calc(var(--font-size-settings) - 2px));
}

.settings-shell .admin-nav-item strong {
  font-size: var(--font-size-settings);
}

.settings-nav-icon {
  display: none;
}

.settings-shell .admin-section-head {
  align-items: center;
}

.settings-head-actions {
  width: min(320px, 30vw);
  min-width: 240px;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.settings-head-actions .settings-head-control {
  width: 100%;
  min-width: 0;
}

.settings-head-actions .settings-head-button {
  white-space: nowrap;
}

.settings-shell label,
.settings-shell .checkbox-item {
  font-size: max(12px, calc(var(--font-size-settings) - 1px));
}

.settings-shell input,
.settings-shell select,
.settings-shell textarea {
  font-size: var(--font-size-settings);
}

.settings-stack {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.settings-shell .settings-card {
  width: 100%;
  max-width: none;
  min-height: 0;
}

.settings-shell .settings-card-body {
  align-content: start;
}

.settings-profile-grid,
.settings-shell .ai-settings-body,
.summary-settings-body {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-appearance-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.settings-appearance-grid > .appearance-toggle-box,
.settings-appearance-grid > .settings-select-card {
  min-width: 0;
  min-height: 136px;
}

.settings-appearance-grid .font-settings-block,
.settings-shell .ai-model-note,
.summary-settings-body .full-span {
  grid-column: 1 / -1;
}

.settings-shell .font-settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

@media (max-width: 900px) {
  .settings-shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
    overflow: auto;
  }

  .settings-shell .settings-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .settings-shell .settings-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-shell .admin-nav-item {
    min-width: 0;
    padding: 10px;
  }

  .settings-shell .settings-content {
    padding: 12px;
  }

  .settings-shell .admin-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-head-actions {
    width: 100%;
    min-width: 0;
    margin-left: 0;
    justify-content: stretch;
  }

  .settings-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-head-control {
    width: 100%;
    min-width: 0;
  }

  .ai-prompt-pair,
  .summary-field-label-grid {
    grid-template-columns: 1fr;
  }

  .settings-shell .ai-settings-card {
    height: auto;
    min-height: 0;
  }

  .settings-shell .ai-settings-card .ai-settings-body {
    grid-template-rows: none;
  }

  .ai-prompt-pair,
  .ai-persona,
  .ai-emphasis {
    height: auto;
    min-height: 180px;
  }

  .daydream-settings-body {
    grid-template-columns: 1fr;
  }

  .daydream-amount-settings {
    grid-row: auto;
  }

  .daydream-generator-card,
  .daydream-expectation-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .daydream-expectation-result {
    grid-template-columns: 1fr;
  }

  .daydream-amount-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .daydream-result-item {
    grid-template-columns: minmax(0, 1fr) auto 34px;
  }

  .daydream-result-item em {
    grid-column: 1 / -1;
  }
}

.settings-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.94);
}

.settings-page-head-plain {
  width: 100%;
}

.settings-page-panel {
  width: 100%;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 12px 34px rgba(15,23,42,0.06);
  display: grid;
  gap: 16px;
  font-family: var(--font-settings);
  font-size: var(--font-size-settings);
}

.settings-card-grid {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(340px, 1.1fr) minmax(360px, 1.18fr);
  gap: 16px;
  align-items: stretch;
}

.settings-card {
  min-width: 0;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 12px 34px rgba(15,23,42,0.06);
  font-family: var(--font-settings);
  font-size: var(--font-size-settings);
}

.settings-card-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-card-head h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.settings-head-control {
  width: min(280px, 42%);
  min-width: 210px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: max(12px, calc(var(--font-size-settings) - 1px));
  font-weight: 800;
}

.settings-head-control select {
  width: 100%;
}

.settings-card-body {
  display: grid;
  gap: 14px;
  align-content: start;
}

.ai-settings-body {
  gap: 8px 12px;
  min-height: 0;
  align-content: stretch;
}

.settings-shell .ai-settings-card {
  height: calc(100dvh - 154px);
  min-height: 520px;
}

.settings-shell .ai-settings-card .ai-settings-body {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.settings-shell .ai-settings-card .settings-card-actions {
  align-self: end;
}

.ai-provider-row {
  max-width: 320px;
}

.ai-model-note {
  display: grid;
  gap: 4px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.daydream-settings-card {
  align-self: start;
}

.daydream-settings-body {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.7fr);
  align-items: start;
}

.daydream-amount-settings,
.daydream-option-settings,
.daydream-generator-settings,
.daydream-expectation-settings,
.daydream-results-settings {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.daydream-amount-settings {
  grid-row: span 2;
}

.daydream-expectation-settings {
  grid-column: 1 / -1;
}

.daydream-generator-card,
.daydream-expectation-card {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--theme-primary), transparent 78%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--theme-primary), transparent 94%);
}

.daydream-expectation-card {
  grid-template-columns: minmax(220px, 0.62fr) minmax(360px, 1.38fr);
}

.daydream-expectation-controls {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.daydream-generator-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.daydream-generator-copy strong {
  color: var(--text-strong);
  font-size: max(14px, calc(var(--font-size-settings) + 1px));
}

.daydream-generator-copy span,
.daydream-generator-card small {
  color: var(--text-muted);
  line-height: 1.55;
}

.daydream-generator-card label,
.daydream-expectation-card label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 700;
}

.daydream-generator-card input,
.daydream-expectation-card input {
  width: 100%;
}

.daydream-generator-card small {
  grid-column: 1 / -1;
  display: block;
}

.daydream-generator-card small:empty {
  display: none;
}

.daydream-expectation-result {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: stretch;
  gap: 8px;
  min-height: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-muted);
  line-height: 1.55;
}

.daydream-expectation-metric {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--theme-primary), transparent 82%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--theme-primary), transparent 96%);
}

.daydream-expectation-metric.accent {
  border-color: color-mix(in srgb, var(--theme-accent), transparent 78%);
  background: color-mix(in srgb, var(--theme-accent), transparent 94%);
}

.daydream-expectation-metric span {
  color: var(--text-muted);
  font-weight: 800;
}

.daydream-expectation-metric strong {
  color: var(--text-strong);
  font-size: max(18px, calc(var(--font-size-settings) + 4px));
}

.daydream-expectation-metric small {
  color: var(--text-muted);
}

.daydream-amount-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.daydream-amount-grid label {
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
}

.daydream-amount-grid span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
}

.daydream-amount-grid input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 5px 7px;
}

.daydream-toggle-box {
  margin-top: 0;
}

.daydream-results-head,
.daydream-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.daydream-results-head {
  justify-content: space-between;
}

.daydream-result-list {
  max-height: 238px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 2px;
}

.daydream-result-item {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(112px, auto) 34px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
}

.daydream-result-item span,
.daydream-result-item em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-result-item strong {
  color: var(--primary);
  font-weight: 900;
}

.daydream-result-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.ai-prompt-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  height: 100%;
}

.ai-prompt-pair label {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 7px;
  align-content: stretch;
}

.ai-textarea {
  width: 100%;
  resize: none;
  line-height: 1.48;
}

.ai-persona {
  min-height: 0;
  height: 100%;
}

.ai-template {
  min-height: 190px;
}

.ai-emphasis {
  min-height: 0;
  height: 100%;
}

.summary-field-settings {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff, var(--bg-soft));
}

.summary-field-label-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.summary-field-label-grid label,
.summary-template-field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.summary-template-field {
  align-content: start;
}

.secret-input-wrap {
  position: relative;
  display: block;
}

.secret-input-wrap input {
  padding-right: 42px;
}

.secret-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.secret-toggle:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.settings-section-head h1 {
  margin: 0;
  font-size: 22px;
}

.settings-section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-page-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  width: 100%;
}

.settings-form,
.font-settings-block,
.font-settings-grid,
.font-setting-field {
  font-family: var(--font-settings);
}

.font-settings-block {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}

.font-settings-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  font-weight: 700;
}

.font-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.font-setting-field {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
}

.font-setting-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.font-setting-field select {
  width: 100%;
}

.font-size-control {
  display: grid;
  gap: 6px;
}

.font-size-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.font-size-control output {
  color: var(--primary);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.font-size-control input[type="range"] {
  width: 100%;
  height: 20px;
  padding: 0;
  border: 0;
  accent-color: var(--primary);
  background: transparent;
}

.settings-warning {
  padding: 10px 12px;
  border: 1px solid #f6c453;
  border-radius: 10px;
  background: #fff8e1;
  color: #8a5a00;
  font-size: 13px;
  line-height: 1.6;
}

.full-span {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.settings-card-actions {
  align-self: end;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.settings-page-form input[name="motto"] {
  width: 100%;
}

.password-modal-card {
  width: min(420px, calc(100vw - 32px));
}

.password-confirm-step {
  display: grid;
  gap: 12px;
}

.password-confirm-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.password-confirm-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.password-confirm-box strong {
  display: block;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  word-break: break-all;
}

.learning-report-layer {
  padding: 12px;
}

.learning-report-card {
  width: min(1480px, calc(100vw - 24px));
  height: min(900px, calc(100vh - 24px));
  max-height: calc(100vh - 24px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  overflow: hidden;
  background: #f8fafc;
}

.learning-report-head,
.learning-report-panel-head,
.learning-report-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.learning-report-head,
.learning-report-panel-head {
  justify-content: space-between;
}

.learning-report-head h2 {
  margin: 0;
  font-size: 20px;
}

.learning-report-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.learning-report-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.learning-report-mode-tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.learning-report-mode-tabs button.active {
  background: linear-gradient(135deg, #f97316, #f59e0b);
  color: #fff;
  box-shadow: 0 8px 22px rgba(249, 115, 22, 0.22);
}

.learning-report-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(560px, 1fr) 300px;
  gap: 12px;
  overflow: hidden;
}

.learning-report-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.learning-report-panel-head strong {
  color: var(--text);
  font-size: 14px;
}

.learning-report-panel-head span,
.report-muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.learning-report-source {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  order: 1;
}

.learning-report-chat {
  order: 2;
}

.learning-report-preview-wrap {
  order: 3;
}

.learning-report-source-body,
.learning-report-preview,
.learning-report-chat-log {
  min-height: 0;
  overflow: auto;
}

.learning-report-preview {
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #eef2f7;
}

.report-source-grid {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 7px 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 12px;
}

.report-source-grid span {
  color: var(--muted);
  font-weight: 800;
}

.report-source-grid strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 900;
}

.report-source-block {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.report-source-block b {
  color: var(--text);
  font-size: 13px;
}

.report-source-block div,
.report-student-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.report-source-block span,
.report-source-block em {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.report-source-block p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.report-student-picker {
  gap: 10px;
}

.report-student-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.report-student-picker-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-student-checks {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 7px !important;
}

.report-student-check {
  display: inline-flex;
  min-width: 0;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  background: #f8fbff;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.report-student-check input {
  width: 13px;
  height: 13px;
  accent-color: var(--primary);
}

.report-student-check span {
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-student-check:has(input:checked) {
  border-color: rgba(24, 101, 242, 0.38);
  background: var(--primary-soft);
  color: var(--primary);
}

.report-source-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 8px;
}

.report-source-actions .mini {
  min-height: 28px;
  padding: 4px 12px;
  border-radius: 7px;
  font-size: 12px;
}

.learning-report-download {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.learning-report-download .primary-btn,
.learning-report-download .secondary-btn {
  width: 100%;
  text-align: center;
}

.learning-report-download small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.learning-report-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
  font-weight: 800;
}

.learning-report-warning span {
  padding: 2px 7px;
  border-radius: 999px;
  background: #ffedd5;
}

.learning-report-empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.learning-report-empty strong {
  color: var(--text);
  font-size: 18px;
}

.learning-report-empty.is-busy strong {
  color: var(--primary);
}

.learning-report-empty.is-busy::before {
  content: "";
  width: 28px;
  height: 28px;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: learning-report-spin .8s linear infinite;
}

.learning-report-empty.is-error strong {
  color: #dc2626;
}

.learning-report-empty.is-error span {
  max-width: 460px;
  color: #991b1b;
}

@keyframes learning-report-spin {
  to {
    transform: rotate(360deg);
  }
}

.learning-report-version-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.learning-report-student-select {
  width: 168px;
  min-height: 32px;
  padding: 4px 30px 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.learning-report-version-list button {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.learning-report-version-list button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.learning-report-canvas {
  display: block;
  width: min(100%, 260px);
  height: auto;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
}

.learning-report-canvas.is-zoomable {
  cursor: zoom-in;
  outline: none;
}

.learning-report-canvas.is-zoomable:focus-visible {
  box-shadow: 0 0 0 3px rgba(24, 101, 242, 0.2), 0 18px 48px rgba(15, 23, 42, 0.18);
}

.report-image-viewer-layer {
  z-index: 126;
  background: rgba(15, 23, 42, 0.56);
}

.report-image-viewer-card {
  width: min(1120px, calc(100vw - 32px));
  height: min(94dvh, 980px);
  max-height: calc(100dvh - 24px);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.report-image-viewer-body {
  min-height: 0;
  overflow: auto;
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 14px;
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  background: #edf2f7;
  -webkit-overflow-scrolling: touch;
}

.report-image-viewer-body img {
  display: block;
  width: min(920px, 100%);
  height: auto;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 56px rgba(15, 23, 42, 0.22);
}

.course-outline-canvas {
  width: min(100%, 280px);
}

.report-preview-set {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.report-preview-student {
  position: sticky;
  top: 0;
  z-index: 2;
  width: max-content;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.report-spread {
  width: 100%;
  aspect-ratio: 420 / 297;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: #dbe4f0;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.report-detail-spread {
  grid-template-columns: minmax(0, 1fr);
}

.report-page {
  min-width: 0;
  min-height: 0;
  background: #fff;
  padding: 18px;
  overflow: hidden;
}

.report-front-cover {
  display: grid;
  align-content: center;
  gap: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #e8f1ff 100%);
}

.report-back-cover {
  display: grid;
  align-content: center;
  gap: 14px;
  background: #fff7ed;
}

.report-page small {
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.report-front-cover h2,
.report-back-cover h3 {
  margin: 0;
  color: #172033;
  font-size: 34px;
  line-height: 1.18;
}

.report-front-cover strong {
  color: #ea580c;
  font-size: 25px;
}

.report-front-cover p,
.report-back-cover p,
.report-front-cover em {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.65;
  font-style: normal;
}

.report-front-cover em {
  width: max-content;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: #e8f1ff;
  color: var(--primary);
  font-weight: 900;
}

.report-detail-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-content: start;
}

.report-section {
  min-width: 0;
  min-height: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.report-section.wide {
  grid-column: 1 / -1;
}

.report-section h4 {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
}

.report-section p,
.report-section li {
  margin: 0;
  color: #334155;
  font-size: 11px;
  line-height: 1.55;
}

.report-section ul {
  margin: 0;
  padding-left: 16px;
}

.report-ability-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  color: #334155;
  font-size: 11px;
  font-weight: 800;
}

.report-ability-row i {
  height: 7px;
  border-radius: 999px;
  background: #dbeafe;
  overflow: hidden;
}

.report-ability-row b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.learning-report-chat {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: 14px;
  background: #f8fafc;
}

.learning-report-field {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.learning-report-field textarea {
  min-height: 0;
  resize: none;
  text-align: left;
  text-align-last: auto;
  font-size: 12px;
  line-height: 1.55;
}

.learning-report-field select {
  width: 100%;
  min-height: 36px;
  margin-top: 7px;
  border-radius: 8px;
  font-size: 13px;
}

.learning-report-chat-input textarea {
  height: clamp(88px, 14dvh, 126px);
  min-height: 88px;
  max-height: 126px;
  overflow: auto;
  box-sizing: border-box;
}

.learning-report-chat .learning-report-actions {
  flex: 0 0 auto;
  align-self: end;
  position: relative;
  z-index: 2;
  padding-top: 2px;
  background: #f8fafc;
}

.learning-report-font-field {
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.report-copy-editor {
  width: 100%;
  display: grid;
  gap: 10px;
  align-content: start;
}

.report-copy-tip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
}

.report-copy-tip strong {
  font-size: 13px;
  font-weight: 900;
}

.report-copy-tip span {
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.report-copy-field {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.report-copy-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.report-copy-field-head span {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.report-copy-expand-btn {
  min-height: 26px;
  padding: 3px 10px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1;
}

.report-copy-field textarea {
  width: 100%;
  min-height: 0;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  text-align: left;
  text-align-last: auto;
}

.report-copy-actions {
  display: flex;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(238,242,247,0), #eef2f7 42%);
}

.report-copy-actions .primary-btn {
  min-width: 150px;
  min-height: 40px;
  border-radius: 8px;
}

.report-image-result {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.report-image-toolbar {
  width: min(100%, 360px);
  display: flex;
  justify-content: flex-end;
}

.report-image-toolbar .secondary-btn {
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.report-copy-zoom-layer {
  z-index: 128;
  background: rgba(15, 23, 42, 0.46);
}

.report-copy-zoom-card {
  width: min(980px, calc(100vw - 32px));
  height: min(82dvh, 760px);
  max-height: calc(100dvh - 24px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.report-copy-zoom-card textarea {
  width: 100%;
  min-height: 0;
  resize: none;
  padding: 14px 16px;
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text);
  font-size: 15px;
  line-height: 1.8;
  text-align: left;
  text-align-last: auto;
}

.learning-report-actions {
  justify-content: stretch;
}

.learning-report-actions .primary-btn,
.learning-report-actions .secondary-btn,
.learning-report-chat > .secondary-btn {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}

.learning-report-chat-log {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(15, 23, 42, 0.28);
  border-radius: 8px;
  background: #0f172a;
  color: #dbeafe;
}

.learning-report-chat-log:empty::before {
  content: "这里会显示本次 AI 对话记录";
  color: rgba(219, 234, 254, 0.58);
  font-size: 12px;
  font-weight: 700;
}

.learning-report-chat-item {
  max-width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  color: #dbeafe;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
  line-height: 1.65;
  font-weight: 600;
  white-space: pre-wrap;
}

.learning-report-chat-item.from-user {
  justify-self: end;
  margin-left: 22px;
  background: rgba(24, 101, 242, 0.32);
  color: #eff6ff;
}

.learning-report-chat-item.from-ai {
  justify-self: start;
  margin-right: 22px;
  border: 0;
}

@media (max-width: 1180px) {
  .learning-report-layout {
    grid-template-columns: 260px minmax(440px, 1fr) 260px;
  }
}

@media (max-width: 920px) {
  .learning-report-card {
    height: calc(100vh - 16px);
  }

  .learning-report-layout {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .learning-report-panel {
    min-height: 360px;
  }

  .learning-report-chat {
    order: 2;
  }

  .learning-report-preview-wrap {
    order: 3;
  }
}

.interaction-card {
  position: relative;
  width: min(1240px, calc(100vw - 16px));
  height: min(820px, calc(100vh - 16px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  overflow: hidden;
}

.interaction-topbar,
.interaction-panel-head,
.interaction-top-actions,
.tool-actions,
.tool-control-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.interaction-topbar {
  justify-content: space-between;
}

.interaction-topbar h2 {
  margin: 0;
  font-size: 20px;
}

.interaction-topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.interaction-layout {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 270px minmax(380px, 1fr);
  gap: 10px;
}

.interaction-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.interaction-panel-head {
  justify-content: space-between;
}

.interaction-panel-head strong {
  color: var(--text);
  font-size: 14px;
}

.inline-check {
  width: auto;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
}

.interaction-student-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.interaction-student-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 52px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.interaction-student-item input[type="checkbox"] {
  width: auto;
}

.interaction-student-item input[type="number"] {
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 12px;
}

.interaction-student-item span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.interaction-student-item strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interaction-student-item em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.interaction-tools {
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.interaction-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.interaction-tabs button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.interaction-tabs button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.interaction-stage,
.interaction-tool {
  min-height: 0;
  min-width: 0;
}

.interaction-stage {
  display: grid;
  overflow: hidden;
}

.interaction-rule-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.36);
}

.interaction-rule-card {
  width: min(720px, 100%);
  max-height: calc(100% - 10px);
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
  border-radius: 12px;
  background: var(--modal-bg);
  color: var(--text);
  box-shadow: var(--shadow-strong);
}

.interaction-rule-head,
.interaction-rule-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.interaction-rule-head span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.interaction-rule-head h3 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1.2;
}

.interaction-rule-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.interaction-rule-meta span,
.interaction-rule-param-note {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.interaction-rule-meta strong {
  color: var(--text);
}

.interaction-rule-steps {
  display: grid;
  gap: 8px;
}

.interaction-rule-steps div {
  min-width: 0;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.interaction-rule-steps strong {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
}

.interaction-rule-steps span {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.interaction-rule-config {
  display: grid;
  gap: 10px;
}

.interaction-rule-param-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.interaction-rule-param-grid label {
  min-width: 0;
}

.interaction-rule-actions {
  justify-content: flex-end;
}

.interaction-tool {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto auto;
  gap: 8px;
  overflow: hidden;
}

.interaction-tool[data-interaction-tool="random"] {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.interaction-tool[data-interaction-tool="twentyfour"] {
  grid-template-rows: minmax(360px, 1fr) auto;
}

.interaction-tool[data-interaction-tool="daydream"] {
  grid-template-rows: minmax(300px, 1fr) auto auto;
}

.tool-control-row {
  flex-wrap: wrap;
}

.interaction-tool[data-interaction-tool="bomb"] .tool-control-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-control-row label {
  flex: 1 1 140px;
  gap: 5px;
  font-size: 12px;
}

.tool-control-row input,
.tool-control-row select {
  min-height: 34px;
  padding: 6px 10px;
}

.spotlight-name,
.bomb-board,
.twentyfour-board {
  position: relative;
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  color: #0f172a;
  text-align: center;
}

.spotlight-name {
  padding: 24px;
  font-size: clamp(34px, 6vw, 72px);
  font-weight: 900;
}

.spotlight-name.is-rolling {
  color: var(--primary);
  background: linear-gradient(180deg, #f0f7ff 0%, #e0efff 100%);
  box-shadow: inset 0 0 0 2px rgba(24, 101, 242, 0.16), 0 18px 46px rgba(24, 101, 242, 0.16);
  animation: random-roll-pulse 0.45s ease-in-out infinite alternate;
}

@keyframes random-roll-pulse {
  from {
    transform: scale(0.992);
  }
  to {
    transform: scale(1.012);
  }
}

.bomb-board strong,
.twentyfour-numbers {
  font-weight: 900;
}

.bomb-board strong {
  font-size: clamp(32px, 5vw, 64px);
}

.bomb-board.is-exploded {
  overflow: hidden;
  border-color: #fecaca;
  background: radial-gradient(circle at 50% 45%, #fff7ed 0%, #fee2e2 45%, #fecaca 100%);
  animation: bomb-pop 0.78s cubic-bezier(.2, .8, .2, 1);
}

.bomb-board.is-exploded::before,
.bomb-board.is-exploded::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 999px;
  border: 3px solid rgba(220, 38, 38, 0.38);
  animation: bomb-ring 0.78s ease-out forwards;
}

.bomb-board.is-exploded::after {
  inset: 30%;
  border-color: rgba(245, 158, 11, 0.44);
  animation-delay: 0.08s;
}

.bomb-board.is-exploded strong {
  color: #991b1b;
  z-index: 1;
  font-size: clamp(32px, 4.8vw, 58px);
}

.daydream-launcher-board {
  min-height: 0;
  height: 100%;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  border-radius: 8px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 78%, #fff), var(--panel));
}

.daydream-launcher-title {
  display: grid;
  gap: 6px;
  text-align: center;
}

.daydream-launcher-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.daydream-launcher-title strong {
  color: var(--text);
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.1;
  letter-spacing: 0;
}

.daydream-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.daydream-rule-grid div {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
}

.daydream-rule-grid strong {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
}

.daydream-rule-grid span {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.daydream-launcher-controls {
  align-items: end;
}

.daydream-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font-body);
}

.daydream-header,
.daydream-status-card,
.daydream-board-panel,
.daydream-side-panel > section,
.daydream-amount-panel,
.daydream-alert {
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.daydream-header {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
}

.daydream-title {
  min-width: 0;
  text-align: center;
}

.daydream-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-title h1 {
  margin: 2px 0 0;
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1.1;
  letter-spacing: 0;
}

.daydream-clock {
  justify-self: end;
  min-width: 136px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--input-bg);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.daydream-alert {
  padding: 12px 14px;
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  color: var(--danger);
  font-weight: 800;
}

.daydream-status-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.daydream-status-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.daydream-status-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-status-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-status-card.accent {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 82%, var(--panel)), var(--panel));
}

.daydream-status-card.accent strong {
  color: var(--primary);
  font-size: 22px;
  font-weight: 900;
}

.daydream-layout {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 14px;
}

.daydream-board-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.daydream-start-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: var(--control-radius);
  background: var(--primary-soft);
}

.daydream-start-panel h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.daydream-start-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.daydream-box-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(74px, 1fr));
  gap: 10px;
}

.daydream-box {
  aspect-ratio: 1 / 0.78;
  min-width: 0;
  min-height: 72px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: var(--control-radius);
  background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--primary-soft) 64%, var(--panel)));
  color: var(--text);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.daydream-box:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 18%, transparent);
}

.daydream-box:disabled {
  cursor: default;
}

.daydream-box span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.daydream-box strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-box.is-selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 76%, var(--panel)), var(--panel));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
}

.daydream-box.is-opened {
  border-color: var(--border);
  background: color-mix(in srgb, var(--muted) 12%, var(--panel));
}

.daydream-box.is-opened strong {
  color: var(--muted);
  font-size: clamp(14px, 1.5vw, 22px);
}

.daydream-box.is-destiny {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--accent) 74%, var(--primary)));
}

.daydream-box.is-destiny span,
.daydream-box.is-destiny strong {
  color: #fff;
}

.daydream-box.is-reveal {
  animation: daydream-reveal .42s ease-out;
}

@keyframes daydream-reveal {
  0% { transform: rotateY(0deg) scale(.98); }
  55% { transform: rotateY(88deg) scale(1.02); }
  100% { transform: rotateY(0deg) scale(1); }
}

.daydream-side-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}

.daydream-offer-panel,
.daydream-result-panel,
.daydream-ranking-panel {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.daydream-offer-panel span,
.daydream-result-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-offer-panel strong,
.daydream-result-panel strong {
  color: var(--primary);
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.1;
  font-weight: 900;
}

.daydream-offer-panel p,
.daydream-result-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.daydream-offer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.daydream-panel-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.daydream-panel-head strong {
  color: var(--text);
  font-size: 14px;
}

.daydream-panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.daydream-ranking-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.daydream-ranking-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--input-bg);
}

.daydream-ranking-item span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 900;
}

.daydream-ranking-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-ranking-item em {
  color: var(--primary);
  font-style: normal;
  font-weight: 900;
}

.daydream-ranking-item.top {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 54%, var(--input-bg));
}

.daydream-amount-panel {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.daydream-amount-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(13, minmax(54px, 1fr));
  gap: 6px;
}

.daydream-amount-list span {
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--input-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.daydream-amount-list span.is-opened {
  background: color-mix(in srgb, var(--muted) 14%, var(--panel));
  color: var(--muted);
  text-decoration: line-through;
}

.daydream-animation-low .daydream-box,
.daydream-animation-low .daydream-box.is-reveal {
  animation: none;
  transition: none;
}

.daydream-animation-high .daydream-box.is-reveal {
  animation-duration: .62s;
}

@keyframes bomb-pop {
  0% { transform: scale(0.96) rotate(0deg); }
  18% { transform: scale(1.035) rotate(-1deg); }
  36% { transform: scale(0.992) rotate(1deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes bomb-ring {
  from {
    opacity: 0.75;
    transform: scale(0.45);
  }
  to {
    opacity: 0;
    transform: scale(1.7);
  }
}

.twentyfour-board {
  padding: 32px 28px;
}

.twentyfour-difficulty {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 132px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.twentyfour-difficulty select {
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 12px;
}

.twentyfour-numbers {
  display: grid;
  grid-template-columns: repeat(4, minmax(68px, 1fr));
  gap: 14px;
  width: min(520px, 100%);
  font-size: clamp(36px, 5vw, 72px);
}

.twentyfour-numbers span {
  min-height: 96px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  box-shadow: inset 0 -3px 0 rgba(15, 23, 42, 0.08), 0 10px 28px rgba(15, 23, 42, 0.08);
}

.bomb-board span,
.twentyfour-answer {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

@media (orientation: portrait) {
  .admin-grid,
  .search-row,
  .settings-card-grid,
  .settings-page-form,
  .settings-profile-grid,
  .settings-appearance-grid,
  .settings-shell .ai-settings-body,
  .font-settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-brand {
    min-width: 0;
  }

  .topbar-brand img {
    width: 104px;
    height: 38px;
  }

  .app-frame .topbar-brand {
    width: 100%;
    margin-right: 0;
  }

  .app-frame .topbar-brand img {
    width: 96px;
    height: 36px;
  }

  .app-frame .topbar-left,
  .app-frame .topbar-right {
    width: 100%;
    min-width: 0;
  }

  .app-frame .tool-link,
  .app-frame .more-wrap {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .app-frame .more-btn {
    width: 100%;
    min-height: 38px;
    gap: 6px;
    padding: 0 12px 0 8px;
  }

  .app-frame .more-btn-icon {
    width: 23px;
    height: 23px;
  }

  .app-frame .more-btn-icon img {
    width: 16px;
    height: 16px;
  }

  .app-frame .app-download-trigger {
    display: none !important;
  }

  .app-frame .more-menu {
    min-width: 148px;
  }

  .admin-shell .settings-drawer {
    padding: 10px;
    place-items: center;
    align-items: center;
  }

  .admin-shell .settings-drawer .drawer-panel,
  .admin-shell .settings-drawer .drawer-panel.drawer-large {
    align-self: center;
    justify-self: center;
    width: min(420px, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    min-height: 0;
    padding: 12px;
    gap: 10px;
    border-radius: 12px;
    overflow: auto;
  }

  .admin-shell .settings-drawer .drawer-head {
    gap: 10px;
  }

  .admin-shell .settings-drawer .drawer-head strong {
    font-size: 15px;
  }

  .admin-shell .settings-drawer .icon-close {
    width: 32px;
    height: 32px;
    font-size: 21px;
  }

  .admin-shell .settings-drawer .settings-form {
    gap: 9px;
  }

  .admin-shell .settings-drawer .settings-form .grid-two {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .admin-shell .settings-drawer .settings-form > label,
  .admin-shell .settings-drawer .settings-form .grid-two > label,
  .admin-shell .settings-drawer .lookup-extra-fields > label,
  .admin-shell .settings-drawer .system-admin-role-select {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    min-height: 34px;
    font-size: 12px;
  }

  .admin-shell .settings-drawer .settings-form > label:has(textarea),
  .admin-shell .settings-drawer .settings-form .grid-two > label:has(textarea),
  .admin-shell .settings-drawer .lookup-extra-fields > label:has(textarea) {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-shell .settings-drawer input,
  .admin-shell .settings-drawer select {
    height: 34px;
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .admin-shell .settings-drawer textarea {
    min-height: 74px;
    max-height: 128px;
    padding: 8px 9px;
    font-size: 12px;
  }

  .admin-shell .settings-drawer .lookup-extra-fields {
    gap: 7px;
    padding: 8px;
  }

  .admin-shell .settings-drawer .lookup-extra-fields .grid-three.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .admin-shell .settings-drawer .lookup-extra-fields .grid-three.compact > label {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 4px;
    min-height: 32px;
    font-size: 11px;
  }

  .admin-shell .settings-drawer .lookup-extra-fields .grid-three.compact input {
    min-width: 0;
    padding-inline: 6px;
  }

  .admin-shell .settings-drawer .privacy-toggle-box,
  .admin-shell .settings-drawer .system-admin-role-box {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 9px;
  }

  .admin-shell .settings-drawer .privacy-toggle-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .admin-shell .settings-drawer .checkbox-item {
    min-height: 34px;
    padding: 0 8px;
    font-size: 12px;
  }

  .admin-shell .settings-drawer .checkbox-item input,
  .admin-shell .settings-drawer input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    padding: 0;
    margin: 0;
  }

  .admin-shell .settings-drawer .primary-btn {
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
  }

  .lookup-category {
    grid-template-columns: 1fr;
  }

  .lookup-title {
    width: 100%;
  }

  .lookup-item {
    flex-basis: 100%;
    max-width: none;
  }

  .summary-form-grid {
    grid-template-columns: 1fr;
  }

  .lesson-summary-layer,
  .summary-poster-layer,
  .chart-modal-layer,
  .learning-report-layer {
    width: 100vw;
    max-width: 100vw;
    padding: 8px;
    overflow: hidden;
    box-sizing: border-box;
  }

  .lesson-summary-card,
  .summary-poster-card,
  .line-chart-card,
  .learning-report-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 10px;
    gap: 8px;
    overflow: hidden;
    box-sizing: border-box;
  }

  .lesson-summary-card {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  }

  .lesson-summary-card .modal-head,
  .summary-poster-card .modal-head,
  .line-chart-card .modal-head,
  .learning-report-head {
    min-width: 0;
    align-items: flex-start;
    gap: 8px;
  }

  .lesson-summary-card .modal-head > div,
  .summary-poster-card .modal-head > div,
  .line-chart-card .modal-head > div,
  .learning-report-head > div {
    min-width: 0;
  }

  .lesson-summary-card .modal-head h2,
  .summary-poster-card .modal-head h2,
  .line-chart-card .modal-head h2,
  .learning-report-head h2 {
    font-size: 15px;
  }

  .lesson-summary-card .modal-head p,
  .summary-poster-card .modal-head p,
  .line-chart-card .modal-head p,
  .learning-report-head p {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }

  .summary-record-strip,
  .summary-students {
    max-width: 100%;
    padding: 7px;
    overflow: auto;
    flex-wrap: nowrap;
    align-items: center;
    -webkit-overflow-scrolling: touch;
  }

  .summary-record-strip span,
  .summary-students span {
    width: auto;
    max-width: 100%;
    flex: 0 0 auto;
    min-height: 22px;
    padding: 3px 7px;
    white-space: nowrap;
  }

  .summary-students em {
    max-width: min(260px, calc(100vw - 96px));
  }

  .summary-form-grid {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding-right: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .summary-top-row,
  .summary-detail-field,
  .summary-form-grid .entry-field-card,
  .summary-word-limit-field {
    min-width: 0;
    max-width: 100%;
  }

  .summary-form-grid .entry-field-card,
  .summary-word-limit-field {
    grid-template-columns: 1fr !important;
  }

  .summary-form-grid .entry-field-label {
    min-width: 0;
    min-height: 30px;
  }

  .summary-form-grid .entry-field-control,
  .summary-form-grid .entry-field-control input,
  .summary-form-grid .entry-field-control textarea {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .summary-roster-card {
    min-height: 118px;
  }

  .summary-roster-card textarea {
    min-height: 102px;
  }

  .summary-detail-roster {
    min-height: 260px;
  }

  .summary-detail-roster textarea {
    min-height: 244px;
  }

  .summary-detail-roster .roster-title {
    right: 8px;
  }

  .summary-math-toggle {
    min-height: 24px;
    padding: 0 8px;
    font-size: 10px;
  }

  .summary-detail-roster.is-math-view::before {
    right: 100px;
  }

  .summary-math-view {
    min-height: 244px;
    padding: 29px 10px 10px;
    font-size: 12px;
  }

  .lesson-summary-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
    min-width: 0;
  }

  .lesson-summary-action-right {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .lesson-summary-actions button,
  .lesson-summary-action-right button {
    min-width: 0;
    width: 100%;
    padding-inline: 8px;
  }

  .student-mention-popover {
    max-width: calc(100vw - 24px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-poster-card,
  .line-chart-card {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .poster-options,
  .line-chart-toolbar {
    max-width: 100%;
    min-width: 0;
    padding: 8px;
    gap: 7px;
    overflow: visible;
  }

  .poster-options .checkbox-item,
  .poster-font-field,
  .line-chart-legend {
    width: 100%;
    min-width: 0;
  }

  .line-chart-legend {
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
  }

  .summary-poster-preview-wrap,
  .line-chart-canvas-wrap {
    width: 100%;
    max-width: 100%;
    max-height: none;
    min-height: 0;
    overflow: auto;
    place-items: start;
    padding: 8px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
  }

  .summary-poster-preview-wrap canvas {
    width: 520px;
    max-width: none;
  }

  .line-chart-canvas-wrap canvas {
    width: 860px;
    min-width: 860px;
    max-width: none;
  }

  .learning-report-card {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .learning-report-head,
  .learning-report-panel-head,
  .learning-report-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .learning-report-mode-tabs {
    min-width: 0;
  }

  .learning-report-layout {
    min-width: 0;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .learning-report-panel {
    min-width: 0;
    min-height: 280px;
    max-width: 100%;
    padding: 10px;
    overflow: hidden;
  }

  .learning-report-source {
    min-height: 300px;
  }

  .learning-report-preview-wrap {
    min-height: 360px;
  }

  .learning-report-chat {
    min-height: min(520px, calc(100dvh - 96px));
    max-height: calc(100dvh - 96px);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    overflow: hidden;
  }

  .learning-report-source-body,
  .learning-report-preview,
  .learning-report-chat-log {
    min-width: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .learning-report-preview {
    justify-items: start;
    align-items: start;
  }

  .learning-report-canvas,
  .course-outline-canvas {
    width: 260px;
    max-width: none;
  }

  .report-image-viewer-card {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    max-height: calc(100dvh - 12px);
    padding: 10px;
  }

  .report-image-viewer-body {
    justify-items: center;
    padding: 8px;
  }

  .report-image-viewer-body img {
    width: min(900px, 100%);
  }

  .report-preview-set,
  .report-spread {
    width: 560px;
    max-width: none;
  }

  .learning-report-field textarea {
    min-height: 96px;
  }

  .learning-report-chat-input textarea {
    height: 92px;
    min-height: 92px;
    max-height: 92px;
  }

  .learning-report-chat .learning-report-actions {
    padding-top: 0;
  }

  .report-copy-tip {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-copy-field-head {
    align-items: stretch;
  }

  .report-copy-expand-btn {
    min-width: 64px;
  }

  .report-copy-actions {
    justify-content: stretch;
  }

  .report-copy-actions .primary-btn,
  .report-image-toolbar,
  .report-image-toolbar .secondary-btn {
    width: 100%;
  }

  .report-copy-zoom-card {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    max-height: calc(100dvh - 12px);
    padding: 10px;
  }

  .report-copy-zoom-card textarea {
    padding: 12px;
    font-size: 14px;
    line-height: 1.75;
  }

  .learning-report-chat-input textarea {
    min-height: 116px;
  }

  .learning-report-chat-log {
    max-height: none;
  }

  .learning-report-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding-top: 6px;
    background: #f8fafc;
  }

  .learning-report-actions .primary-btn {
    min-height: 42px;
  }

  .interaction-layer {
    width: 100vw;
    max-width: 100vw;
    padding: 8px;
    overflow: hidden;
    align-items: stretch;
    place-items: stretch;
    box-sizing: border-box;
  }

  .interaction-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
    overflow: hidden;
    box-sizing: border-box;
  }

  .interaction-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
  }

  .interaction-topbar > div:first-child {
    min-width: 0;
  }

  .interaction-topbar h2 {
    font-size: 15px;
    line-height: 1.25;
  }

  .interaction-topbar p {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }

  .interaction-top-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }

  .interaction-top-actions .secondary-btn {
    min-height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  .interaction-layout {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(128px, 28dvh);
    gap: 8px;
    overflow: hidden;
  }

  .interaction-tools {
    order: 1;
    min-width: 0;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 8px;
    overflow: hidden;
  }

  .interaction-students {
    order: 2;
    min-width: 0;
    min-height: 0;
    padding: 8px;
    overflow: hidden;
  }

  .interaction-panel-head {
    align-items: center;
    flex-direction: row;
    gap: 8px;
  }

  .interaction-panel-head strong {
    font-size: 12px;
  }

  .interaction-panel-head .inline-check {
    margin-left: auto;
    font-size: 11px;
  }

  .interaction-student-list {
    min-height: 0;
    overflow: auto;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .interaction-student-item {
    grid-template-columns: auto minmax(0, 1fr) 46px;
    gap: 6px;
    padding: 6px;
  }

  .interaction-student-item strong {
    font-size: 12px;
  }

  .interaction-student-item input[type="number"] {
    min-height: 30px;
    padding: 3px 5px;
  }

  .interaction-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .interaction-tabs button {
    min-height: 32px;
    padding: 0 6px;
    border-radius: 8px;
    font-size: 12px;
  }

  .interaction-stage {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .interaction-tool {
    min-width: 0;
    min-height: 100%;
    height: auto;
    gap: 8px;
    overflow: visible;
  }

  .interaction-tool[data-interaction-tool="random"] {
    grid-template-rows: auto minmax(170px, 1fr) auto;
  }

  .interaction-tool[data-interaction-tool="bomb"] {
    grid-template-rows: minmax(170px, 1fr) auto auto;
  }

  .interaction-tool[data-interaction-tool="twentyfour"] {
    grid-template-rows: minmax(190px, 1fr) auto;
  }

  .interaction-tool[data-interaction-tool="daydream"] {
    grid-template-rows: minmax(220px, 1fr) auto auto;
  }

  .daydream-launcher-board {
    padding: 14px;
    gap: 12px;
  }

  .daydream-rule-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .daydream-rule-grid div {
    padding: 9px;
  }

  .tool-control-row,
  .tool-actions {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 7px;
  }

  .interaction-tool[data-interaction-tool="bomb"] .tool-control-row {
    grid-template-columns: 1fr;
  }

  .tool-control-row label {
    width: 100%;
    min-width: 0;
    flex-basis: auto;
    font-size: 11px;
  }

  .tool-control-row input,
  .tool-control-row select {
    min-height: 32px;
    padding: 5px 8px;
  }

  .tool-actions .primary-btn,
  .tool-actions .secondary-btn {
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
  }

  .spotlight-name,
  .bomb-board,
  .twentyfour-board {
    min-height: 170px;
    height: auto;
    padding: 14px 10px;
    gap: 10px;
    overflow: hidden;
  }

  .spotlight-name {
    font-size: clamp(30px, 13vw, 58px);
  }

  .bomb-board strong {
    font-size: clamp(30px, 12vw, 54px);
  }

  .bomb-board span,
  .twentyfour-answer {
    font-size: 12px;
  }

  .twentyfour-board {
    align-content: center;
    padding-top: 58px;
  }

  .twentyfour-difficulty {
    top: 10px;
    right: 10px;
    width: min(126px, calc(100% - 20px));
    font-size: 11px;
  }

  .twentyfour-numbers {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    font-size: clamp(26px, 10vw, 42px);
  }

  .twentyfour-numbers span {
    min-height: 64px;
    border-radius: 10px;
  }

}

@media (orientation: portrait) {
  .api-settings-grid,
  .api-doc-grid,
  .wecom-two-column,
  .wecom-variable-grid {
    grid-template-columns: 1fr;
  }

  .api-key-actions {
    justify-content: flex-start;
  }

  .wecom-card-head {
    display: grid;
  }

  .wecom-bot-page .admin-section-head {
    flex-wrap: wrap;
  }

  .wecom-head-tools {
    order: 3;
    flex-basis: 100%;
    max-width: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .wecom-head-toggles {
    width: 100%;
  }

  .admin-grid-wide,
  .admin-grid-bottom {
    grid-template-columns: 1fr;
  }

  .admin-accounts-card {
    min-height: 0;
  }

  .admin-accounts-card .admin-table,
  .admin-groups-card .admin-table,
  .lookup-categories {
    max-height: none;
  }

  .settings-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (orientation: portrait) {
  .wecom-variable-modal {
    align-items: stretch;
    padding: 12px;
  }

  .wecom-variable-dialog {
    max-height: calc(100vh - 24px);
    padding: 14px;
  }

  .wecom-variable-head {
    gap: 10px;
  }

  .wecom-card-save .primary-btn {
    width: 100%;
  }

  .wecom-head-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wecom-command-table {
    min-width: 960px;
  }
}

@media (min-width: 761px) and (max-height: 760px) {
  .app-frame[data-page="entry"] .workspace {
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .app-frame[data-page="entry"] .entry-layout {
    gap: 10px;
    min-height: 0;
  }

  .app-frame[data-page="entry"] .entry-panel {
    min-height: 0;
    padding: 8px;
    gap: 8px;
    grid-template-rows: auto minmax(150px, 1fr) auto;
  }

  .app-frame[data-page="entry"] .entry-fields {
    gap: 7px;
  }

  .app-frame[data-page="entry"] .entry-field-card {
    min-height: 30px;
  }

  .app-frame[data-page="entry"] .entry-field-label {
    padding-top: 2px;
    padding-bottom: 2px;
  }

  .app-frame[data-page="entry"] .entry-field-control input,
  .app-frame[data-page="entry"] .entry-field-control select {
    min-height: 30px;
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .app-frame[data-page="entry"] .two-textareas {
    gap: 8px;
  }

  .app-frame[data-page="entry"] .roster-card {
    min-height: 160px;
    padding-top: 14px;
    --roster-mask-top: 15px;
  }

  .app-frame[data-page="entry"] .roster-card textarea {
    min-height: 148px;
    padding-top: 27px;
  }

  .app-frame[data-page="entry"] .entry-panel .primary-btn.full {
    min-height: 38px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .learning-report-card {
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
    gap: 8px;
    padding: 10px;
  }

  .learning-report-layout {
    gap: 8px;
  }

  .learning-report-panel {
    padding: 9px;
    gap: 7px;
  }

  .learning-report-head h2 {
    font-size: 18px;
  }

  .learning-report-chat {
    grid-template-rows: auto minmax(120px, 1fr) auto minmax(72px, auto) auto;
    padding: 10px;
    gap: 8px;
  }

  .learning-report-field select {
    min-height: 32px;
    margin-top: 5px;
  }

  .learning-report-chat-input textarea {
    min-height: 72px;
  }

  .learning-report-actions {
    flex: 0 0 auto;
  }

  .learning-report-actions .primary-btn,
  .learning-report-actions .secondary-btn,
  .learning-report-chat > .secondary-btn {
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
}

@media (min-width: 761px) and (max-height: 680px) {
  .app-frame[data-page="entry"] .entry-panel {
    gap: 6px;
    grid-template-rows: auto minmax(122px, 1fr) auto;
  }

  .app-frame[data-page="entry"] .entry-fields {
    gap: 5px;
  }

  .app-frame[data-page="entry"] .entry-field-card,
  .app-frame[data-page="entry"] .entry-field-control input,
  .app-frame[data-page="entry"] .entry-field-control select {
    min-height: 28px;
  }

  .app-frame[data-page="entry"] .roster-card {
    min-height: 132px;
  }

  .app-frame[data-page="entry"] .roster-card textarea {
    min-height: 120px;
  }

  .app-frame[data-page="entry"] .entry-panel .primary-btn.full {
    min-height: 34px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .learning-report-card {
    gap: 6px;
    padding: 8px;
  }

  .learning-report-layout {
    gap: 6px;
  }

  .learning-report-panel {
    padding: 8px;
    gap: 6px;
  }

  .learning-report-chat {
    grid-template-rows: auto minmax(84px, 1fr) auto minmax(60px, auto) auto;
    padding: 8px;
    gap: 6px;
  }

  .learning-report-chat-input textarea {
    min-height: 60px;
  }

  .learning-report-actions .primary-btn,
  .learning-report-actions .secondary-btn,
  .learning-report-chat > .secondary-btn {
    min-height: 34px;
    font-size: 13px;
  }
}

@media (min-width: 1121px) and (max-height: 680px) {
  .app-frame[data-page="entry"] .entry-layout {
    zoom: 0.92;
  }
}

@media (min-width: 1281px) and (max-width: 1440px) and (max-height: 680px) {
  .app-frame[data-page="entry"] .entry-layout {
    zoom: 0.9;
  }
}

@media (min-width: 1121px) and (max-width: 1280px) and (max-height: 680px) {
  .app-frame[data-page="entry"] .entry-layout {
    zoom: 0.86;
  }
}

@media (max-width: 900px) {
  .settings-shell {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .settings-shell .settings-sidebar {
    gap: 10px;
    padding: 12px;
  }

  .settings-shell .admin-brand {
    padding: 12px;
  }

  .settings-shell .admin-brand img {
    width: 132px;
    height: 52px;
  }

  .settings-shell .admin-content {
    padding: 10px;
  }

  .settings-stack {
    gap: 10px;
  }

  .settings-shell .settings-card,
  .settings-shell .ai-settings-card {
    height: auto;
    min-height: 0;
    gap: 10px;
    padding: 12px;
  }

  .settings-shell .settings-card-body,
  .settings-shell .ai-settings-card .ai-settings-body {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 10px;
    align-content: start;
  }

  .settings-appearance-grid,
  .summary-settings-body,
  .settings-profile-grid,
  .settings-shell .font-settings-grid,
  .summary-field-label-grid {
    grid-template-columns: 1fr;
  }

  .settings-shell .ai-model-note {
    min-height: 0;
    padding: 10px 12px;
    display: grid;
    gap: 4px;
  }

  .settings-shell .ai-model-note span {
    min-height: 0;
  }

  .settings-shell .ai-prompt-pair {
    height: auto;
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .settings-shell .ai-prompt-pair label {
    min-height: 0;
  }

  .settings-shell .ai-persona,
  .settings-shell .ai-emphasis {
    height: 220px;
    min-height: 220px;
  }

  .settings-shell .ai-template {
    min-height: 180px;
  }

  .settings-shell .settings-card-actions {
    gap: 8px;
    flex-wrap: wrap;
  }

  .settings-shell .settings-card-actions button {
    flex: 1 1 120px;
  }
}

@media (max-width: 560px) {
  .settings-shell .admin-brand img {
    width: 118px;
    height: 46px;
  }

  .settings-shell .admin-nav {
    gap: 8px;
  }

  .settings-shell .admin-nav-item {
    padding: 10px;
    min-height: 72px;
  }

  .settings-shell .ai-prompt-pair {
    grid-template-columns: 1fr;
  }

  .settings-shell .ai-persona,
  .settings-shell .ai-emphasis {
    height: 180px;
    min-height: 180px;
  }
}

@media (orientation: portrait) {
  body.mobile-sidebar-lock {
    overflow: hidden;
  }

  .mobile-sidebar-toggle {
    display: inline-flex;
    flex-direction: column;
  }

  .app-frame > .topbar {
    position: sticky;
    top: 0;
    z-index: 720;
  }

  .app-frame .topbar-left {
    align-items: center;
  }

  .sidebar,
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 940;
    width: min(292px, calc(100vw - 54px));
    height: 100dvh;
    max-height: 100dvh;
    padding: 16px;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    background: rgba(255,255,255,0.98);
    box-shadow: 18px 0 42px rgba(15,23,42,0.16);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(calc(-100% - 18px));
    transition: transform 0.22s ease;
  }

  .settings-shell .settings-sidebar {
    border-right: 1px solid var(--border);
    border-bottom: 0;
  }

  .app-frame.mobile-sidebar-open .sidebar,
  .admin-shell.mobile-sidebar-open .admin-sidebar {
    transform: translateX(0);
  }

  .mobile-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 930;
    background: rgba(15,23,42,0.38);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .app-frame.mobile-sidebar-open .mobile-sidebar-backdrop,
  .admin-shell.mobile-sidebar-open .mobile-sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .admin-mobile-sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 760;
  }

  .admin-shell .admin-content {
    padding-top: 62px;
  }

  .settings-shell .settings-content {
    padding-top: 62px;
  }

  .settings-shell .settings-nav {
    grid-template-columns: 1fr;
  }
}

@media (orientation: portrait) {
  .app-frame .topbar-left {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
  }

  .app-frame .topbar-left .badge {
    display: none;
  }

  .app-frame .topbar-brand {
    width: auto;
  }

  .sidebar,
  .admin-sidebar {
    width: min(286px, calc(100vw - 42px));
  }
}

/* 白日梦想家新版布局 */
.daydream-page {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.daydream-page *,
.daydream-page *::before,
.daydream-page *::after {
  box-sizing: border-box;
}

.daydream-progress-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.daydream-progress-card > span {
  grid-column: 1 / -1;
}

.daydream-progress-card .primary-btn {
  min-height: 34px;
  padding: 7px 12px;
  white-space: nowrap;
}

.daydream-best-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.daydream-best-card > span,
.daydream-best-card > small {
  grid-column: 1 / -1;
}

.daydream-best-card small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-best-card .secondary-btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.daydream-game-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(142px, 178px) minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

.daydream-amount-rail,
.daydream-board-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.daydream-amount-rail {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.daydream-amount-rail .daydream-panel-head {
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
}

.daydream-amount-rail .daydream-amount-list {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(26, minmax(0, 1fr));
  gap: 5px;
  overflow: hidden;
}

.daydream-amount-rail .daydream-amount-list span {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 2px 5px;
  border-color: color-mix(in srgb, var(--primary) 16%, var(--border));
  background: color-mix(in srgb, var(--primary-soft) 26%, var(--input-bg));
  color: var(--text);
  font-size: 12px;
  line-height: 1.1;
}

.daydream-amount-rail .daydream-amount-list span.is-opened {
  border-style: dashed;
  background: color-mix(in srgb, var(--muted) 16%, var(--panel));
  color: var(--muted);
  text-decoration: line-through;
}

.daydream-board-panel {
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  padding: 12px;
}

.daydream-board-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 10px;
}

.daydream-board-head div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.daydream-board-head span,
.daydream-board-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-board-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-board-head small {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--input-bg);
}

.daydream-board-panel .daydream-box-grid {
  min-height: 0;
  height: 100%;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.daydream-board-panel .daydream-box {
  aspect-ratio: auto;
  min-height: 0;
  height: 100%;
  border-color: color-mix(in srgb, var(--primary) 26%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 92%, #fff), color-mix(in srgb, var(--primary-soft) 58%, var(--panel)));
}

.daydream-board-panel .daydream-box strong {
  font-size: clamp(16px, 2vw, 26px);
}

.daydream-board-panel .daydream-box.is-opened strong {
  font-size: clamp(12px, 1.45vw, 18px);
}

.daydream-board-panel .daydream-box:focus-visible,
.daydream-swap-box:focus-visible,
.daydream-modal-actions button:focus-visible,
.daydream-best-card button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 36%, transparent);
  outline-offset: 2px;
}

.daydream-modal-layer {
  position: fixed;
  inset: 0;
  z-index: 2400;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, 0.54);
  backdrop-filter: blur(8px);
}

.daydream-modal-layer[hidden] {
  display: none !important;
}

.daydream-modal-card {
  width: min(760px, 100%);
  max-height: calc(100dvh - 44px);
  display: grid;
  gap: 14px;
  padding: 18px;
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--panel) 92%, #fff), color-mix(in srgb, var(--primary-soft) 38%, var(--panel))),
    var(--panel);
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.34);
  animation: daydream-modal-in .2s ease-out;
}

.daydream-modal-head {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
}

.daydream-modal-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-modal-head h2 {
  margin: 3px 0 0;
  color: var(--text);
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.1;
}

.daydream-modal-head > strong {
  color: var(--primary);
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1;
  white-space: nowrap;
}

.daydream-modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.daydream-remaining-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--input-bg);
}

.daydream-modal-amount-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.daydream-modal-amount-list span {
  min-width: 0;
  padding: 7px 5px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.daydream-modal-amount-list span.is-high {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 58%, var(--panel));
  color: var(--accent);
}

.daydream-modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.daydream-decision-card .daydream-modal-actions {
  gap: 18px;
  padding: 6px 8px 2px;
}

.daydream-decision-card .daydream-modal-actions button {
  position: relative;
  isolation: isolate;
  min-height: 66px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%);
  color: #fff;
  font-size: clamp(19px, 2.4vw, 26px);
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 2px 6px rgba(15, 23, 42, .34);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .34),
    inset 0 -7px 0 rgba(15, 23, 42, .22),
    0 16px 28px rgba(15, 23, 42, .22);
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}

.daydream-decision-card .daydream-modal-actions button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, .34), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, .16), transparent 54%);
}

.daydream-decision-card .daydream-modal-actions button:hover:not(:disabled),
.daydream-decision-card .daydream-modal-actions button:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  filter: saturate(1.12) brightness(1.03);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .42),
    inset 0 -8px 0 rgba(15, 23, 42, .24),
    0 22px 38px rgba(15, 23, 42, .28);
}

.daydream-decision-card [data-daydream-deal] {
  background: linear-gradient(135deg, #15803d 0%, #22c55e 48%, #0f766e 100%);
}

.daydream-decision-card [data-daydream-no-deal] {
  background: linear-gradient(135deg, #334155 0%, #64748b 50%, #475569 100%);
}

.daydream-swap-box-list,
.daydream-final-reveal,
.daydream-history-list {
  min-width: 0;
  display: grid;
  gap: 9px;
}

.daydream-swap-box-list {
  grid-template-columns: repeat(auto-fit, minmax(116px, 142px));
  justify-content: center;
  justify-items: center;
  gap: 14px;
  padding: 4px 0 2px;
}

.daydream-swap-box {
  width: min(142px, 100%);
  min-width: 0;
  min-height: 98px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: var(--control-radius);
  background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--primary-soft) 64%, var(--panel)));
  color: var(--text);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.daydream-swap-box:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 18%, transparent);
}

.daydream-swap-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-swap-box strong {
  color: var(--text);
  font-size: clamp(20px, 2.2vw, 28px);
}

.daydream-final-reveal {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.daydream-final-reveal div,
.daydream-history-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--input-bg);
}

.daydream-final-reveal span,
.daydream-history-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-final-reveal strong {
  display: block;
  margin-top: 5px;
  color: var(--primary);
  font-size: 26px;
}

.daydream-history-card {
  width: min(680px, 100%);
}

.daydream-history-list {
  max-height: min(560px, calc(100dvh - 190px));
  overflow: auto;
  padding-right: 2px;
}

.daydream-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.daydream-history-item div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.daydream-history-item strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-history-item em {
  color: var(--primary);
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.daydream-history-foot {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

@keyframes daydream-modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .daydream-modal-card,
  .daydream-box.is-reveal {
    animation: none !important;
  }
}

@media (max-width: 900px) {
  .daydream-page,
  body.app-shell .daydream-page {
    height: auto;
    max-height: none;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .daydream-status-grid,
  body.app-shell .daydream-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .daydream-game-main,
  body.app-shell .daydream-game-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, auto);
    overflow: visible;
  }

  .daydream-amount-rail,
  body.app-shell .daydream-amount-rail {
    padding: 10px;
    overflow: hidden;
  }

  .daydream-amount-rail .daydream-panel-head,
  body.app-shell .daydream-amount-rail .daydream-panel-head {
    align-items: center;
    flex-direction: row;
  }

  .daydream-amount-rail .daydream-amount-list,
  body.app-shell .daydream-amount-rail .daydream-amount-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: none;
    gap: 6px;
    overflow: visible;
    padding-bottom: 0;
  }

  .daydream-amount-rail .daydream-amount-list span,
  body.app-shell .daydream-amount-rail .daydream-amount-list span {
    min-width: 0;
    min-height: 26px;
    font-size: 11px;
  }

  .daydream-board-panel,
  body.app-shell .daydream-board-panel {
    padding: 10px;
  }

  .daydream-board-panel .daydream-box-grid,
  body.app-shell .daydream-board-panel .daydream-box-grid {
    height: auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: none;
    gap: 7px;
  }

  .daydream-board-panel .daydream-box,
  body.app-shell .daydream-board-panel .daydream-box {
    min-height: 68px;
    aspect-ratio: 1 / .82;
  }

  .daydream-modal-layer {
    padding: 10px;
  }

  .daydream-modal-card {
    max-height: calc(100dvh - 20px);
    padding: 12px;
    border-radius: 12px;
  }

  .daydream-modal-head {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .daydream-modal-head > strong {
    justify-self: start;
    font-size: 34px;
  }

  .daydream-modal-amount-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .daydream-header,
  body.app-shell .daydream-header {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .daydream-title,
  body.app-shell .daydream-title {
    order: -1;
    text-align: left;
  }

  .daydream-clock,
  .daydream-back-link,
  body.app-shell .daydream-clock,
  body.app-shell .daydream-back-link {
    width: 100%;
    min-width: 0;
  }

  .daydream-status-grid,
  body.app-shell .daydream-status-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .daydream-progress-card,
  .daydream-best-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .daydream-progress-card .primary-btn,
  .daydream-best-card .secondary-btn {
    width: 100%;
  }

  .daydream-amount-rail .daydream-amount-list,
  body.app-shell .daydream-amount-rail .daydream-amount-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .daydream-board-head {
    align-items: stretch;
    flex-direction: column;
    gap: 7px;
  }

  .daydream-board-head small {
    width: 100%;
    text-align: center;
  }

  .daydream-board-panel .daydream-box-grid,
  body.app-shell .daydream-board-panel .daydream-box-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .daydream-board-panel .daydream-box,
  body.app-shell .daydream-board-panel .daydream-box {
    min-height: 62px;
  }

  .daydream-modal-actions,
  .daydream-final-reveal,
  .daydream-swap-box-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .daydream-modal-amount-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .daydream-history-item {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Education theme layer */
body.app-shell {
  color: var(--text);
  background: var(--bg-soft);
}

body.app-shell:not(.theme-rainbow) {
  color-scheme: light;
}

body.app-shell.theme-rainbow {
  color-scheme: dark;
}

body.app-shell .login-screen,
body.app-shell .app-frame,
body.app-shell .admin-shell,
body.app-shell .settings-page,
body.app-shell .settings-shell {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 58%, transparent), transparent 38%),
    var(--bg-soft);
}

body.app-shell input,
body.app-shell select,
body.app-shell textarea {
  background: var(--input-bg);
  color: var(--text);
  border-color: var(--border);
  border-radius: var(--control-radius);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

body.app-shell input:focus,
body.app-shell select:focus,
body.app-shell textarea:focus {
  border-color: var(--primary);
  box-shadow: none;
}

body.app-shell input::placeholder,
body.app-shell textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

body.app-shell .primary-btn {
  border-radius: var(--button-radius);
  background: var(--gradient);
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

body.app-shell .primary-btn:hover {
  filter: saturate(1.06) brightness(1.02);
  box-shadow: var(--shadow-strong);
}

body.app-shell .secondary-btn,
body.app-shell .tool-link,
body.app-shell .more-btn,
body.app-shell .theme-toggle,
body.app-shell .icon-btn {
  border-color: var(--border);
  border-radius: var(--button-radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

body.app-shell .secondary-btn:hover,
body.app-shell .tool-link:hover,
body.app-shell .more-btn:hover,
body.app-shell .theme-toggle:hover,
body.app-shell .icon-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

body.app-shell .badge,
body.app-shell .pill {
  background: var(--primary-soft);
  color: var(--primary);
}

body.app-shell .sidebar,
body.app-shell .admin-sidebar,
body.app-shell .settings-shell .settings-sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-color: var(--border);
}

body.app-shell .sidebar-brand span,
body.app-shell .user-role,
body.app-shell .sidebar-meta,
body.app-shell .admin-brand span,
body.app-shell .admin-nav-item span,
body.app-shell .settings-shell .admin-nav-item span {
  color: var(--sidebar-muted);
}

body.app-shell .sidebar-brand strong,
body.app-shell .user-hi,
body.app-shell .admin-brand strong,
body.app-shell .admin-nav-item strong,
body.app-shell .settings-shell .admin-nav-item strong {
  color: var(--sidebar-text);
}

body.app-shell .nav-item,
body.app-shell .version-chip,
body.app-shell .admin-brand,
body.app-shell .admin-nav-item {
  background: var(--sidebar-item-bg);
  color: var(--sidebar-text);
  border-color: color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: var(--button-radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

body.app-shell .nav-item::before {
  background: var(--accent);
}

body.app-shell .nav-item:hover,
body.app-shell .admin-nav-item:hover {
  background: var(--sidebar-item-hover);
  border-color: color-mix(in srgb, var(--primary) 36%, var(--border));
  box-shadow: var(--shadow-soft);
}

body.app-shell .nav-item.active,
body.app-shell .admin-nav-item.active {
  background: var(--sidebar-item-active);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 48%, var(--border));
  box-shadow: var(--shadow-soft);
}

body.app-shell .nav-item.active .nav-label,
body.app-shell .admin-nav-item.active strong {
  color: var(--primary);
}

body.app-shell .nav-icon,
body.app-shell .nav-item.active .nav-icon,
body.app-shell .version-icon,
body.app-shell .result-count-icon {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}

body.app-shell .topbar,
body.app-shell .app-frame > .topbar {
  background: var(--topbar-bg);
  border-color: var(--border);
  backdrop-filter: blur(14px);
}

body.app-shell .install-card,
body.app-shell .login-panel,
body.app-shell .entry-panel,
body.app-shell .settings-card,
body.app-shell .settings-page-head,
body.app-shell .settings-page-panel,
body.app-shell .admin-section-head,
body.app-shell .admin-table,
body.app-shell .admin-form-card,
body.app-shell .student-profile-shell,
body.app-shell .student-profile-head,
body.app-shell .student-profile-side,
body.app-shell .learning-report-card,
body.app-shell .learning-report-panel,
body.app-shell .learning-report-chat,
body.app-shell .interaction-card,
body.app-shell .interaction-panel,
body.app-shell .interaction-stage,
body.app-shell .interaction-tool,
body.app-shell .excel-export-card,
body.app-shell .lesson-summary-card,
body.app-shell .summary-poster-card,
body.app-shell .line-chart-card {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-soft);
}

body.app-shell .entry-field-card,
body.app-shell .department-filter .department-entry-field,
body.app-shell .checkbox-item,
body.app-shell .system-logo-preview,
body.app-shell .watermark-preview,
body.app-shell .learning-report-source,
body.app-shell .learning-report-preview-wrap,
body.app-shell .learning-report-source-body,
body.app-shell .learning-report-preview,
body.app-shell .learning-report-chat-log,
body.app-shell .interaction-student-item,
body.app-shell .interaction-tabs button,
body.app-shell .learning-report-mode-tabs button {
  background: var(--input-bg);
  color: var(--text);
  border-color: var(--border);
  border-radius: var(--control-radius);
}

body.app-shell .entry-field-label,
body.app-shell .field-label,
body.app-shell .field-hint,
body.app-shell .learning-report-head p,
body.app-shell .learning-report-panel-head span,
body.app-shell .interaction-topbar p,
body.app-shell .admin-section-head p,
body.app-shell .settings-card-head p,
body.app-shell .settings-head-control {
  color: var(--muted);
}

body.app-shell .data-table thead th {
  background: var(--table-head);
  color: var(--text);
  border-color: var(--border);
}

body.app-shell .data-table thead th.is-sortable:hover,
body.app-shell .data-table thead th.is-sort-active {
  background: var(--primary-soft);
  color: var(--primary);
}

body.app-shell .data-table th,
body.app-shell .data-table td {
  border-color: var(--border);
}

body.app-shell .data-table tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

body.app-shell .data-table tbody tr:hover {
  background: var(--table-hover);
}

body.app-shell .empty-row td {
  background: var(--panel);
  color: var(--muted);
}

body.app-shell .data-table tbody tr.is-new {
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

body.app-shell .modal-layer,
body.app-shell .student-profile-modal-layer,
body.app-shell .learning-report-layer,
body.app-shell .interaction-layer {
  background: var(--modal-overlay);
}

body.app-shell .modal-card,
body.app-shell .student-profile-modal-card,
body.app-shell .drawer-panel,
body.app-shell .context-menu {
  background: var(--modal-bg);
  color: var(--text);
  border-color: var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-strong);
}

body.app-shell .context-menu button {
  background: var(--input-bg);
  color: var(--text);
  border-radius: var(--control-radius);
}

body.app-shell .context-menu button:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

body.app-shell .context-menu .danger {
  color: var(--danger);
}

body.app-shell .context-menu .danger:hover,
body.app-shell .admin-shell .tool-link-mini.danger {
  background: color-mix(in srgb, var(--danger) 12%, var(--panel));
  border-color: color-mix(in srgb, var(--danger) 36%, var(--border));
  color: var(--danger);
}

body.app-shell .toast-success {
  background: linear-gradient(135deg, var(--success), color-mix(in srgb, var(--success) 70%, #ffffff));
}

body.app-shell .toast-error {
  background: linear-gradient(135deg, var(--danger), color-mix(in srgb, var(--warning) 70%, var(--danger)));
}

body.app-shell .learning-report-mode-tabs button.active,
body.app-shell .interaction-tabs button.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 46%, var(--border));
}

body.theme-forest .nav-item::before,
body.theme-forest .admin-nav-item.active {
  border-left: 3px solid var(--accent);
}

body.theme-forest .data-table {
  letter-spacing: 0;
}

body.theme-sunrise .student-profile-head,
body.theme-sunrise .learning-report-head,
body.theme-sunrise .interaction-topbar,
body.theme-sunrise .admin-section-head {
  border-top: 3px solid var(--accent);
}

body.theme-sunrise .badge,
body.theme-sunrise .pill {
  background: var(--accent-soft);
  color: var(--primary);
}

body.theme-neutral .data-table th,
body.theme-neutral .data-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}

body.theme-neutral .nav-item,
body.theme-neutral .admin-nav-item {
  min-height: 40px;
  box-shadow: none;
}

body.theme-neutral .primary-btn,
body.theme-neutral .secondary-btn,
body.theme-neutral .tool-link,
body.theme-neutral .more-btn {
  box-shadow: none;
}

body.theme-rainbow .page-watermark {
  mix-blend-mode: screen;
  opacity: 0.08;
}

body.theme-rainbow .page-watermark span {
  color: rgba(226, 232, 240, 0.34);
}

body.theme-rainbow .login-panel,
body.theme-rainbow .install-card,
body.theme-rainbow .topbar,
body.theme-rainbow .app-frame > .topbar,
body.theme-rainbow .modal-card,
body.theme-rainbow .student-profile-modal-card,
body.theme-rainbow .drawer-panel,
body.theme-rainbow .context-menu {
  backdrop-filter: blur(16px);
}

body.theme-rainbow .login-input-pill {
  background: var(--input-bg);
  border-color: var(--border);
}

body.theme-rainbow .login-input-pill input,
body.theme-rainbow .login-remember {
  color: var(--text);
}

body.theme-rainbow .login-input-pill input:-webkit-autofill,
body.theme-rainbow .login-input-pill input:-webkit-autofill:hover,
body.theme-rainbow .login-input-pill input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 1000px #0f172a inset;
}

body.theme-rainbow .primary-btn,
body.theme-rainbow .nav-icon,
body.theme-rainbow .nav-item.active .nav-icon,
body.theme-rainbow .version-icon,
body.theme-rainbow .result-count-icon {
  color: #06111f;
}

body.theme-rainbow .secondary-btn,
body.theme-rainbow .tool-link,
body.theme-rainbow .more-btn,
body.theme-rainbow .theme-toggle,
body.theme-rainbow .icon-btn,
body.theme-rainbow .checkbox-item,
body.theme-rainbow .system-logo-preview,
body.theme-rainbow .watermark-preview {
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
}

body.theme-rainbow .data-table thead th::after {
  color: color-mix(in srgb, var(--primary) 72%, var(--muted));
}

body.theme-rainbow .data-table tbody tr.is-new {
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  body.app-shell .primary-btn,
  body.app-shell .secondary-btn,
  body.app-shell .tool-link,
  body.app-shell .more-btn,
  body.app-shell .theme-toggle,
  body.app-shell .icon-btn,
  body.app-shell input,
  body.app-shell select,
  body.app-shell textarea {
    transition: none;
  }
}

/* Mobile comfort layer for education themes */
@media (orientation: portrait) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body.app-shell {
    --mobile-page-pad: 10px;
    --mobile-control-height: 44px;
    -webkit-text-size-adjust: 100%;
  }

  body.app-shell .login-screen {
    min-height: 100dvh;
    padding: 14px;
    place-items: center;
  }

  body.app-shell .login-panel,
  body.app-shell .install-card {
    width: min(100%, calc(100vw - 24px));
    padding: 18px;
    border-radius: max(var(--card-radius), 14px);
    box-shadow: var(--shadow-strong);
  }

  body.app-shell .login-brand {
    margin-bottom: 18px;
    gap: 8px;
  }

  body.app-shell .login-brand img {
    width: min(132px, 42vw);
    height: 48px;
  }

  body.app-shell .login-brand h1,
  body.app-shell .install-brand h1 {
    font-size: 20px;
  }

  body.app-shell .login-input-pill {
    min-height: var(--mobile-control-height);
    grid-template-columns: 30px minmax(0, 1fr);
    padding: 0 12px;
    border-radius: var(--control-radius);
    background: var(--input-bg);
    border-color: var(--border);
  }

  body.app-shell .login-input-pill input {
    height: 44px;
    font-size: 14px;
  }

  body.app-shell button,
  body.app-shell .primary-btn,
  body.app-shell .secondary-btn,
  body.app-shell .tool-link,
  body.app-shell .more-btn,
  body.app-shell .theme-toggle,
  body.app-shell .icon-btn {
    min-height: var(--mobile-control-height);
  }

  body.app-shell .app-frame,
  body.app-shell .admin-shell,
  body.app-shell .settings-shell {
    width: 100%;
    min-width: 0;
    min-height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    overflow-x: hidden;
  }

  body.app-shell .topbar,
  body.app-shell .app-frame > .topbar {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    gap: 8px;
    align-items: center;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  }

  body.app-shell .topbar-left,
  body.app-shell .topbar-right {
    min-width: 0;
    gap: 8px;
  }

  body.app-shell .topbar-brand {
    min-width: 0;
    width: auto;
    margin-right: 0;
    gap: 8px;
  }

  body.app-shell .topbar-brand img {
    width: 88px;
    height: 34px;
  }

  body.app-shell .topbar-brand strong {
    font-size: 13px;
    line-height: 1.2;
  }

  body.app-shell .topbar-brand span {
    display: none;
  }

  body.app-shell .mobile-sidebar-toggle,
  body.app-shell .admin-mobile-sidebar-toggle {
    width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: var(--control-radius);
    background: var(--panel);
    border-color: var(--border);
  }

  body.app-shell .sidebar,
  body.app-shell .admin-sidebar,
  body.app-shell .settings-shell .settings-sidebar {
    width: min(304px, calc(100vw - 38px));
    padding: 14px;
    background: var(--sidebar-bg);
    box-shadow: 18px 0 44px rgba(15, 23, 42, 0.22);
  }

  body.app-shell .sidebar-nav,
  body.app-shell .admin-nav,
  body.app-shell .settings-nav {
    gap: 8px;
  }

  body.app-shell .nav-item,
  body.app-shell .admin-nav-item {
    min-height: 44px;
    padding: 9px 10px;
  }

  body.app-shell .nav-icon {
    width: 30px;
    height: 30px;
  }

  body.app-shell .content,
  body.app-shell .admin-content,
  body.app-shell .settings-shell .settings-content,
  body.app-shell .workspace {
    width: 100%;
    min-width: 0;
    padding: var(--mobile-page-pad);
    gap: 10px;
    overflow-x: hidden;
  }

  body.app-shell .admin-content,
  body.app-shell .settings-shell .settings-content {
    padding-top: 62px;
  }

  body.app-shell .admin-section-page,
  body.app-shell .settings-stack,
  body.app-shell .entry-layout,
  body.app-shell .processing-layout,
  body.app-shell .student-profile-grid,
  body.app-shell .learning-report-layout,
  body.app-shell .interaction-layout {
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  body.app-shell .admin-section-head,
  body.app-shell .settings-card-head,
  body.app-shell .student-profile-head,
  body.app-shell .learning-report-head,
  body.app-shell .learning-report-panel-head,
  body.app-shell .interaction-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  body.app-shell .admin-section-head h2,
  body.app-shell .student-profile-head h2,
  body.app-shell .learning-report-head h2,
  body.app-shell .interaction-topbar h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.25;
  }

  body.app-shell .admin-section-head p,
  body.app-shell .student-profile-head p,
  body.app-shell .learning-report-head p,
  body.app-shell .interaction-topbar p {
    font-size: 12px;
    line-height: 1.55;
    white-space: normal;
  }

  body.app-shell .entry-panel,
  body.app-shell .settings-card,
  body.app-shell .settings-page-panel,
  body.app-shell .admin-table,
  body.app-shell .admin-form-card,
  body.app-shell .student-profile-shell,
  body.app-shell .student-profile-side,
  body.app-shell .learning-report-card,
  body.app-shell .learning-report-panel,
  body.app-shell .learning-report-chat,
  body.app-shell .interaction-card,
  body.app-shell .interaction-panel,
  body.app-shell .interaction-stage,
  body.app-shell .interaction-tool {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 12px;
    border-radius: max(var(--card-radius), 12px);
  }

  body.app-shell label,
  body.app-shell .settings-head-control,
  body.app-shell .field-label {
    font-size: 12px;
  }

  body.app-shell input,
  body.app-shell select {
    min-height: var(--mobile-control-height);
    padding: 9px 11px;
    font-size: 14px;
  }

  body.app-shell textarea {
    min-height: 120px;
    padding: 11px;
    font-size: 14px;
    line-height: 1.65;
  }

  body.app-shell .entry-field-card,
  body.app-shell .department-filter .department-entry-field,
  body.app-shell .summary-form-grid .entry-field-card,
  body.app-shell .record-edit-fields .entry-field-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  body.app-shell .entry-field-label {
    align-items: start;
    justify-content: start;
    min-height: 0;
    padding: 0;
  }

  body.app-shell .entry-field-control {
    width: 100%;
    min-width: 0;
  }

  body.app-shell .two-textareas,
  body.app-shell .record-edit-grid,
  body.app-shell .record-edit-fields,
  body.app-shell .summary-form-grid,
  body.app-shell .settings-profile-grid,
  body.app-shell .settings-appearance-grid,
  body.app-shell .settings-shell .ai-settings-body,
  body.app-shell .system-settings-grid,
  body.app-shell .system-inline-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  body.app-shell .system-classroom-setting-row {
    align-items: stretch;
    flex-direction: column;
  }

  body.app-shell .table-wrap,
  body.app-shell .admin-table,
  body.app-shell .student-table-wrap,
  body.app-shell .learning-report-source-body,
  body.app-shell .learning-report-preview,
  body.app-shell .learning-report-chat-log {
    max-width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.app-shell .table-wrap .data-table,
  body.app-shell .admin-table .data-table,
  body.app-shell .student-profile-table {
    min-width: 760px;
  }

  body.app-shell .data-table th,
  body.app-shell .data-table td {
    padding: 9px 7px;
    font-size: 12px;
  }

  body.app-shell .modal-layer,
  body.app-shell .student-profile-modal-layer,
  body.app-shell .learning-report-layer,
  body.app-shell .interaction-layer {
    padding: 8px;
    align-items: stretch;
    place-items: stretch;
    overflow: hidden;
  }

  body.app-shell .modal-card,
  body.app-shell .student-profile-modal-card,
  body.app-shell .drawer-panel,
  body.app-shell .drawer-panel.drawer-large,
  body.app-shell .excel-export-card,
  body.app-shell .lesson-summary-card,
  body.app-shell .summary-poster-card,
  body.app-shell .line-chart-card {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    padding: 12px;
    overflow: auto;
  }

  body.app-shell .modal-head,
  body.app-shell .modal-actions,
  body.app-shell .student-profile-actions,
  body.app-shell .learning-report-actions,
  body.app-shell .tool-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  body.app-shell .modal-actions button,
  body.app-shell .student-profile-actions > *,
  body.app-shell .learning-report-actions .primary-btn,
  body.app-shell .learning-report-actions .secondary-btn,
  body.app-shell .tool-actions .primary-btn,
  body.app-shell .tool-actions .secondary-btn {
    width: 100%;
  }

  body.app-shell .context-menu {
    width: min(320px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
  }

  body.app-shell .lesson-summary-card .modal-head {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    text-align: left;
  }

  body.app-shell .lesson-summary-card .modal-head > div {
    min-width: 0;
    text-align: left;
  }

  body.app-shell .lesson-summary-card .modal-head h2,
  body.app-shell .lesson-summary-card .modal-head p {
    text-align: left;
  }

  body.app-shell .record-edit-card {
    height: calc(var(--app-visual-viewport-height, 100dvh) - 16px);
    max-height: calc(var(--app-visual-viewport-height, 100dvh) - 16px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
  }

  body.app-shell .record-edit-scroll {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    overflow: hidden;
  }

  body.app-shell .record-edit-fields {
    align-content: start;
    gap: 5px;
  }

  body.app-shell .record-edit-fields .entry-field-card {
    min-height: 34px;
    grid-template-columns: 92px minmax(0, 1fr) !important;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
  }

  body.app-shell .record-edit-fields .entry-field-label {
    min-height: 0;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    font-size: 12px;
    line-height: 1.2;
  }

  body.app-shell .record-edit-fields .entry-icon-wrap {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  body.app-shell .record-edit-fields .entry-icon-wrap img {
    width: 16px;
    height: 16px;
  }

  body.app-shell .record-edit-fields .entry-field-control {
    min-height: 28px;
    display: flex;
    align-items: center;
    margin-left: 0;
    border-left: 1px solid #d7dee8;
    border-radius: 7px;
  }

  body.app-shell .record-edit-fields .entry-field-control input,
  body.app-shell .record-edit-fields .entry-field-control select {
    height: 28px;
    min-height: 28px;
    padding: 3px 8px;
    font-size: 12px;
    line-height: 1.2;
  }

  body.app-shell .record-edit-rosters {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body.app-shell .record-edit-rosters .roster-card {
    min-height: 0;
    height: 100%;
  }

  body.app-shell .record-edit-rosters .roster-card textarea {
    min-height: 0;
    height: 100%;
    text-align: center;
    text-align-last: center;
  }

  body.app-shell [data-record-context-menu] {
    grid-template-columns: minmax(0, 1fr);
  }

  body.app-shell .settings-head-actions,
  body.app-shell .settings-head-control {
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  body.app-shell .settings-card-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  body.app-shell .settings-shell .settings-sidebar {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    z-index: 940;
    width: auto;
    height: auto;
    max-height: min(58dvh, 420px);
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--border) 82%, var(--primary));
    border-radius: 18px;
    background: color-mix(in srgb, var(--modal-bg) 96%, var(--panel));
    box-shadow: 0 -18px 44px rgba(15, 23, 42, 0.22);
    overflow: auto;
    overscroll-behavior: contain;
    transform: translateY(calc(100% + 18px));
    transition: transform 0.22s ease;
  }

  body.app-shell .settings-shell.mobile-sidebar-open .settings-sidebar {
    transform: translateY(0);
  }

  body.app-shell .settings-shell .admin-brand {
    display: none;
  }

  body.app-shell .settings-shell .settings-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  body.app-shell .settings-shell .settings-nav .admin-nav-item,
  body.app-shell .settings-shell .admin-back-link {
    min-height: 42px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--panel) 88%, var(--bg-soft));
    border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    text-align: center;
  }

  body.app-shell .settings-shell .settings-nav .admin-nav-item strong,
  body.app-shell .settings-shell .admin-back-link {
    font-size: 13px;
    font-weight: 900;
    line-height: 1.2;
  }

  body.app-shell .settings-shell .settings-nav .admin-nav-item span {
    display: none;
  }

  body.app-shell .settings-shell .settings-nav .admin-nav-item.active {
    background: color-mix(in srgb, var(--primary-soft) 84%, var(--panel));
    border-color: color-mix(in srgb, var(--primary) 36%, var(--border));
    color: var(--primary);
  }

  body.app-shell .settings-shell .admin-back-link {
    width: 100%;
    margin-top: 8px;
    color: var(--text);
  }

  body.app-shell .learning-report-card {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  body.app-shell .learning-report-mode-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  body.app-shell .learning-report-mode-tabs button {
    min-height: 40px;
    padding: 0 8px;
  }

  body.app-shell .learning-report-layout {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.app-shell .learning-report-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding-top: 8px;
    background: linear-gradient(180deg, transparent, var(--panel) 22%);
  }

  body.app-shell .learning-report-chat {
    min-height: min(560px, calc(100dvh - 88px));
    max-height: calc(100dvh - 88px);
  }

  body.app-shell .learning-report-chat-input textarea {
    min-height: 96px;
    max-height: 140px;
  }

  body.app-shell .interaction-card {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
  }

  body.app-shell .interaction-layout {
    grid-template-rows: minmax(0, 1fr) minmax(132px, 30dvh);
    overflow: hidden;
  }

  body.app-shell .interaction-students,
  body.app-shell .interaction-tools,
  body.app-shell .interaction-stage {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.app-shell .interaction-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  body.app-shell .interaction-tabs button {
    min-height: 38px;
    padding: 0 6px;
    font-size: 12px;
  }

  body.app-shell .interaction-student-item {
    grid-template-columns: auto minmax(0, 1fr) 48px;
    gap: 7px;
    padding: 8px;
  }

  body.app-shell .spotlight-name {
    font-size: clamp(34px, 14vw, 64px);
  }

  body.app-shell .bomb-board strong {
    font-size: clamp(34px, 13vw, 60px);
  }

  body.app-shell .twentyfour-numbers {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    font-size: clamp(26px, 10vw, 44px);
  }

  body.app-shell .twentyfour-numbers span {
    min-height: 64px;
  }

  body.app-shell .daydream-page {
    width: 100%;
    min-width: 0;
    min-height: 100dvh;
    gap: 10px;
    padding: 10px;
    overflow-x: hidden;
  }

  body.app-shell .daydream-header {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
  }

  body.app-shell .daydream-title {
    order: -1;
    text-align: left;
  }

  body.app-shell .daydream-clock,
  body.app-shell .daydream-back-link {
    width: 100%;
    min-width: 0;
  }

  body.app-shell .daydream-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body.app-shell .daydream-status-card {
    padding: 10px;
  }

  body.app-shell .daydream-status-card strong {
    font-size: 14px;
  }

  body.app-shell .daydream-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  body.app-shell .daydream-board-panel,
  body.app-shell .daydream-side-panel > section,
  body.app-shell .daydream-amount-panel {
    padding: 10px;
  }

  body.app-shell .daydream-start-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  body.app-shell .daydream-box-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  body.app-shell .daydream-box {
    min-height: 66px;
    aspect-ratio: 1 / .88;
  }

  body.app-shell .daydream-box strong {
    font-size: clamp(16px, 5vw, 22px);
  }

  body.app-shell .daydream-side-panel {
    grid-template-rows: auto auto auto;
  }

  body.app-shell .daydream-offer-actions {
    grid-template-columns: 1fr;
  }

  body.app-shell .daydream-amount-list {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  body.app-shell .daydream-amount-list span {
    flex: 0 0 auto;
    min-width: 72px;
  }

  body.app-shell .daydream-amount-panel {
    position: sticky;
    bottom: 0;
    z-index: 4;
  }
}

@media (max-width: 430px) {
  body.app-shell {
    --mobile-page-pad: 8px;
  }

  body.app-shell .login-panel,
  body.app-shell .install-card,
  body.app-shell .entry-panel,
  body.app-shell .settings-card,
  body.app-shell .settings-page-panel,
  body.app-shell .admin-table,
  body.app-shell .admin-form-card,
  body.app-shell .student-profile-shell,
  body.app-shell .learning-report-panel,
  body.app-shell .learning-report-chat,
  body.app-shell .interaction-card,
  body.app-shell .interaction-panel,
  body.app-shell .interaction-stage,
  body.app-shell .interaction-tool {
    padding: 10px;
  }

  body.app-shell .topbar {
    padding: 7px 8px;
  }

  body.app-shell .topbar-brand img {
    width: 76px;
    height: 30px;
  }

  body.app-shell .topbar-brand strong {
    max-width: 148px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.app-shell .badge,
  body.app-shell .pill,
  body.app-shell .tool-link,
  body.app-shell .more-btn {
    padding-left: 10px;
    padding-right: 10px;
    font-size: 12px;
  }

  body.app-shell .admin-section-head h2,
  body.app-shell .student-profile-head h2,
  body.app-shell .learning-report-head h2,
  body.app-shell .interaction-topbar h2 {
    font-size: 17px;
  }

  body.app-shell .table-wrap .data-table,
  body.app-shell .admin-table .data-table,
  body.app-shell .student-profile-table {
    min-width: 680px;
  }

  body.app-shell .learning-report-mode-tabs {
    grid-template-columns: minmax(0, 1fr);
  }

  body.app-shell .interaction-layout {
    grid-template-rows: minmax(0, 1fr) minmax(118px, 28dvh);
  }

}

@media (max-width: 360px) {
  body.app-shell .sidebar,
  body.app-shell .admin-sidebar,
  body.app-shell .settings-shell .settings-sidebar {
    width: calc(100vw - 28px);
    padding: 12px;
  }

  body.app-shell .settings-shell .settings-sidebar {
    width: auto;
    right: 6px;
    bottom: 6px;
    left: 6px;
    padding: 9px;
  }

  body.app-shell .topbar-brand strong {
    max-width: 112px;
  }

  body.app-shell .twentyfour-numbers span {
    min-height: 56px;
  }
}

/* Floating menus and contrast corrections */
body.app-shell .topbar,
body.app-shell .app-frame > .topbar {
  position: relative;
  z-index: 80;
  overflow: visible;
}

body.app-shell .topbar-left,
body.app-shell .topbar-right,
body.app-shell .more-wrap,
body.app-shell .query-menu {
  overflow: visible;
}

body.app-shell .more-wrap {
  z-index: 81;
}

body.app-shell .more-menu,
body.app-shell .query-options {
  z-index: 91;
  background: var(--modal-bg);
  color: var(--text);
  border-color: color-mix(in srgb, var(--border) 80%, var(--primary));
  box-shadow: var(--shadow-strong);
}

body.app-shell .more-menu-link,
body.app-shell .more-menu button,
body.app-shell .query-options a,
body.app-shell .query-options button {
  background: color-mix(in srgb, var(--panel) 88%, var(--bg-soft));
  color: var(--text);
  border: 1px solid transparent;
}

body.app-shell .more-menu-link:hover,
body.app-shell .more-menu button:hover,
body.app-shell .query-options a:hover,
body.app-shell .query-options button:hover {
  background: color-mix(in srgb, var(--primary-soft) 78%, var(--panel));
  color: color-mix(in srgb, var(--primary) 70%, #07111f);
  border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
}

body.app-shell .badge,
body.app-shell .pill {
  color: color-mix(in srgb, var(--primary) 62%, #07111f);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
}

body.app-shell .pill.active,
body.app-shell .query-menu > .pill.active,
body.app-shell .view-toggle-btn.active,
body.app-shell .learning-report-mode-tabs button.active,
body.app-shell .interaction-tabs button.active {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--primary) 86%, #06111f) 0%,
    color-mix(in srgb, var(--secondary) 82%, #06111f) 100%
  );
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 12px 26px var(--shadow);
}

body.app-shell .pill.active:hover,
body.app-shell .query-menu > .pill.active:hover,
body.app-shell .view-toggle-btn.active:hover,
body.app-shell .learning-report-mode-tabs button.active:hover,
body.app-shell .interaction-tabs button.active:hover {
  color: #ffffff;
  filter: saturate(1.08);
}

body.theme-rainbow .badge,
body.theme-rainbow .pill {
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
  border-color: var(--border);
}

body.theme-rainbow .pill.active,
body.theme-rainbow .query-menu > .pill.active,
body.theme-rainbow .view-toggle-btn.active,
body.theme-rainbow .learning-report-mode-tabs button.active,
body.theme-rainbow .interaction-tabs button.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #06111f;
  border-color: transparent;
}

body.theme-rainbow .more-menu-link:hover,
body.theme-rainbow .more-menu button:hover,
body.theme-rainbow .query-options a:hover,
body.theme-rainbow .query-options button:hover {
  background: var(--primary);
  color: #06111f;
}

/* Mobile entry form polish */
@media (orientation: portrait) {
  body.app-shell .app-frame[data-page="entry"] .entry-panel {
    gap: 14px;
    padding: 14px;
    align-content: start;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields {
    gap: 12px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-card {
    display: grid;
    grid-template-columns: clamp(118px, 30vw, 154px) minmax(0, 1fr);
    gap: 0;
    min-height: 46px;
    padding: 0;
    align-items: stretch;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-label {
    min-height: 46px;
    padding: 6px 10px;
    align-items: center;
    justify-content: flex-start;
    border-radius: 10px 0 0 10px;
    border-color: var(--border);
    background: color-mix(in srgb, var(--panel) 92%, var(--primary-soft));
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-label strong {
    font-size: 14px;
    line-height: 1.15;
    color: var(--text);
    text-align: left;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-icon-wrap {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-icon-wrap img {
    width: 18px;
    height: 18px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-control {
    min-height: 46px;
    margin-left: -1px;
    border-left: 1px solid var(--border);
    border-radius: 0 10px 10px 0;
    background: var(--input-bg);
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-control input,
  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-control select {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.25;
    text-align: left;
  }

  body.app-shell .app-frame[data-page="entry"] .two-textareas {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    height: auto;
    align-self: auto;
  }

  body.app-shell .app-frame[data-page="entry"] .roster-card {
    min-height: clamp(260px, 43dvh, 430px);
    height: auto;
    padding-top: 22px;
    --roster-mask-top: 22px;
    --roster-mask-height: 34px;
    --roster-mask-left: 0px;
    --roster-mask-right: 18px;
  }

  body.app-shell .app-frame[data-page="entry"] .roster-title {
    left: 14px;
    top: 0;
    gap: 8px;
    max-width: calc(100% - 28px);
  }

  body.app-shell .app-frame[data-page="entry"] .roster-icon-wrap {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  body.app-shell .app-frame[data-page="entry"] .roster-icon-wrap img {
    width: 24px;
    height: 24px;
  }

  body.app-shell .app-frame[data-page="entry"] .roster-title strong {
    padding: 4px 8px;
    font-size: 15px;
    line-height: 1.2;
    color: var(--text);
    background: var(--panel);
  }

  body.app-shell .app-frame[data-page="entry"] .roster-card textarea {
    min-height: clamp(238px, 39dvh, 390px);
    height: 100%;
    padding: 54px 14px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.75;
    text-align: left;
    text-align-last: auto;
    overflow: auto;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-panel .primary-btn.full {
    min-height: 48px;
    border-radius: 14px;
    font-size: 15px;
  }

  body.app-shell .app-frame[data-page="entry"] .records-panel,
  body.app-shell .app-frame[data-page="entry"] .table-wrap {
    max-width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 430px) {
  body.app-shell .app-frame[data-page="entry"] .entry-panel {
    padding: 12px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-card {
    grid-template-columns: clamp(108px, 31vw, 138px) minmax(0, 1fr);
    min-height: 44px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-label {
    min-height: 44px;
    padding: 6px 8px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-label strong {
    font-size: 13px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-icon-wrap {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-control,
  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-control input,
  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-control select {
    min-height: 44px;
  }

  body.app-shell .app-frame[data-page="entry"] .roster-card {
    min-height: 300px;
  }

  body.app-shell .app-frame[data-page="entry"] .roster-card textarea {
    min-height: 278px;
    padding-top: 56px;
  }
}

@media (max-width: 768px) {
  body.app-shell .lesson-summary-card .summary-form-grid .entry-field-label {
    align-items: center;
    justify-content: flex-start;
    min-height: 32px;
    padding: 4px 8px;
  }

  body.app-shell .lesson-summary-card .summary-form-grid .entry-icon-wrap {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  body.app-shell .lesson-summary-card .summary-form-grid .entry-icon-wrap img {
    width: 18px;
    height: 18px;
  }

  body.app-shell .lesson-summary-card .summary-roster-card textarea {
    padding: 42px 12px 12px;
  }

  body.app-shell .lesson-summary-card .summary-detail-roster textarea {
    padding-top: 46px;
  }

  body.app-shell .lesson-summary-card .summary-math-view {
    padding-top: 42px;
  }
}

@media (max-width: 360px) {
  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-card {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-label,
  body.app-shell .app-frame[data-page="entry"] .entry-fields .entry-field-control {
    margin-left: 0;
    border-radius: 10px;
  }

  body.app-shell .app-frame[data-page="entry"] .roster-title strong {
    max-width: calc(100vw - 118px);
  }
}

/* 白日梦想家细节修正 */
.daydream-settings-card[data-settings-panel="daydream"],
.daydream-results-settings-card[data-settings-panel="daydream"] {
  align-self: start;
}

.daydream-settings-card .daydream-settings-body {
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .55fr);
}

.daydream-results-settings-card {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.daydream-results-settings-card .settings-card-head {
  align-items: center;
}

.daydream-results-settings-card .settings-card-head h1 {
  margin: 0;
}

.daydream-results-settings-card .settings-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.daydream-results-settings-card .daydream-result-list {
  max-height: min(520px, 46dvh);
}

.daydream-best-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.daydream-best-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.daydream-best-info span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-best-info strong {
  min-width: 0;
  overflow: hidden;
  color: var(--primary);
  font-size: 20px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-best-info small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-best-card .secondary-btn {
  align-self: center;
  justify-self: end;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.daydream-offer-history-bar {
  display: grid;
  grid-template-columns: minmax(132px, 190px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}

.daydream-offer-history-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.daydream-offer-history-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-offer-history-title strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-offer-history-list {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
}

.daydream-offer-history-list > span {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--input-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.daydream-offer-history-list b,
.daydream-offer-history-list em,
.daydream-offer-history-list i {
  font-style: normal;
  white-space: nowrap;
}

.daydream-offer-history-list b {
  color: var(--text);
}

.daydream-offer-history-list em {
  color: var(--primary);
  font-weight: 900;
}

.daydream-offer-history-list i {
  color: var(--muted);
}

.daydream-offer-history-list .is-pending {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
  background: color-mix(in srgb, var(--primary-soft) 52%, var(--input-bg));
}

.daydream-offer-history-list .is-accepted {
  border-color: color-mix(in srgb, var(--success) 42%, var(--border));
  background: color-mix(in srgb, var(--success) 12%, var(--input-bg));
}

.daydream-offer-history-list .is-refused {
  opacity: .76;
}

.daydream-last-opened-card {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: var(--control-radius);
  background: color-mix(in srgb, var(--accent-soft) 52%, var(--panel));
}

.daydream-last-opened-card[hidden] {
  display: none !important;
}

.daydream-last-opened-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-last-opened-card strong {
  color: var(--text);
  font-size: 18px;
}

.daydream-last-opened-card em {
  color: var(--accent);
  font-size: 20px;
  font-style: normal;
  font-weight: 900;
}

@media (max-width: 900px) {
  .daydream-settings-card .daydream-settings-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .daydream-best-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .daydream-best-card .secondary-btn {
    width: 100%;
  }

  .daydream-offer-history-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .daydream-offer-history-list {
    flex-wrap: wrap;
    overflow: visible;
  }
}

@media (max-width: 560px) {
  .daydream-last-opened-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .daydream-offer-history-list > span {
    width: 100%;
    justify-content: space-between;
  }
}

/* 白日梦想家报价条与盒子状态增强 */
.daydream-offer-history-bar {
  min-height: 58px;
  grid-template-columns: minmax(128px, 168px) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  overflow: hidden;
}

.daydream-offer-history-title strong {
  font-size: 14px;
}

.daydream-offer-history-list {
  height: 50px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
  overflow: hidden;
}

.daydream-offer-history-list > span {
  width: 100%;
  height: 50px;
  min-width: 0;
  display: grid;
  grid-template-rows: 14px 16px 12px;
  align-items: center;
  justify-items: center;
  gap: 1px;
  padding: 4px 5px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary-soft) 46%, var(--panel));
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}

.daydream-offer-history-list b,
.daydream-offer-history-list em,
.daydream-offer-history-list i {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.daydream-offer-history-list b {
  color: color-mix(in srgb, var(--text) 92%, #000);
  font-size: 11px;
  font-weight: 900;
}

.daydream-offer-history-list em {
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.daydream-offer-history-list i {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.daydream-offer-history-list .is-empty {
  border-color: color-mix(in srgb, var(--border) 82%, var(--muted));
  background: color-mix(in srgb, var(--input-bg) 86%, var(--panel));
  opacity: .66;
}

.daydream-offer-history-list .is-pending {
  border-color: color-mix(in srgb, var(--accent) 56%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 62%, var(--panel));
}

.daydream-offer-history-list .is-pending em,
.daydream-offer-history-list .is-pending i {
  color: var(--accent);
}

.daydream-offer-history-list .is-accepted {
  border-color: color-mix(in srgb, var(--success) 58%, var(--border));
  background: color-mix(in srgb, var(--success) 18%, var(--panel));
}

.daydream-offer-history-list .is-accepted em,
.daydream-offer-history-list .is-accepted i {
  color: var(--success);
}

.daydream-offer-history-list .is-refused {
  border-color: color-mix(in srgb, var(--muted) 30%, var(--border));
  background: color-mix(in srgb, var(--muted) 9%, var(--panel));
  opacity: .88;
}

.daydream-board-panel .daydream-box {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 88%, #fff), color-mix(in srgb, var(--primary-soft) 70%, var(--panel)));
  color: var(--text);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--primary) 10%, transparent);
}

.daydream-board-panel .daydream-box span {
  color: color-mix(in srgb, var(--primary) 70%, var(--muted));
}

.daydream-board-panel .daydream-box strong {
  color: color-mix(in srgb, var(--text) 94%, #000);
  font-weight: 900;
}

.daydream-board-panel .daydream-box.is-selected {
  border-color: color-mix(in srgb, var(--accent) 78%, var(--primary));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 82%, var(--panel)), color-mix(in srgb, var(--accent) 18%, var(--panel)));
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--accent) 34%, transparent),
    0 10px 24px color-mix(in srgb, var(--accent) 16%, transparent);
}

.daydream-board-panel .daydream-box.is-selected span {
  color: color-mix(in srgb, var(--accent) 76%, var(--text));
}

.daydream-board-panel .daydream-box.is-selected strong {
  color: color-mix(in srgb, var(--text) 90%, var(--accent));
}

.daydream-board-panel .daydream-box.is-opened {
  border-color: color-mix(in srgb, var(--muted) 38%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--muted) 12%, var(--panel)), color-mix(in srgb, var(--muted) 18%, var(--input-bg)));
  color: var(--muted);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--muted) 10%, transparent);
}

.daydream-board-panel .daydream-box.is-opened span,
.daydream-board-panel .daydream-box.is-opened strong {
  color: color-mix(in srgb, var(--muted) 86%, var(--text));
}

.daydream-board-panel .daydream-box.is-revealed {
  border-color: color-mix(in srgb, var(--primary) 44%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 54%, var(--panel)), color-mix(in srgb, var(--panel) 82%, var(--input-bg)));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 14%, transparent);
}

.daydream-board-panel .daydream-box.is-revealed span {
  color: color-mix(in srgb, var(--primary) 72%, var(--text));
}

.daydream-board-panel .daydream-box.is-revealed strong {
  color: color-mix(in srgb, var(--text) 88%, var(--primary));
}

.daydream-board-panel .daydream-box.is-destiny {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--primary));
  background:
    radial-gradient(circle at 30% 20%, color-mix(in srgb, #fff 24%, transparent), transparent 34%),
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 78%, var(--accent)), color-mix(in srgb, var(--accent) 84%, var(--primary)));
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, #fff 28%, transparent),
    0 16px 34px color-mix(in srgb, var(--primary) 28%, transparent);
}

.daydream-board-panel .daydream-box.is-destiny span {
  color: color-mix(in srgb, #fff 86%, var(--primary-soft));
}

.daydream-board-panel .daydream-box.is-destiny strong {
  color: #fff;
  text-shadow: 0 2px 10px rgba(15, 23, 42, .28);
}

@media (max-width: 900px) {
  .daydream-offer-history-bar {
    grid-template-columns: minmax(0, 1fr);
    min-height: 104px;
  }

  .daydream-offer-history-list {
    width: 100%;
    grid-template-columns: repeat(8, 64px);
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
}

/* 白日梦想家报价弹窗本轮开盒列表 */
.daydream-last-opened-card {
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
}

.daydream-last-opened-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.daydream-last-opened-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.daydream-last-opened-head strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.daydream-opened-round-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 7px;
}

.daydream-opened-round-item {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 78%, var(--accent-soft));
}

.daydream-opened-round-item span {
  min-width: 0;
  overflow: hidden;
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daydream-opened-round-item strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 女巫的毒药：固定 100 颗棋盘布局 */
.witch-page {
  height: 100vh;
  min-height: 100vh;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.witch-status-card-head,
.witch-progress-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.witch-status-card-head small {
  min-width: 0;
  color: #99f6e4;
  font-size: 12px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.witch-status-card .witch-counter-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.witch-status-card .witch-counter-grid div {
  padding: 7px;
}

.witch-status-card .witch-counter-grid span {
  font-size: 10px;
  white-space: nowrap;
}

.witch-status-card .witch-counter-grid strong {
  font-size: 15px;
}

.witch-progress-row > strong {
  min-width: 0;
  flex: 1 1 auto;
}

.witch-progress-card .witch-control-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 8px;
}

.witch-progress-card .witch-control-actions button {
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.witch-board-panel {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

.witch-board-panel .witch-clue-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: 74px;
  overflow: hidden;
}

.witch-board-panel .witch-clue-card {
  padding: 7px 9px;
}

.witch-board-panel .witch-clue-card strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.witch-pill-grid {
  height: 100%;
  min-height: 0;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  align-content: stretch;
  gap: 6px;
  overflow: hidden;
  scrollbar-gutter: auto;
}

.witch-pill {
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: 3px;
  padding: 3px;
}

.witch-pill-shape {
  width: min(38px, 72%);
  height: 16px;
}

.witch-pill strong {
  font-size: clamp(10px, 0.9vw, 14px);
}

.witch-pill em {
  font-size: 10px;
}

@media (orientation: portrait) {
  .witch-page {
    height: 100svh;
    min-height: 100svh;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .witch-header {
    gap: 8px;
    padding: 8px;
  }

  .witch-title h1 {
    font-size: 22px;
  }

  .witch-clock {
    min-width: 0;
    padding: 6px 8px;
    font-size: 12px;
  }

  .witch-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .witch-status-card {
    gap: 4px;
    padding: 8px;
  }

  .witch-status-card strong {
    font-size: 13px;
  }

  .witch-status-card .witch-counter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .witch-status-card .witch-counter-grid div {
    padding: 5px;
  }

  .witch-status-card .witch-counter-grid span {
    font-size: 9px;
  }

  .witch-status-card .witch-counter-grid strong {
    font-size: 12px;
  }

  .witch-progress-row {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .witch-progress-card .witch-control-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .witch-progress-card .witch-control-actions button {
    width: 100%;
    min-height: 30px;
    padding: 0 6px;
    font-size: 12px;
  }

  .witch-board-panel {
    gap: 6px;
    padding: 7px;
  }

  .witch-board-head {
    display: none;
  }

  .witch-board-panel .witch-clue-list {
    max-height: 58px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .witch-board-panel .witch-clue-card {
    padding: 5px 6px;
  }

  .witch-board-panel .witch-clue-card span {
    font-size: 9px;
  }

  .witch-board-panel .witch-clue-card strong {
    font-size: 10px;
    line-height: 1.25;
  }

  .witch-pill-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(20, minmax(0, 1fr));
    gap: 4px;
    overflow: hidden;
  }

  .witch-pill {
    min-height: 0;
    gap: 1px;
    padding: 2px;
    border-radius: 6px;
  }

  .witch-pill-shape {
    width: min(28px, 74%);
    height: 10px;
  }

  .witch-pill strong {
    font-size: 9px;
    line-height: 1;
  }

  .witch-pill em {
    display: none;
  }
}

@media (orientation: portrait) {
  .interaction-rule-layer {
    padding: 10px;
  }

  .interaction-rule-card {
    width: 100%;
    max-height: calc(100vh - 40px);
    padding: 14px;
  }

  .interaction-rule-head,
  .interaction-rule-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .interaction-rule-meta,
  .interaction-rule-param-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .interaction-rule-actions button {
    width: 100%;
  }
}

/* hidden 属性必须优先于桌面弹窗的网格布局，确保关闭按钮可以真正隐藏窗口。 */
body.app-shell .department-analysis-layer[hidden] {
  display: none !important;
}

/* 普通鼠标点击不显示浏览器默认黑色焦点框，键盘导航仍保留主题色焦点。 */
body.app-shell button:focus:not(:focus-visible),
body.app-shell a:focus:not(:focus-visible),
body.app-shell input:focus:not(:focus-visible),
body.app-shell select:focus:not(:focus-visible),
body.app-shell textarea:focus:not(:focus-visible) {
  outline: none;
}

body.app-shell :is(input, select, textarea):focus {
  outline: none;
  box-shadow: none;
}

body.app-shell :is(button, a, summary, [tabindex]):focus:not(:focus-visible) {
  outline: none;
}

body.app-shell :is(button, a, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.admin-form-notice {
  padding: 10px 12px;
  border-left: 3px solid var(--success);
  background: var(--panel);
  color: var(--text);
  overflow-wrap: anywhere;
}

.admin-form-notice[data-error="1"] {
  border-color: var(--danger);
  color: var(--danger);
}

.admin-password-form,
.system-ai-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.system-ai-form { margin: 0 0 18px; }
.system-ai-form [hidden] { display: none !important; }
.system-ai-route-note { display: grid; gap: 6px; padding: 10px 12px; border-left: 3px solid var(--info); background: color-mix(in srgb, var(--info) 7%, var(--panel)); color: var(--text); }
.system-ai-route-note p { margin: 0; line-height: 1.6; overflow-wrap: anywhere; }
.system-ai-route-note code { margin: 0 4px; color: var(--primary); font-size: 0.95em; }
.system-ai-clear { margin-top: 10px; width: fit-content; }
.system-ai-clear input { width: 16px; min-height: 16px; height: 16px; flex: 0 0 16px; }
.api-settings-card > .system-calendar-head { margin-bottom: 14px; }
.admin-password-form h3 { margin: 0; font-size: 16px; }
.admin-password-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.admin-password-fields label { min-width: 0; }
@media (max-width: 800px) {
  .admin-password-fields { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 901px) {
  .app-frame {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .app-frame .content {
    min-height: 0;
    overscroll-behavior: contain;
  }

  .app-frame .sidebar {
    position: relative;
    inset: auto;
    z-index: auto;
    width: auto;
    height: auto;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-bottom: 0;
    box-shadow: none;
    transform: none;
    transition: none;
  }

  .app-frame .mobile-sidebar-toggle,
  .app-frame .mobile-sidebar-backdrop,
  .app-frame.mobile-sidebar-open .mobile-sidebar-backdrop {
    display: none;
  }
}
