/* 错题整理 · 平板优先样式 */
:root {
  --primary: #2b6cb0;
  --primary-dark: #245a94;
  --primary-tint: #ebf4ff;
  --danger: #dc2626;
  --success: #16a34a;
  --amber: #d97706;
  --text: #1e293b;
  --muted: #64748b;
  --border: #dbe3ee;
  --bg: #f1f5f9;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 16px; color: var(--text); background: var(--bg);
  overscroll-behavior: none;
}
button { font-family: inherit; }
img { -webkit-user-drag: none; user-select: none; }

#splash {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); font-size: 20px; color: var(--muted); z-index: 5000;
}

#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- 侧边栏 ---------- */
#sidebar {
  width: 216px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px;
  padding-top: calc(18px + env(safe-area-inset-top));
}
.avatar-btn {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  padding: 8px; border-radius: 12px; cursor: pointer; text-align: left; margin-bottom: 18px;
}
.avatar-btn:hover { background: var(--bg); }
.avatar-on { background: var(--primary-tint); }
.avatar-circle {
  width: 52px; height: 52px; border-radius: 50%; background: var(--primary-tint);
  border: 2px solid var(--primary); display: flex; align-items: center; justify-content: center;
  font-size: 28px; flex-shrink: 0;
}
.avatar-name { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px; border: none;
  background: none; border-radius: 12px; cursor: pointer; font-size: 16px; color: var(--text);
  min-height: 48px;
}
.nav-item:hover { background: var(--bg); }
.nav-on { background: var(--primary-tint); color: var(--primary-dark); font-weight: 700; }
.nav-icon { font-size: 20px; }
.nav-badge {
  margin-left: auto; background: var(--primary); color: #fff; font-size: 12px;
  min-width: 22px; height: 22px; border-radius: 11px; display: flex; align-items: center; justify-content: center; padding: 0 6px;
}
.sidebar-foot { margin-top: auto; display: flex; justify-content: space-between; padding: 8px; }

/* ---------- 主区 ---------- */
#main { flex: 1; overflow-y: auto; padding: 20px 24px calc(24px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }

