.sm-root {
  --sm-bg: #f2ece1;
  --sm-card: #fbf8f1;
  --sm-paper: #fffdf8;
  --sm-ink: #33291f;
  --sm-muted: #8d8172;
  --sm-line: #e6ddcd;
  --sm-accent: #b06f24;
  --sm-accent-deep: #8a5518;
  --sm-accent-soft: #f3e3cb;
  color: var(--sm-ink);
  font: 14px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.sm-root *, .sm-root *::before, .sm-root *::after { box-sizing: border-box; }
.sm-root button { font: inherit; }
.sm-root button:focus-visible { outline: 3px solid rgba(176,111,36,.26); outline-offset: 2px; }

.sm-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--sm-line);
  border-radius: 14px;
  background: rgba(251,248,241,.96);
  box-shadow: 0 6px 18px rgba(66,48,28,.05);
}

@supports ((backdrop-filter: blur(14px)) or (-webkit-backdrop-filter: blur(14px))) {
  .sm-toolbar {
    position: sticky;
    top: 10px;
    z-index: 18;
    background: rgba(251,248,241,.84);
    -webkit-backdrop-filter: blur(16px) saturate(1.12);
    backdrop-filter: blur(16px) saturate(1.12);
    box-shadow: 0 10px 30px rgba(66,48,28,.09), inset 0 1px rgba(255,255,255,.72);
  }
}

