/* 液压消防局 · AI导学 —— 共享样式 */
:root {
  --navy: #0d2438;
  --navy-2: #123047;
  --blue: #1976d2;
  --blue-l: #e3f0fb;
  --water: #29b6f6;
  --fire: #ff6b35;
  --fire-d: #e8531a;
  --ok: #2e9e5b;
  --ok-bg: #e6f6ec;
  --warn: #d97706;
  --warn-bg: #fdf3e3;
  --bad: #d64545;
  --bad-bg: #fdeaea;
  --ink: #1f2d3d;
  --muted: #6b7d8f;
  --line: #dbe6ef;
  --bg: #eef4f9;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(13, 36, 56, .08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  touch-action: manipulation;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
input, textarea, select { font-family: inherit; font-size: 16px; }  /* ≥16px 防 iOS 聚焦自动放大 */

/* ---------- 顶栏 ---------- */
.topbar {
  position: relative; z-index: 60;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff;
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;                       /* 窄屏自动换行，绝不横向溢出 */
  padding: 10px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topbar .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--water), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex: 0 0 auto;
}
.topbar h1 { font-size: 17px; margin: 0; line-height: 1.25; min-width: 0; }
.topbar > div { min-width: 0; }
.topbar .sub { font-size: 12px; opacity: .75; }
.topbar .spacer { flex: 1 1 auto; min-width: 8px; }
.badge {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; padding: 4px 12px; font-size: 13px;
  max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.progress-wrap { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.progress-bar {
  width: 120px; height: 8px; border-radius: 99px;
  background: rgba(255,255,255,.2); overflow: hidden;
}
.progress-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--water), #7ee08f); width: 0; transition: width .4s; }
.icon-btn {
  border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.1);
  color: #fff; border-radius: 10px; padding: 7px 13px; font-size: 14px;
}
.icon-btn:hover { background: rgba(255,255,255,.22); }