.steps { display: flex; align-items: center; gap: 6px; }
.step { padding: 4px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.step-on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.step-arrow { color: var(--muted); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }

/* ---------- 按钮 ---------- */
.btn {
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; font-weight: 600; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-big { min-height: 54px; font-size: 17px; padding: 0 22px; border-radius: 12px; }
.btn-mini { min-height: 32px; font-size: 13px; padding: 0 10px; border-radius: 8px; }
.btn-step { width: 46px; min-height: 46px; font-size: 20px; padding: 0; }
.btn-star-on { background: #fffbeb; border-color: #fcd34d; color: var(--amber); font-weight: 600; }
.btn-ai { background: #f5f3ff; border-color: #ddd6fe; color: #7c3aed; font-weight: 600; }
.btn-next { border-style: dashed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- chips / tags ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card);
  font-size: 14px; cursor: pointer; min-height: 34px; color: var(--text);
}
.chip-on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.chip-sm { padding: 2px 10px; min-height: 24px; font-size: 12px; cursor: default; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; background: #eef2ff; color: #4338ca;
  padding: 4px 10px; border-radius: 8px; font-size: 13px;
}
.tag-sm { padding: 2px 8px; font-size: 12px; }
.tag-kn { background: #ecfdf5; color: #047857; }
.tag-x { border: none; background: none; color: inherit; opacity: .55; cursor: pointer; font-size: 12px; padding: 2px; }
.tag-x:hover { opacity: 1; }

.segment { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg-btn { border: none; background: var(--card); padding: 10px 18px; font-size: 15px; cursor: pointer; min-height: 44px; }
.seg-on { background: var(--primary); color: #fff; font-weight: 600; }

/* ---------- 输入 ---------- */
.input, .no-input, .search-input, .tag-input, .note-input {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: 15px;
  font-family: inherit; background: var(--card); color: var(--text); min-height: 42px;
}
.input:focus, .no-input:focus, .search-input:focus, .tag-input:focus, .note-input:focus {
  outline: 2px solid var(--primary-tint); border-color: var(--primary);
}
.no-input { width: 76px; text-align: center; font-weight: 700; }
.no-big { width: 90px; min-height: 46px; font-size: 18px; }
.search-input { width: 230px; }
.tag-input { flex: 1; min-width: 150px; min-height: 36px; }
.note-input { width: 100%; margin-top: 10px; resize: vertical; }
.stepper { display: flex; align-items: center; gap: 6px; }

/* ---------- 录入页 ---------- */
.capture-panel { display: flex; flex-direction: column; gap: 14px; }
.cap-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-end; }
.cap-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.cap-grow { flex: 1; min-width: 240px; }
.cap-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.draft-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.draft-card { margin-bottom: 0; content-visibility: auto; contain-intrinsic-size: auto 220px; }
.draft-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.draft-part { margin-top: 8px; }
.part-mini { display: block; margin-bottom: 4px; }

.thumb-row { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb-wrap {
  position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); cursor: pointer; background: var(--bg); flex-shrink: 0;
}
.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-badge {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, .65);
  color: #fff; font-size: 11px; text-align: center; padding: 2px 0;
}
.thumb-wrap.selectable { border: 2px dashed var(--primary); }
.thumb-wrap.selected { outline: 3px solid var(--primary); }
.thumb-check {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.empty-part { padding: 10px; background: var(--bg); border-radius: 8px; }

.sticky-bar {
  position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow); margin-top: 18px;
  border: 1px solid var(--border);
}
.practice-bar { justify-content: center; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty p { margin-bottom: 10px; }

/* ---------- 库 ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 8px 16px; font-size: 14px; cursor: pointer; min-height: 38px;
}
.tab-on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.tab-count { opacity: .65; font-size: 12px; margin-left: 4px; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tag-cloud { width: 100%; margin-top: 8px; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 14px; }
.lib-card { padding: 0; overflow: hidden; cursor: pointer; margin-bottom: 0; content-visibility: auto; contain-intrinsic-size: auto 260px; }
.lib-card:hover { box-shadow: 0 4px 18px rgba(15, 23, 42, .14); }
.lib-selected { outline: 3px solid var(--primary); }
.lib-thumb-wrap { position: relative; height: 150px; background: #e2e8f0; }
.lib-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-thumb.noimg { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.lib-no { position: absolute; top: 8px; left: 8px; background: rgba(15, 23, 42, .72); color: #fff; font-size: 12px; padding: 3px 9px; border-radius: 8px; }
.lib-subj { position: absolute; top: 8px; right: 8px; background: var(--primary); color: #fff; font-size: 12px; padding: 3px 9px; border-radius: 8px; }
.lib-check {
  position: absolute; bottom: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
}
.lib-body { padding: 10px 12px 12px; }
.lib-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 6px; }
.lib-date { flex-shrink: 0; }

/* ---------- 题目编辑 ---------- */
.qe-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.qe-no { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 16px; }
.qe-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.qe-part { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 10px; }
.qe-part-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.qe-part-label { font-weight: 700; }
.qe-part-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.organize-tip, .redo-tip { margin-bottom: 14px; }
.stitch-preview { max-width: 100%; max-height: 52vh; display: block; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; }

/* ---------- 详情 / 批注 ---------- */
.meta-card .chip-row { margin-bottom: 6px; }
.note-text { margin: 6px 0; line-height: 1.6; }
.meta-line { margin-top: 6px; }
.part-title { font-size: 18px; margin: 18px 0 10px; display: flex; gap: 8px; align-items: baseline; }
.img-panel { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #f8fafc; margin-bottom: 12px; }
.panel-img { display: block; width: 100%; }
.ann-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ann-canvas.drawing { cursor: crosshair; }
.missing { padding: 30px; text-align: center; }
.ann-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ann-colors { display: flex; gap: 6px; }
.ann-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.ann-color-on { box-shadow: 0 0 0 3px var(--text); }
.ann-size { width: 110px; }
.ann-tip { font-size: 12px; }

/* ---------- 浮窗 ---------- */
.float-win {
  position: fixed; background: var(--card); border-radius: 12px; border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(15, 23, 42, .28); display: flex; flex-direction: column; overflow: hidden;
  min-width: 240px; min-height: 180px;
}
.float-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: #f8fafc; border-bottom: 1px solid var(--border);
  cursor: move; touch-action: none; user-select: none;
}
.float-title { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.float-x { border: none; background: none; cursor: pointer; font-size: 14px; color: var(--muted); padding: 4px 6px; }
.float-body { flex: 1; overflow-y: auto; padding: 10px; }
.float-grip {
  position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #94a3b8 50%); touch-action: none;
}
.fw-imgs .img-panel { margin-bottom: 8px; }

/* ---------- 设置 ---------- */
.profile-card { display: flex; align-items: center; gap: 16px; }
.avatar-big {
  width: 74px; height: 74px; border-radius: 50%; font-size: 40px; background: var(--primary-tint);
  border: 2px solid var(--primary); cursor: pointer; flex-shrink: 0;
}
.profile-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.settings-card h2 { font-size: 17px; margin-bottom: 8px; }
.settings-card p { line-height: 1.6; margin-bottom: 8px; }
.form-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.form-row label { width: 90px; flex-shrink: 0; color: var(--muted); font-size: 14px; }
.form-row .input { flex: 1; min-width: 200px; }
.about-list { padding-left: 20px; line-height: 2; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 10px; }
.emoji-opt { width: 54px; height: 54px; font-size: 28px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); cursor: pointer; }
.emoji-on { border-color: var(--primary); background: var(--primary-tint); box-shadow: 0 0 0 2px var(--primary-tint); }

/* ---------- 模态 / toast ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .48); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 640px; max-height: 92vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(15, 23, 42, .35);
}
.modal-wide { max-width: 940px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-x { border: none; background: none; font-size: 16px; color: var(--muted); cursor: pointer; padding: 6px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-img { max-width: 100%; max-height: 56vh; display: block; margin: 0 auto; border-radius: 8px; }
.img-viewer { text-align: center; }
.img-viewer img { max-width: 100%; max-height: 70vh; }
.confirm-msg { font-size: 16px; line-height: 1.7; }

.toast-root {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 2000;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  width: max-content; max-width: 90vw;
}
.toast {
  background: #1e293b; color: #fff; padding: 11px 20px; border-radius: 12px; font-size: 15px;
  opacity: 0; transform: translateY(10px); transition: all .25s; box-shadow: 0 6px 20px rgba(15, 23, 42, .3);
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ---------- 重做对照布局 ---------- */
.cmp-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.cmp {
  display: flex; height: calc(100dvh - 260px); min-height: 320px;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card);
}
.cmp-v { flex-direction: column; }
.cmp-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.cmp-pane-head {
  padding: 8px 12px; font-weight: 700; font-size: 14px; background: #f8fafc;
  border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: baseline; flex-shrink: 0;
}
.cmp-pane-body { flex: 1; overflow-y: auto; padding: 10px; }
.cmp-divider { flex: 0 0 10px; background: #e2e8f0; cursor: col-resize; touch-action: none; }
.cmp-v .cmp-divider { cursor: row-resize; }
.cmp-divider:hover, .cmp-divider:active { background: #94a3b8; }

/* ---------- 侧边栏收起 ---------- */
#sidebar.collapsed { width: 68px; padding: 18px 8px; }
#sidebar.collapsed .avatar-name, #sidebar.collapsed .nav-label, #sidebar.collapsed .foot-text { display: none; }
#sidebar.collapsed .avatar-btn { justify-content: center; padding: 4px; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 13px 0; position: relative; }
#sidebar.collapsed .nav-badge { position: absolute; top: 4px; right: 4px; margin: 0; min-width: 18px; height: 18px; font-size: 11px; }
#sidebar.collapsed .sidebar-foot { justify-content: center; }
.sidebar-toggle { min-width: 34px; font-size: 16px; }

/* ---------- 图片编辑器 ---------- */
.edit-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.edit-toolbar.busy { opacity: .55; pointer-events: none; }
.edit-stage { text-align: center; background: #0f172a; border-radius: 12px; padding: 12px; }
.edit-frame { position: relative; display: inline-block; max-width: 100%; }
.edit-img { max-width: 100%; max-height: 56vh; display: block; }
.edit-crop-layer { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.edit-rect { position: absolute; border: 2px solid #38bdf8; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .55); cursor: move; }
.edit-handle { position: absolute; width: 18px; height: 18px; background: #38bdf8; border: 2px solid #fff; border-radius: 4px; }
.edit-handle[data-dir="nw"] { left: 0; top: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.edit-handle[data-dir="ne"] { right: 0; top: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.edit-handle[data-dir="sw"] { left: 0; bottom: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.edit-handle[data-dir="se"] { right: 0; bottom: 0; transform: translate(50%, 50%); cursor: nwse-resize; }
.edit-hint { margin-top: 10px; }
.img-actions { display: flex; gap: 6px; margin-bottom: 6px; }

/* ---------- 内置相机 ---------- */
.camera-overlay { position: fixed; inset: 0; background: #000; z-index: 1500; display: flex; flex-direction: column; }
.cam-video, .cam-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cam-top {
  position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.cam-btn { border: none; background: rgba(255, 255, 255, .16); color: #fff; min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: 15px; cursor: pointer; }
.cam-meta { color: #fff; font-size: 15px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.cam-hint {
  position: absolute; left: 0; right: 0; bottom: calc(120px + env(safe-area-inset-bottom)); text-align: center;
  color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); z-index: 2; pointer-events: none;
}
.cam-bottom {
  position: relative; z-index: 2; margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 18px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.cam-shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: rgba(255, 255, 255, .9); cursor: pointer; box-shadow: 0 0 0 3px rgba(0, 0, 0, .35); }
.cam-shutter:active { transform: scale(.94); }
.cam-shutter:disabled { opacity: .5; }
.cam-preview-bar .btn { min-width: 130px; }
.cam-retake { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .4); color: #fff; }

/* ---------- 快捷标签 ---------- */
.qe-quick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.quick-label { flex-shrink: 0; }
.quick-tag { cursor: pointer; }

/* ---------- 窄屏（竖屏/手机） ---------- */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #sidebar {
    width: 100%; flex-direction: row; align-items: center; padding: 8px 10px;
    border-right: none; border-bottom: 1px solid var(--border); gap: 8px;
  }
  .avatar-btn { margin-bottom: 0; padding: 4px; }
  .avatar-circle { width: 40px; height: 40px; font-size: 22px; }
  .avatar-name { display: none; }
  .nav { flex-direction: row; flex: 1; }
  .nav-item { padding: 8px 10px; min-height: 42px; font-size: 14px; flex: 1; justify-content: center; }
  .nav-label { font-size: 13px; }
  .sidebar-foot { display: flex; margin-top: 0; padding: 0; }
  .sidebar-foot .foot-text { display: none; }
  #sidebar.collapsed { width: 100%; padding: 8px 10px; }
  #sidebar.collapsed .nav-item { flex: 0 0 52px; }
  #main { padding: 14px 12px calc(16px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 19px; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
  .lib-thumb-wrap { height: 110px; }
  .search-input { width: 100%; }
  .page-head-actions { margin-left: 0; width: 100%; }
  .form-row label { width: 76px; }
  .cap-actions .btn-big { flex: 1; }
}