.sm-filter { display: flex; align-items: center; gap: 9px; }
.sm-filter > span { color: var(--sm-muted); font-size: 12px; font-weight: 700; }
.sm-period { margin-left: auto; }
.sm-segment { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--sm-line); border-radius: 11px; background: #f6f0e4; }
.sm-segment button {
  min-height: 34px;
  padding: 5px 12px;
  border: 0;
  border-radius: 8px;
  color: #675b4e;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}
.sm-segment button:hover { color: var(--sm-accent-deep); background: rgba(255,255,255,.7); }
.sm-segment button.active { color: #fff; background: var(--sm-accent); box-shadow: 0 4px 11px rgba(138,85,24,.2); }

.sm-sync {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--sm-line);
  color: var(--sm-muted);
  font-size: 11.5px;
}
.sm-sync i { width: 8px; height: 8px; border-radius: 50%; background: #7ca66c; box-shadow: 0 0 0 5px rgba(124,166,108,.13); }
.sm-sync i.error { background: #c9654f; box-shadow: 0 0 0 5px rgba(201,101,79,.12); }
.sm-sync strong { color: #5d5145; }
.sm-sync span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-sync button {
  margin-left: auto;
  padding: 5px 11px;
  border: 1px solid var(--sm-line);
  border-radius: 8px;
  color: var(--sm-accent-deep);
  background: #fffdf8;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.sm-subnav { display: flex; align-items: stretch; gap: 8px; margin: 0 0 14px; }
.sm-subnav button {
  padding: 8px 16px;
  border: 1px solid var(--sm-line);
  border-radius: 18px;
  color: #625648;
  background: var(--sm-card);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.sm-subnav button:hover { border-color: #c79b64; }
.sm-subnav button.active { border-color: #2b231c; color: #fff; background: #2b231c; }
.sm-subnav .sm-ai-search {
  display: flex;
  min-width: 218px;
  margin-left: auto;
  padding: 7px 14px;
  border-color: rgba(176,111,36,.32);
  border-radius: 13px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  color: var(--sm-accent-deep);
  background: linear-gradient(135deg, rgba(255,253,248,.96), rgba(243,227,203,.72));
  box-shadow: 0 6px 18px rgba(95,61,25,.07), inset 0 1px rgba(255,255,255,.8);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.sm-subnav .sm-ai-search[hidden] { display: none; }
.sm-subnav .sm-ai-search:hover { transform: translateY(-1px); border-color: var(--sm-accent); box-shadow: 0 9px 22px rgba(95,61,25,.1), inset 0 1px rgba(255,255,255,.86); }
.sm-subnav .sm-ai-search:active { transform: scale(.98); }
.sm-ai-search span { font-size: 12.5px; font-weight: 800; line-height: 1.35; }
.sm-ai-search small { margin-top: 1px; color: var(--sm-muted); font-size: 9.5px; font-weight: 600; line-height: 1.35; }

.sm-block, .sm-course-studio, .sm-ops-studio {
  margin-bottom: 16px;
  border: 1px solid var(--sm-line);
  border-radius: 15px;
  background: var(--sm-card);
  box-shadow: 0 7px 22px rgba(62,43,24,.045);
}
.sm-block { padding: 18px; }
.sm-section-head, .sm-poster-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}
.sm-section-head small, .sm-poster-head small, .sm-queue header small {
  display: block;
  margin-bottom: 3px;
  color: var(--sm-accent-deep);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
}
.sm-section-head h2, .sm-poster-head h3, .sm-queue h3 { margin: 0; color: var(--sm-ink); font-family: "Songti SC", "STSong", serif; }
.sm-section-head h2 { font-size: 22px; }
.sm-section-head p, .sm-poster-head p { margin: 4px 0 0; color: var(--sm-muted); font-size: 11.5px; }
.sm-feedback { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.sm-schedule-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sm-material-card { overflow: hidden; border: 1px solid var(--sm-line); border-radius: 13px; background: var(--sm-paper); }
.sm-material-card > header { padding: 10px 12px 9px; border-bottom: 1px solid var(--sm-line); }
.sm-material-card > header strong { display: block; color: var(--sm-accent-deep); font-size: 13px; }
.sm-material-card > header span { display: block; color: var(--sm-muted); font-size: 10.5px; }
.sm-material-preview { display: grid; place-items: center; min-height: 225px; max-height: 390px; overflow: auto; background: #eee6d8; }
.sm-material-preview img { display: block; width: 100%; height: auto; }
.sm-placeholder { display: grid; place-items: center; width: 100%; min-height: 225px; padding: 24px; color: var(--sm-muted); text-align: center; }
.sm-material-card > footer { display: flex; gap: 7px; padding: 10px; border-top: 1px solid var(--sm-line); }
.sm-root button.primary, .sm-material-card > footer button, .sm-actions button, .sm-card-progress button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #d8c9b5;
  border-radius: 8px;
  color: #645546;
  background: #fffdf9;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.sm-root button.primary { border-color: var(--sm-accent); color: #fff; background: var(--sm-accent); }
.sm-root button:disabled { cursor: not-allowed; opacity: .4; }
.sm-material-card > footer button { flex: 1; }

.sm-course-studio, .sm-ops-studio { display: grid; grid-template-columns: minmax(235px, 290px) minmax(0, 1fr); overflow: hidden; }
.sm-queue { min-width: 0; padding: 16px; border-right: 1px solid var(--sm-line); background: #f6f0e5; }
.sm-queue > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sm-queue h3 { font-size: 18px; line-height: 1.35; }
.sm-queue header em { padding: 3px 8px; border-radius: 10px; color: var(--sm-accent-deep); background: var(--sm-accent-soft); font-size: 10.5px; font-style: normal; font-weight: 700; white-space: nowrap; }
.sm-course-list, .sm-ops-list { display: grid; gap: 8px; max-height: 740px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #d5c5af transparent; }
.sm-course, .sm-ops-item {
  width: 100%;
  padding: 11px;
  border: 1px solid var(--sm-line);
  border-radius: 10px;
  color: var(--sm-ink);
  background: var(--sm-paper);
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.sm-course:hover, .sm-ops-item:hover { transform: translateY(-1px); border-color: #c99f6b; }
.sm-course.active, .sm-ops-item.active { border-color: var(--sm-accent); background: #fff6e9; box-shadow: inset 3px 0 var(--sm-accent); }
.sm-course > span, .sm-ops-item > span { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 5px; }
.sm-course b, .sm-ops-item b { color: var(--sm-accent-deep); font-size: 10.5px; }
.sm-course i, .sm-ops-item i { padding: 2px 6px; border-radius: 8px; color: #62804c; background: #e8efdd; font-size: 9px; font-style: normal; }
.sm-course i.missing { color: #a25c35; background: #f7e3d8; }
.sm-course > strong, .sm-ops-item > strong { display: block; font-size: 12.5px; line-height: 1.55; }
.sm-course > small, .sm-ops-item > small { display: block; margin-top: 5px; color: var(--sm-muted); font-size: 10px; line-height: 1.5; }

.sm-poster-workbench { min-width: 0; padding: 18px; }
.sm-poster-head h3 { font-size: 20px; }
.sm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.sm-poster-stage {
  display: grid;
  place-items: center;
  padding: 13px;
  border: 1px solid var(--sm-line);
  border-radius: 13px;
  background-color: #eee6d9;
  background-image: linear-gradient(45deg, rgba(255,255,255,.38) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.38) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.38) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.38) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}
.sm-poster-stage canvas { display: block; width: min(100%, 455px); height: auto; border-radius: 9px; background: #fff; box-shadow: 0 14px 32px rgba(52,35,18,.16); }
.sm-reasons { display: grid; gap: 8px; margin-top: 12px; }
.sm-reasons article { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; align-items: flex-start; padding: 10px 11px; border: 1px solid var(--sm-line); border-radius: 10px; background: #fffdf8; }
.sm-reasons i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; background: var(--sm-accent); font-size: 11px; font-style: normal; font-weight: 900; }
.sm-reasons strong, .sm-reasons span { display: block; }
.sm-reasons strong { color: var(--sm-accent-deep); font-size: 12px; }
.sm-reasons span { color: #62584d; font-size: 11.5px; line-height: 1.7; }
.sm-empty { display: grid; place-items: center; min-height: 150px; padding: 24px; color: var(--sm-muted); text-align: center; }
.sm-empty strong, .sm-empty span { display: block; }
.sm-empty strong { color: #64584b; font-size: 13px; }
.sm-empty span { margin-top: 4px; font-size: 11px; }

.sm-scope-note { margin: 0 0 12px; padding: 9px 10px; border-radius: 9px; color: #79644f; background: #efe3d1; font-size: 10.5px; line-height: 1.65; }
.sm-card-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 11px; }
.sm-card-tabs button { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--sm-line); border-radius: 10px; color: #675b4e; background: #fffdf8; text-align: left; cursor: pointer; }
.sm-card-tabs button.active { border-color: var(--sm-accent); color: var(--sm-accent-deep); background: #fff3e2; box-shadow: inset 0 -2px var(--sm-accent); }
.sm-card-tabs i { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; color: var(--sm-accent-deep); background: var(--sm-accent-soft); font-size: 10px; font-style: normal; font-weight: 900; }
.sm-card-tabs span { font-size: 11px; font-weight: 700; }
.sm-card-progress { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--sm-muted); font-size: 10.5px; }
.sm-card-progress > div { display: flex; gap: 6px; }
.sm-card-progress button { min-height: 30px; padding: 4px 10px; }
.sm-progress { height: 4px; overflow: hidden; margin-bottom: 12px; border-radius: 99px; background: #e7d9c5; }
.sm-progress i { display: block; width: 33.333%; height: 100%; border-radius: inherit; background: var(--sm-accent); transition: transform .2s ease; }
.sm-copy-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 9px; margin-top: 12px; }
.sm-copy-grid article { padding: 11px 12px; border: 1px solid var(--sm-line); border-radius: 10px; background: #fffdf8; }
.sm-copy-grid article > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sm-copy-grid article > header .sm-feedback { margin-top: 0; justify-content: flex-end; }
.sm-copy-grid strong { display: block; color: var(--sm-accent-deep); font-size: 11px; }
.sm-copy-grid p { margin: 5px 0 0; color: #655a4e; font-size: 11px; line-height: 1.75; white-space: pre-wrap; }

.sm-toast { position: fixed; left: 50%; bottom: 24px; z-index: 120; transform: translateX(-50%); padding: 9px 18px; border-radius: 22px; color: #fff; background: #2b231c; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 12px; }
.sm-flash { animation: sm-flash 1.2s ease-out; }
@keyframes sm-flash { 0%, 35% { box-shadow: 0 0 0 4px rgba(176,111,36,.25), 0 8px 24px rgba(62,43,24,.08); } 100% { box-shadow: 0 0 0 0 rgba(176,111,36,0); } }

@media (max-width: 1120px) {
  .sm-period { margin-left: 0; }
  .sm-schedule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-course-studio, .sm-ops-studio { grid-template-columns: 250px minmax(0, 1fr); }
}

@media (max-width: 850px) {
  .sm-course-studio, .sm-ops-studio { grid-template-columns: 1fr; }
  .sm-queue { border-right: 0; border-bottom: 1px solid var(--sm-line); }
  .sm-course-list, .sm-ops-list { max-height: 350px; }
  .sm-poster-head { flex-direction: column; }
  .sm-actions { justify-content: flex-start; }
  .sm-copy-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .sm-toolbar { padding: 12px; gap: 10px; }
  .sm-filter { width: 100%; align-items: flex-start; flex-direction: column; gap: 5px; }
  .sm-filter .sm-segment { width: 100%; }
  .sm-filter .sm-segment button { flex: 1; padding-inline: 6px; }
  .sm-period { width: 100%; }
  .sm-sync { align-items: flex-start; flex-wrap: wrap; }
  .sm-sync span { width: calc(100% - 20px); margin-left: 16px; white-space: normal; }
  .sm-sync button { margin-left: 16px; }
  .sm-subnav { display: grid; grid-template-columns: 1fr 1fr; }
  .sm-subnav .sm-ai-search { grid-column: 1 / -1; width: 100%; min-width: 0; margin-left: 0; }
  .sm-schedule-grid { grid-template-columns: 1fr; }
  .sm-block { padding: 13px; }
  .sm-poster-workbench, .sm-queue { padding: 13px; }
  .sm-material-preview { max-height: 520px; }
  .sm-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .sm-actions button:first-child { grid-column: 1 / -1; }
  .sm-card-tabs { grid-template-columns: 1fr; }
  .sm-card-progress { align-items: flex-start; flex-direction: column; }
  .sm-card-progress > div, .sm-card-progress button { width: 100%; }
  .sm-poster-stage { padding: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .sm-root *, .sm-root *::before, .sm-root *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
