/* ============================================================
   365Lab 课表 — Design System
   ============================================================ */
:root {
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef2ff;
  --primary-soft-2: #e0e7ff;
  --accent: #0ea5e9;
  --ink: #1e293b;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f5f6fa;
  --card: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-s: 0 1px 2px rgba(15, 23, 42, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --header-h: 60px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}
img, svg { vertical-align: middle; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::placeholder { color: var(--ink-3); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); font-size: 16px; white-space: nowrap; }
.brand .brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; letter-spacing: -.5px;
  box-shadow: 0 3px 8px -2px rgba(79, 70, 229, .5);
}
.brand small { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  color: var(--ink-2); padding: 7px 11px; border-radius: 8px;
  font-size: 13.5px; white-space: nowrap;
}
.site-nav a:hover { background: var(--primary-soft); color: var(--primary-strong); }
.site-nav a.active { background: var(--primary); color: #fff; font-weight: 600; }

.lang-switch { display: flex; align-items: center; gap: 6px; margin-left: 8px; flex-shrink: 0; }
.lang-switch select {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 8px;
  background: #fff; font-size: 13px; cursor: pointer; color: var(--ink-2);
}
.lang-switch svg { color: var(--ink-3); }

/* ---------- Layout ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 26px 20px 60px; }
.page-hero { margin-bottom: 22px; }
.page-hero .crumbs { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; }
.page-hero .crumbs a { color: var(--ink-3); }
.page-hero h1 { font-size: 25px; margin: 0 0 6px; letter-spacing: -.3px; display: flex; align-items: center; gap: 10px; }
.page-hero h1 .h1-ico {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff;
  box-shadow: 0 4px 10px -3px rgba(79, 70, 229, .5);
}
.page-hero p { margin: 0; color: var(--ink-2); font-size: 14.5px; max-width: 760px; }

.workbench { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 980px) { .workbench { grid-template-columns: 1fr; } }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-s); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 8px; padding: 13px 16px;
  border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px;
  color: var(--ink);
}
.panel-head .ico { color: var(--primary); display: inline-flex; }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 16px; }

/* editor panel stays visible while scrolling (desktop only) */
@media (min-width: 981px) {
  .editor-col { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100vh - var(--header-h) - 32px); overflow-y: auto; }
  .editor-col .panel { margin-bottom: 16px; }
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fafbff, #f4f6fc);
  border-radius: var(--radius) var(--radius) 0 0;
}
.toolbar .tb-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.toolbar .tb-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.draft-select {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 8px;
  font-size: 13px; background: #fff; max-width: 170px; cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  border-radius: 9px; padding: 7px 12px; font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-soft); }
.btn:active { transform: translateY(1px); }
.btn svg { flex-shrink: 0; }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 3px 8px -2px rgba(79, 70, 229, .45);
}
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--primary-soft); border-color: transparent; }
.btn-sm { padding: 5px 9px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 6px 8px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field > label, .field-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px; letter-spacing: .2px;
}
.field-label .hint { color: var(--ink-3); font-weight: 400; }
.ipt, .sel, .txa {
  width: 100%; border: 1px solid var(--line-2); border-radius: 9px;
  padding: 8px 11px; font-size: 14px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ipt:focus, .sel:focus, .txa:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.txa { resize: vertical; min-height: 64px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .row3 { grid-template-columns: 1fr 1fr; } }
fieldset.fieldset {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  margin: 0 0 14px; background: #fafbfe;
}
fieldset.fieldset legend { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 0 6px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button {
  border: 0; background: transparent; padding: 7px 13px; font-size: 13px;
  color: var(--ink-2); cursor: pointer; border-left: 1px solid var(--line);
}
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--primary); color: #fff; font-weight: 600; }

.color-dot {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; padding: 0;
}
.color-dot.on { box-shadow: 0 0 0 2px var(--primary); }

/* ---------- List editor rows (subjects / members / entries …) ---------- */
.list-rows { display: flex; flex-direction: column; gap: 8px; }
.list-row { display: flex; gap: 8px; align-items: center; }
.list-row .ipt { flex: 1; min-width: 0; }
.list-row .row-ops { display: flex; gap: 4px; flex-shrink: 0; }
.del-x {
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  width: 28px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
}
.del-x:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- Preview sheet (A4 paper) ---------- */
.sheet-wrap { display: flex; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 820px; min-height: 400px;
  padding: 34px 38px; border-radius: 4px;
  box-shadow: 0 0 0 1px var(--line), 0 10px 30px -12px rgba(15, 23, 42, .18);
}
.sheet h2.sheet-title { font-size: 21px; text-align: center; margin: 0 0 4px; letter-spacing: 1px; }
.sheet .sheet-sub { text-align: center; color: var(--ink-2); font-size: 12.5px; margin-bottom: 18px; }
.sheet .sheet-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; font-size: 12.5px; color: var(--ink-2); margin-bottom: 14px; }
.sheet-foot { margin-top: 22px; display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
table.tpl {
  border-collapse: collapse; width: 100%; font-size: 13.5px;
}
table.tpl th, table.tpl td {
  border: 1px solid var(--line-2); padding: 7px 9px; text-align: center; vertical-align: middle;
}
table.tpl thead th { background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; }
table.tpl tbody th { background: #f8fafc; font-weight: 600; color: var(--ink-2); }
table.tpl td.editable { cursor: pointer; min-width: 72px; }
table.tpl td.editable:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
table.tpl .cell-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.5;
}
table.tpl .cell-empty { color: var(--ink-3); font-weight: 400; }
table.tpl td.left, table.tpl th.left { text-align: left; }

/* status checkbox pill */
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.status-todo { background: var(--line); color: var(--ink-2); }
.status-doing { background: var(--warn-soft); color: var(--warn); }
.status-done { background: var(--ok-soft); color: var(--ok); }

/* ---------- Cards (mistake book) ---------- */
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .card-grid { grid-template-columns: 1fr; } }
.mb-card { border: 1px solid var(--line-2); border-radius: 11px; padding: 12px 14px; text-align: left; }
.mb-card .mb-top { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 7px; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.mb-card .mb-q { font-size: 13.5px; font-weight: 600; margin: 4px 0; white-space: pre-wrap; }
.mb-card .mb-sec { font-size: 12.5px; margin: 5px 0; }
.mb-card .mb-sec b { color: var(--ink-3); font-weight: 600; margin-right: 4px; }
.mb-card .mb-sec .content { white-space: pre-wrap; }
.review-flag { background: var(--warn-soft); color: var(--warn); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 12px; }
.cal-head .cal-month { font-size: 17px; font-weight: 700; min-width: 130px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--line-2); border-top: 1px solid var(--line-2); }
.cal-grid .cal-dow { background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; font-size: 12.5px; padding: 6px 4px; text-align: center; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.cal-cell { min-height: 86px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 4px 5px; font-size: 12px; cursor: pointer; position: relative; background: #fff; }
.cal-cell:hover { background: var(--primary-soft); }
.cal-cell.blank { background: #fafbfc; cursor: default; }
.cal-cell.today .cal-daynum { background: var(--primary); color: #fff; }
.cal-daynum { display: inline-flex; width: 22px; height: 22px; border-radius: 999px; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; }
.cal-item { margin-top: 3px; padding: 1px 6px; border-radius: 5px; font-size: 11px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-item.t-task { background: var(--primary-soft-2); color: var(--primary-strong); }
.cal-item.t-exam { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.cal-item.t-todo { background: var(--ok-soft); color: var(--ok); }
.cal-legend { display: flex; gap: 14px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Routine timeline ---------- */
.routine-wrap { max-width: 640px; margin: 0 auto; }
.routine-block { display: flex; gap: 0; margin-bottom: 6px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); }
.routine-time {
  flex: 0 0 92px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--ink-2); background: #f8fafc; padding: 8px 4px; text-align: center;
}
.routine-bar { flex: 1; display: flex; align-items: center; padding: 8px 14px; gap: 8px; }
.routine-bar .r-ico { display: inline-flex; opacity: .9; }
.routine-bar .r-label { font-weight: 600; font-size: 13.5px; }
.routine-bar .r-dur { margin-left: auto; font-size: 11.5px; opacity: .85; }
.routine-cat { font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 999px; }

/* ---------- Entry rows in editor (mistake book entries etc.) ---------- */
.entry-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.entry-item + .entry-item { margin-top: 8px; }
.entry-item .entry-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.entry-item .entry-idx { font-size: 11px; font-weight: 700; color: var(--ink-3); }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: 0 24px 60px -12px rgba(15, 23, 42, .35);
  width: 100%; max-width: 460px; max-height: 86vh; overflow-y: auto; padding: 20px;
}
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal .modal-ops { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Toast ---------- */
.toast-box { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; box-shadow: 0 8px 24px -6px rgba(15, 23, 42, .4);
  animation: toast-in .25s ease;
}
.toast.toast-ok { background: var(--ok); }
.toast.toast-err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; color: var(--ink-3); padding: 34px 10px; font-size: 13.5px; }
.empty-state svg { display: block; margin: 0 auto 8px; opacity: .6; }

/* ---------- Home page ---------- */
.home-hero { text-align: center; padding: 52px 16px 40px; }
.home-hero h1 { font-size: 34px; letter-spacing: -.5px; margin: 0 0 12px; line-height: 1.3; }
.home-hero h1 .grad { background: linear-gradient(90deg, #4f46e5, #0ea5e9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-hero p.lead { color: var(--ink-2); max-width: 620px; margin: 0 auto 24px; font-size: 16px; }
.home-hero .hero-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.home-hero .btn { padding: 10px 20px; font-size: 14.5px; border-radius: 11px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 7px; background: var(--primary-soft); color: var(--primary-strong);
  font-size: 12.5px; font-weight: 600; padding: 5px 14px; border-radius: 999px; margin-bottom: 18px;
}
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 18px; }
.tool-card {
  display: flex; flex-direction: column; gap: 10px; padding: 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-s); transition: box-shadow .18s, transform .18s, border-color .18s; color: inherit;
}
.tool-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); border-color: var(--primary-soft-2); }
.tool-card .tc-ico {
  width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
}
.tool-card h3 { margin: 0; font-size: 16.5px; }
.tool-card p { margin: 0; color: var(--ink-2); font-size: 13.5px; flex: 1; }
.tool-card .tc-go { color: var(--primary); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.section-title { text-align: center; font-size: 23px; margin: 44px 0 8px; letter-spacing: -.3px; }
.section-sub { text-align: center; color: var(--ink-2); font-size: 14px; margin: 0 0 6px; }
.feat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.feat { display: flex; gap: 10px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.feat svg { color: var(--ok); flex-shrink: 0; margin-top: 2px; }
.feat b { display: block; font-size: 14px; }
.feat span { font-size: 12.5px; color: var(--ink-2); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: #fff; margin-top: 40px; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 22px 20px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; color: var(--ink-3); font-size: 12.5px; }
.footer-inner .f-nav { display: flex; gap: 14px; flex-wrap: wrap; }
.footer-inner a { color: var(--ink-3); }
.footer-inner a:hover { color: var(--primary); }

/* ---------- Print ---------- */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; font-size: 12.5px; }
  .site-header, .site-footer, .editor-col, .toolbar, .no-print, .toast-box, .modal-mask { display: none !important; }
  .page { padding: 0; max-width: none; }
  .workbench { display: block; }
  .preview-col { padding: 0 !important; }
  .panel { border: 0 !important; box-shadow: none !important; }
  .panel-head { display: none !important; }
  .panel-body { padding: 0 !important; }
  .sheet {
    box-shadow: none !important; max-width: none !important; width: 100% !important;
    padding: 0 !important; border-radius: 0 !important; min-height: auto !important;
  }
  .sheet-wrap { display: block; }
  .tbl-wrap { overflow: visible !important; }
  table.tpl { font-size: 11px; }
  table.tpl th, table.tpl td { padding: 4px 6px; }
  .cal-cell { min-height: 64px; }
  .mb-card, .entry-item, tr, .routine-block, table.tpl { page-break-inside: avoid; }
  .card-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .sheet-foot { margin-top: 12mm; }
}