/* ---------- 布局：顶栏 + 横滑胶囊导航（与 reflection/keshe 同款，不挤压内容） ---------- */
.layout { display: block; max-width: 1180px; margin: 0 auto; padding: 14px; }
.sidenav {
  position: sticky; top: 8px; z-index: 55;
  display: flex; flex-direction: row; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 8px; margin-bottom: 14px;
}
.sidenav::-webkit-scrollbar { display: none; }
.sidenav { scrollbar-width: none; }
.sidenav button {
  flex: 0 0 auto; white-space: nowrap;
  border: 1px solid var(--line); background: #fff; text-align: left;
  padding: 10px 14px; min-height: 44px; border-radius: 999px; font-size: 15px; color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px;
}
.sidenav button:hover { background: var(--blue-l); }
.sidenav button.active { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.sidenav button .dot { font-size: 12px; }
.sidenav .step-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--blue-l);
  color: var(--blue); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.sidenav button.active .step-num { background: var(--fire); color: #fff; }
.main { flex: 1; min-width: 0; }
.sheet-section { display: none; }
.sheet-section.active { display: block; animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 16px; border: 1px solid #e8f0f6;
}
.card h2 { margin: 0 0 4px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.card h3 { margin: 18px 0 8px; font-size: 16px; color: var(--navy); }
.card .hint { color: var(--muted); font-size: 13px; }
.hero {
  background: linear-gradient(120deg, #0d2438 0%, #14486b 55%, #1976d2 100%);
  color: #fff; border: 0;
}
.hero h2 { color: #fff; }
.hero p { opacity: .92; margin: 8px 0 0; }
.constraint-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.chip {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3);
  border-radius: 12px; padding: 9px 14px; font-size: 14px;
}
.chip b { color: #ffd166; }

table.sheet { width: 100%; border-collapse: collapse; margin: 10px 0; }
table.sheet th, table.sheet td {
  border: 1px solid var(--line); padding: 8px 10px; font-size: 14px; text-align: center;
}
table.sheet th { background: var(--blue-l); color: var(--navy); font-weight: 600; }
table.sheet td input, table.sheet td select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
}

.blank {
  display: inline-block; min-width: 90px; border: 0; border-bottom: 2px solid var(--blue);
  background: var(--blue-l); border-radius: 6px 6px 0 0; padding: 4px 10px;
  min-height: 34px;
  text-align: center; font-size: 16px; color: var(--navy); font-weight: 600;
}
.blank:focus { outline: 2px solid var(--water); }
.blank.ok { background: var(--ok-bg); border-color: var(--ok); }
.blank.bad { background: var(--bad-bg); border-color: var(--bad); }

textarea.area {
  width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; resize: vertical;
}
input.line {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%;
}

.btn {
  border: 0; border-radius: 10px; padding: 12px 22px; font-size: 16px; font-weight: 600;
  min-height: 44px;                     /* Apple 触控目标建议 */
  background: var(--blue); color: #fff; transition: transform .05s, filter .2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn.fire { background: linear-gradient(90deg, var(--fire), var(--fire-d)); }
.btn.ghost { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 8px 14px; font-size: 14px; border-radius: 8px; min-height: 36px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.feedback {
  margin-top: 10px; border-radius: 10px; padding: 10px 14px; font-size: 14px;
  display: none; white-space: pre-wrap;
}
.feedback.show { display: block; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe6cd; }
.feedback.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f3d9a8; }
.feedback.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid #f2c1c1; }
.feedback.info { background: var(--blue-l); color: var(--navy); border: 1px solid #bcd9f5; }

.tag { font-size: 12px; border-radius: 99px; padding: 2px 10px; font-weight: 600; }
.tag.done { background: var(--ok-bg); color: var(--ok); }
.tag.todo { background: #eef2f6; color: var(--muted); }

.formula-tiles { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.tile {
  min-width: 46px; height: 46px; border-radius: 10px; border: 2px dashed var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: var(--navy); background: #fbfdff;
}
.tile.fixed { border: 2px solid var(--navy); background: var(--navy); color: #fff; }
.tile.drop { border-color: var(--water); background: #fff; cursor: default; }
.tile.drop.filled { border-style: solid; border-color: var(--blue); background: var(--blue-l); }
.tile-pool { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.tile-pool .tile { border: 2px solid var(--blue); background: #fff; cursor: pointer; }
.tile-pool .tile.used { opacity: .3; pointer-events: none; }

.sim-wrap { display: flex; gap: 18px; flex-wrap: wrap; }
.sim-canvas-box { flex: 1 1 480px; min-width: 300px; }
.sim-canvas-box canvas { width: 100%; border-radius: 12px; background: #f4fafd; border: 1px solid var(--line); display: block; touch-action: none; }
.sim-panel { flex: 1 1 240px; min-width: 230px; }
.sim-panel label { font-size: 13px; color: var(--muted); display: block; margin: 12px 0 4px; }
.sim-panel input[type=range] { width: 100%; height: 34px; accent-color: var(--blue); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue); margin-top: -10px; box-shadow: 0 1px 5px rgba(0,0,0,.3);
}
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 99px; background: #dde8f0; }
input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--blue); }
.sim-panel select { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--line); }
.meter { margin: 10px 0; }
.meter .meter-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.meter .track { height: 14px; border-radius: 99px; background: #e8eef4; overflow: hidden; position: relative; }
.meter .track > i { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .3s; }
.meter .limit { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--bad); }

.step-acc { border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; overflow: hidden; }
.step-acc > header {
  padding: 12px 14px; background: #f7fbfe; cursor: pointer; font-weight: 600;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.step-acc > header .n {
  width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: #fff;
  font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
}
.step-acc > div { padding: 4px 14px 14px; display: none; font-size: 14px; }
.step-acc.open > div { display: block; }

.photo-grid { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.photo-grid img {
  width: 96px; height: 96px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); cursor: zoom-in;
}

.radio-line { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.radio-line label { display: inline-flex; align-items: center; gap: 5px; font-size: 15px; cursor: pointer; }
.radio-line input[type=radio] { width: 18px; height: 18px; }

.stars { display: inline-flex; gap: 4px; }
.stars span { font-size: 30px; cursor: pointer; color: #d5dee7; transition: transform .1s; }
.stars span.on { color: #ffb400; }
.stars span:hover { transform: scale(1.15); }

/* ---------- 登录遮罩 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(9, 24, 38, .6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.mask.hidden { display: none; }
.login-card {
  background: #fff; border-radius: 18px; padding: 28px; width: 100%; max-width: 430px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.login-card h2 { margin: 0 0 6px; }
.login-card .row { margin: 12px 0; }
.login-card label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.login-card select, .login-card input { width: 100%; padding: 11px; border-radius: 10px; border: 1px solid var(--line); font-size: 16px; }
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-grid button {
  border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 4px; font-size: 14px;
}
.role-grid button.sel { border-color: var(--blue); background: var(--blue-l); font-weight: 600; color: var(--navy); }

/* ---------- AI助教 ---------- */
.tutor-fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 80;
  width: 62px; height: 62px; border-radius: 50%; border: 0; font-size: 28px;
  background: linear-gradient(135deg, var(--water), var(--blue)); color: #fff;
  box-shadow: 0 6px 18px rgba(25,118,210,.45);
}
.tutor-panel {
  position: fixed; right: 18px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 80;
  width: min(380px, calc(100vw - 36px));
  height: min(560px, calc(100vh - 150px));
  height: min(560px, calc(100dvh - 150px));
  background: #fff; border-radius: 16px; box-shadow: 0 14px 44px rgba(0,0,0,.28);
  display: none; flex-direction: column; overflow: hidden;
}
.tutor-panel.open { display: flex; }
.tutor-panel header {
  background: var(--navy); color: #fff; padding: 12px 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.tutor-panel header .x { margin-left: auto; background: none; border: 0; color: #fff; font-size: 18px; }
.tutor-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: #f1f6fb; border-bottom-left-radius: 4px; }
.tutor-chips { display: flex; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
.tutor-chips button { border: 1px solid var(--line); background: #f7fafc; border-radius: 99px; padding: 4px 10px; font-size: 12px; }
.tutor-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.tutor-input input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.tutor-input button { border: 0; background: var(--blue); color: #fff; border-radius: 10px; padding: 0 16px; }

/* ---------- 教师端 ---------- */
.matrix-wrap { overflow-x: auto; }
.badge-done { color: var(--ok); font-weight: 700; }
.badge-none { color: #c3ccd5; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 96vw); z-index: 90;
  background: #fff; box-shadow: -8px 0 30px rgba(0,0,0,.2); transform: translateX(100%);
  transition: transform .25s; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer .body { flex: 1; overflow-y: auto; padding: 14px 18px; }
.ans-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.ans-item .q { font-size: 12px; color: var(--muted); }
.ans-item .a { margin: 6px 0; white-space: pre-wrap; font-size: 14px; }
.ans-item .f { font-size: 12px; color: var(--blue); background: var(--blue-l); border-radius: 8px; padding: 6px 9px; margin-top: 6px; white-space: pre-wrap; }
.ans-item img { max-width: 110px; border-radius: 8px; margin: 4px 6px 0 0; cursor: zoom-in; }
.img-viewer { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; }
.img-viewer.open { display: flex; }
.img-viewer img { max-width: 92vw; max-height: 88vh; transition: transform .2s; }

.stat-cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat-card { flex: 1 1 140px; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; }
.stat-card .v { font-size: 26px; font-weight: 800; color: var(--navy); }
.stat-card .k { font-size: 12px; color: var(--muted); }
.dim-bar { margin: 8px 0; }
.dim-bar .lbl { display: flex; justify-content: space-between; font-size: 13px; }
.dim-bar .tr { height: 10px; background: #e8eef4; border-radius: 99px; overflow: hidden; }
.dim-bar .tr i { display: block; height: 100%; background: linear-gradient(90deg, var(--water), var(--blue)); }

/* ============ 平板（iPad 横屏 1024~1180）============ */
/* 保持双栏仿真布局，只压缩卡片留白 —— 对齐 reflection 的断点策略 */
@media (max-width: 1200px) {
  .layout { max-width: 100%; padding: 12px; }
  .card { padding: 18px; }
}

/* iPad 竖屏（768~834）及以下 */
@media (max-width: 900px) {
  .layout { padding: 10px; }
  .topbar { gap: 8px; padding: 10px 12px; }
  .topbar .sub { display: none; }
  .sim-wrap { flex-direction: column; }
  .sim-panel { flex: none; }
}

/* ============ 手机 ============ */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .card { padding: 14px; border-radius: 12px; }
  .card h2 { font-size: 18px; }
  .blank { min-width: 72px; }
  .topbar h1 { font-size: 15px; }
  .topbar .logo { width: 34px; height: 34px; font-size: 18px; }
  .progress-bar { width: 70px; }
  .sidenav { top: 6px; padding: 6px; gap: 6px; }
  .sidenav button { padding: 8px 12px; font-size: 14px; }
  .tile { min-width: 42px; height: 42px; }
  .stars span { font-size: 26px; }
  .login-card { padding: 20px; }
  .radio-line { gap: 10px; }
  /* AI助教变成底部全宽面板 */
  .tutor-panel {
    right: 0; left: 0; bottom: 0; width: 100%;
    height: 72vh; height: 72dvh;
    border-radius: 16px 16px 0 0;
  }
  .tutor-fab { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .img-viewer img { max-width: 96vw; }
}
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-scroll table.sheet { min-width: 560px; }
