/* V6.1 UI Layout Override — 顶部导航 + 宽屏内容 + 响应式
 * 替代左侧固定导航。加载在 v4.css 之后覆盖布局样式。
 * 本文件只处理布局结构，不处理学校品牌配色（由 school-theme.js 负责）。
 */

/* ============ 顶部导航 Header ============ */
.sidebar {
  position: sticky !important;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 64px !important;
  min-height: 64px;
  padding: 0 28px !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 20px;
  background: var(--paper);
  border-right: none !important;
  border-bottom: 1px solid var(--line);
  z-index: 100;
  overflow: visible;
}
.sidebar .brand {
  flex: none;
  gap: 10px;
}
.sidebar .crest { width: 36px; height: 40px; font-size: 18px; }
.sidebar .brand small { font-size: 10px; margin-top: 2px; }
.sidebar .school-selector { display: none; }
.sidebar nav {
  display: flex !important;
  flex-direction: row !important;
  gap: 2px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.sidebar nav::-webkit-scrollbar { display: none; }
.sidebar nav button {
  flex: none;
  gap: 6px;
  padding: 8px 14px !important;
  font-size: 13px;
  border-radius: 4px;
  white-space: nowrap;
}
.sidebar nav button.active {
  background: var(--brand);
  color: #fff;
}
.sidebar nav small { display: none; }
.sidebar-bottom {
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  flex: none;
}
.sidebar-bottom p { display: none; }
.sidebar-bottom small { display: none; }

/* ============ 主内容区 ============ */
.main-shell { margin-left: 0 !important; }
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 40px 60px;
}

/* ============ 顶栏合并到 Header（隐藏原 topbar） ============ */
.topbar { display: none !important; }

/* ============ 首页 ============ */
.home-hero {
  grid-template-columns: 1.2fr 1fr;
  min-height: 420px;
  gap: 40px;
  padding: 40px 0 40px;
  border-bottom: none;
}
.home-hero h1 { font-size: 42px; line-height: 1.35; letter-spacing: -.01em; }
.home-hero figure { border-radius: 4px; min-height: 340px; }

/* ============ 教材课堂 ============ */
.curriculum-unit { grid-template-columns: 180px 1fr; gap: 30px; }
.lesson-top h1 { font-size: 28px; }
.art-layout { grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); gap: 24px; }
.viewer { height: 480px; }

/* ============ 作品馆 ============ */
.gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 24px; }

/* ============ ============ */

/* ============ 笔记本 1366px ============ */
@media (max-width: 1440px) {
  main { padding: 24px 32px 50px; max-width: 1200px; }
  .home-hero h1 { font-size: 36px; }
  .home-hero { min-height: 360px; }
  .viewer { height: 420px; }
}

@media (max-width: 1200px) {
  .sidebar { padding: 0 18px; }
  main { padding: 20px 24px 50px; }
  .home-hero h1 { font-size: 32px; }
  .curriculum-unit { grid-template-columns: 150px 1fr; gap: 24px; }
  .art-layout { grid-template-columns: 1fr; }
}

/* ============ 平板 ~900px ============ */
@media (max-width: 900px) {
  .sidebar { padding: 0 14px; height: 56px; min-height: 56px; }
  .sidebar .brand small { display: none; }
  .sidebar nav button { padding: 7px 10px; font-size: 12px; }
  main { padding: 18px 16px 40px; }
  .home-hero { grid-template-columns: 1fr; gap: 20px; min-height: auto; }
  .home-hero h1 { font-size: 28px; }
  .home-hero figure { min-height: 220px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 20px; }
  .curriculum-unit { grid-template-columns: 1fr; gap: 16px; }
  .art-layout { grid-template-columns: 1fr; gap: 16px; }
  .split { grid-template-columns: 1fr; gap: 20px; }
  .viewer { height: 360px; }
  .gallery-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
}

/* ============ 手机 390px ============ */
@media (max-width: 540px) {
  .sidebar {
    padding: 0 12px;
    height: 52px;
    min-height: 52px;
    gap: 8px;
  }
  .sidebar .crest { width: 30px; height: 34px; font-size: 15px; }
  .sidebar .brand { font-size: 13px; }
  .sidebar nav button { padding: 6px 8px; font-size: 11px; }
  .sidebar nav button small { display: none; }
  .sidebar-bottom button { font-size: 10px; padding: 4px 8px; }
  main { padding: 14px 12px 40px; }
  .home-hero h1 { font-size: 24px; }
  .home-hero figure { min-height: 180px; }
  .lesson-top h1 { font-size: 20px; }
  .viewer { height: 280px; }
  .gallery-grid { grid-template-columns: 1fr; gap: 14px; }
  .paper { padding: 16px; }
  .art-selection button { min-width: 120px; }
  .zones button { font-size: 12px; padding: 8px 10px; }
}

/* ============ 消除侧栏空白 ============ */
/* 确保 main-shell 不再留有侧栏偏移 */
@media (min-width: 701px) {
  .main-shell { margin-left: 0 !important; }
}


/* ============ R12 第二阶段：内容布局 ============ */

/* 首页 */
.home-section { margin: 0 auto 48px; max-width: 1280px; padding: 0 40px; }
.home-section .section-head { border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin: 0 0 24px; }
.home-section .section-head h2 { font-size: 22px; font-weight: 700; margin: 0; }
.home-section .section-head span { font-size: 12px; color: var(--muted); }

.home-hero { padding: 48px 40px; border-bottom: 1px solid var(--line); }
.home-hero h1 { font-size: 44px; line-height: 1.3; margin: 12px 0; }
.home-sub { font-size: 15px; color: var(--muted); line-height: 1.8; margin: 8px 0 20px; }
.hero-actions .primary { padding: 14px 32px; font-size: 15px; }
.home-hero figure { position: relative; overflow: hidden; }
.home-hero figure img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.home-hero figure:hover img { transform: scale(1.03); }
.home-hero figure.img-absent { min-height: 280px; background: var(--surface); }
.home-hero figcaption { position: absolute; bottom: 0; right: 0; font-size: 11px; color: var(--muted); padding: 8px; background: rgba(255,255,255,.85); }

/* 精选课程网格 */
.home-featured-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.home-course-card {
  background: var(--paper); border: 1px solid var(--line); overflow: hidden;
  text-align: left; padding: 0; cursor: pointer; transition: transform .2s, box-shadow .2s;
}
.home-course-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.home-course-card .hcc-visual { height: 140px; background: var(--surface); overflow: hidden; }
.home-course-card .hcc-visual img { width: 100%; height: 100%; object-fit: cover; }
.home-course-card .hcc-body { padding: 14px 16px; }
.home-course-card .hcc-body small { display: block; font-size: 10px; color: var(--muted); margin-bottom: 6px; letter-spacing: .03em; }
.home-course-card .hcc-body b { display: block; font-size: 15px; margin-bottom: 6px; }
.home-course-card .hcc-body p { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.6; }

/* 作品探索横向条 */
.home-works-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.home-work-card {
  text-align: left; padding: 0; border: none; background: transparent; cursor: pointer;
}
.home-work-card .hwc-img {
  height: 160px; background: var(--surface); overflow: hidden; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
}
.home-work-card .hwc-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.home-work-card:hover .hwc-img img { transform: scale(1.05); }
.home-work-card .hwc-img .ph { font-size: 11px; color: var(--muted); padding: 12px; text-align: center; }
.home-work-card b { display: block; font-size: 13px; margin: 8px 0 3px; }
.home-work-card small { font-size: 11px; color: var(--muted); }

/* 教材单元网格 */
.home-units-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.home-unit-card {
  background: var(--paper); border: 1px solid var(--line); padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.home-unit-card .hu-num { font-family: Georgia, serif; font-size: 36px; color: var(--line); font-weight: 400; line-height: 1; }
.home-unit-card b { font-size: 16px; }
.home-unit-card small { font-size: 11px; color: var(--muted); }
.home-unit-card p { font-size: 12px; color: var(--muted); margin: 4px 0 0; line-height: 1.6; }
.home-unit-card .hu-themes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.home-unit-card .hu-theme-link {
  font-size: 11px; color: var(--brand); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 2px; cursor: pointer; background: transparent;
}
.home-unit-card .hu-theme-link:hover { border-color: var(--brand); }

/* 展览卡 */
.home-exh-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.home-exh-card {
  display: block; background: var(--paper); border: 1px solid var(--line);
  padding: 18px; text-decoration: none; color: var(--ink); transition: border-color .2s;
}
.home-exh-card:hover { border-color: var(--brand); }
.home-exh-card b { display: block; font-size: 15px; margin-bottom: 4px; }

/* 看画页面 65/35 双栏 */
.art-layout { grid-template-columns: minmax(0, 65fr) minmax(280px, 35fr) !important; gap: 28px; }

/* 教材课堂目录 */
.curriculum-unit { grid-template-columns: 200px 1fr; gap: 32px; }

/* 响应式 */
@media (max-width: 1200px) {
  .home-featured-grid { grid-template-columns: repeat(2, 1fr); }
  .home-works-strip { grid-template-columns: repeat(3, 1fr); }
  .home-units-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .home-section { padding: 0 20px; margin-bottom: 36px; }
  .home-hero { padding: 28px 20px; }
  .home-hero h1 { font-size: 28px; }
  .home-featured-grid { grid-template-columns: 1fr; }
  .home-works-strip { grid-template-columns: repeat(2, 1fr); }
  .home-units-grid { grid-template-columns: 1fr; }
  .home-exh-grid { grid-template-columns: 1fr; }
  .art-layout { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .home-section { padding: 0 12px; margin-bottom: 28px; }
  .home-hero { padding: 20px 12px; }
  .home-hero h1 { font-size: 22px; }
  .home-works-strip { grid-template-columns: 1fr 1fr; }
  .home-work-card .hwc-img { height: 120px; }
}


/* ============ 看画页面 65/35 双栏 ============ */
.art-layout {
  display: grid;
  grid-template-columns: minmax(0, 65fr) minmax(280px, 35fr) !important;
  gap: 28px;
  align-items: start;
}
.art-layout > div:first-child { min-width: 0; }
.art-companion-column { min-width: 0; }

/* 作品查看器 */
.viewer { height: 520px; background: #2a3028; border-radius: 2px; }
.viewer img { pointer-events: none; user-select: none; }

/* 局部按钮 */
.region-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0; }
.region-row button { font-size: 12px; border: 1px solid var(--line); background: var(--paper); padding: 6px 12px; border-radius: 2px; cursor: pointer; }
.region-row button:hover { border-color: var(--brand); color: var(--brand); }

/* 观察点 */
.marker { z-index: 3; }

/* 对照观看 */
.comparison { background: var(--paper); padding: 16px; margin-top: 16px; border: 1px solid var(--line); }
.comparison img { max-width: 100%; max-height: 200px; object-fit: contain; }
.comparison h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; }

/* ============ 七步读画 ============ */
.zones { border-bottom: 2px solid var(--ink); margin-bottom: 18px; }
.zones button { font-size: 14px; font-weight: 600; padding: 10px 16px; letter-spacing: .03em; }
.zones button.active { border-bottom: 3px solid var(--brand); }

.reading-progress { display: flex; gap: 16px; align-items: center; font-size: 13px; margin: 14px 0; }
.reading-progress strong { font-size: 15px; }
.reading-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); gap: 24px; }

/* ============ 作品馆 ============ */
.page-head { border-bottom: 2px solid var(--ink); padding-bottom: 20px; margin-bottom: 24px; }
.page-head h1 { font-size: 32px; font-weight: 700; letter-spacing: -.01em; }

.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.gallery-grid .generated-visual { height: 260px; border: 1px solid var(--line); }

/* ============ 集体展厅 ============ */
.student-gallery-shell { max-width: 1280px; margin: 0 auto; padding: 20px; }
.student-gallery-shell-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.student-gallery-shell h1 { font-size: 26px; font-weight: 700; }

/* ============ 登录/注册 ============ */
.ms-login, .ms-register, .ms-signedin {
  max-width: 480px; margin: 40px auto; padding: 28px 32px;
  background: var(--paper); border: 1px solid var(--line);
}
.ms-login h3, .ms-register h3, .ms-signedin h3 { font-size: 18px; margin: 0 0 14px; }
.ms-login label, .ms-register label, .ms-register .ms-role-seg { display: block; margin: 12px 0 4px; font-size: 13px; }
.ms-login input, .ms-register input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 3px; font-size: 14px; background: #fff;
}
.ms-login button, .ms-register button[type=submit] {
  width: 100%; padding: 12px; background: var(--brand); color: #fff;
  border: none; border-radius: 3px; font-size: 14px; cursor: pointer; margin-top: 12px;
}
.ms-status { font-size: 13px; color: var(--brand); min-height: 18px; }
.ms-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.ms-reglink { font-size: 13px; color: var(--brand); cursor: pointer; display: inline-block; margin-top: 10px; }

/* ============ 管理后台 ============ */
.ms-admin-panel { max-width: 960px; margin: 30px auto; padding: 24px; }
.ms-admin-panel h3 { font-size: 17px; margin: 16px 0 10px; }
.ms-admin-panel .item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }

/* ============ 响应式 390px ============ */
@media (max-width: 540px) {
  .art-layout { grid-template-columns: 1fr; gap: 16px; }
  .reading-layout { grid-template-columns: 1fr; }
  .viewer { height: 260px; }
  .gallery-grid { grid-template-columns: 1fr; gap: 14px; }
  .student-gallery-shell { padding: 10px; }
  .ms-login, .ms-register, .ms-signedin { margin: 20px 12px; padding: 20px; }
  .home-section { padding: 0 14px; }
}
