:root {
  color: #30352f;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --background: #faf9f5;
  --foreground: #30352f;
  --card: #fff;
  --primary: #386c56;
  --primary-deep: #28513f;
  --primary-soft: #e3f0e9;
  --accent: #c96442;
  --accent-soft: #f6ded6;
  --yellow: #d6a33d;
  --yellow-soft: #fff2cc;
  --blue: #4e7fa3;
  --blue-soft: #e6f0f7;
  --purple: #80639a;
  --purple-soft: #eee7f4;
  --danger: #cc4e45;
  --muted: #7d817b;
  --secondary: #ece9df;
  --border: #dcd9cf;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; letter-spacing: 0; }
html, body, #app { min-width: 320px; min-height: 100%; margin: 0; }
body { background: var(--background); overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgb(56 108 86 / 24%); outline-offset: 3px; }

.app-shell { height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.app-header { z-index: 20; flex: 0 0 76px; display: grid; grid-template-columns: 170px minmax(0, 1fr) 76px; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--border); background: rgb(250 249 245 / 96%); box-shadow: 0 8px 24px rgb(40 42 36 / 4%); }
.module-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.home-link { width: 36px; height: 36px; display: grid; place-items: center; flex: none; border-radius: 6px; color: var(--foreground); font-size: 25px; text-decoration: none; }
.brand-copy { min-width: 0; display: flex; flex-direction: column; }
.brand-copy small { color: var(--primary); font-size: 9px; font-weight: 900; }
.brand-copy strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.demo-tabs { min-width: 0; display: flex; justify-content: safe center; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.demo-tabs::-webkit-scrollbar { display: none; }
.demo-tabs button { min-width: 155px; height: 48px; padding: 0 13px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 900; cursor: pointer; }
.demo-tabs button:hover { color: var(--foreground); background: var(--secondary); }
.demo-tabs button.active { color: #fff; background: var(--primary); box-shadow: 0 8px 18px rgb(56 108 86 / 20%); }
.nav-number { font-family: ui-monospace, monospace; font-size: 9px; opacity: .78; }
.lab-status { display: flex; justify-content: flex-end; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 900; }
.lab-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

.feature-page { flex: 1; min-height: 0; padding: 13px 20px 18px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.feature-heading { min-height: 72px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.heading-copy { min-width: 0; }
.eyebrow { color: var(--primary); font-size: 9px; font-weight: 950; text-transform: uppercase; }
.feature-heading h1 { margin: 3px 0 4px; font-family: Georgia, "Times New Roman", serif; font-size: 27px; line-height: 1; }
.feature-heading p { max-width: 720px; margin: 0; color: var(--muted); font-size: 10px; font-weight: 750; line-height: 1.45; }
.feature-actions { display: flex; align-items: center; gap: 6px; }
.tool-button { width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 18px; font-weight: 900; cursor: pointer; }
.status-chip { min-height: 29px; padding: 6px 9px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; color: var(--primary-deep); background: var(--primary-soft); font-size: 9px; font-weight: 900; }
.status-chip.orange { color: #91401f; background: var(--accent-soft); }
.status-chip.blue { color: #345f7e; background: var(--blue-soft); }
.status-chip.yellow { color: #725616; background: var(--yellow-soft); }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 8px 24px rgb(40 42 36 / 4%); }
.guided-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 10px; }
.guided-layout.complete { grid-template-columns: minmax(0, 1fr); }
.workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.action-button, .text-button { min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 10px; font-weight: 900; cursor: pointer; }
.action-button.primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.action-button.accent { color: #fff; border-color: var(--accent); background: var(--accent); }
.action-button:disabled { cursor: not-allowed; filter: grayscale(.7); opacity: .45; }
.text-button { width: 100%; margin-top: 9px; color: var(--primary); background: var(--primary-soft); }
.empty-state { padding: 18px; display: grid; place-items: center; color: var(--muted); text-align: center; font-size: 11px; font-weight: 750; }

.factory-layout { flex: 1; min-height: 500px; display: grid; grid-template-columns: 205px minmax(430px, 1fr) minmax(310px, .82fr); gap: 10px; }
.factory-types { padding: 14px; display: flex; flex-direction: column; gap: 7px; }
.section-label { color: var(--muted); font-size: 8px; font-weight: 950; text-transform: uppercase; }
.factory-type { padding: 12px; border: 1px solid var(--border); border-left: 4px solid var(--type); border-radius: 6px; background: #fff; text-align: left; cursor: pointer; }
.factory-type.active { background: #f7faf8; box-shadow: inset 0 0 0 1px var(--primary); }
.factory-type b { display: block; margin-bottom: 4px; font-size: 12px; }
.factory-type span { color: var(--muted); font-size: 9px; font-weight: 750; line-height: 1.35; }
.factory-mini { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.factory-mini strong { display: block; font-family: Georgia, serif; font-size: 18px; }
.factory-mini p { margin: 4px 0 0; color: var(--muted); font-size: 9px; font-weight: 750; line-height: 1.45; }
.essay-stage { min-height: 0; padding: 15px; display: flex; flex-direction: column; }
.essay-stage header { padding-bottom: 11px; border-bottom: 1px solid var(--border); }
.essay-stage header span { color: var(--primary); font-size: 8px; font-weight: 950; }
.essay-stage h2 { margin: 4px 0; font-family: Georgia, serif; font-size: 21px; }
.essay-stage header p { margin: 0; color: var(--muted); font-size: 10px; font-weight: 750; }
.essay-scroll { min-height: 0; padding: 10px 2px 2px; display: grid; gap: 10px; overflow: auto; }
.essay-part { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 9px; align-items: start; }
.essay-part > b { padding-top: 10px; color: var(--muted); font-size: 9px; }
.slot-list { display: grid; gap: 6px; }
.sentence-slot { min-height: 58px; padding: 8px 10px; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 9px; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 6px; background: #fcfbf8; text-align: left; cursor: pointer; }
.sentence-slot:hover, .sentence-slot.active { border-color: var(--primary); background: var(--primary-soft); }
.sentence-slot > b { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-family: ui-monospace, monospace; font-size: 9px; }
.sentence-slot strong { display: block; font-size: 10px; }
.sentence-slot p { margin: 3px 0 0; color: var(--muted); font-family: Georgia, serif; font-size: 11px; line-height: 1.35; }
.sentence-slot small { max-width: 82px; color: var(--muted); font-size: 8px; font-weight: 800; text-align: right; }
.factory-library { min-height: 0; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
.library-head { display: flex; justify-content: space-between; gap: 8px; }
.library-head h2 { margin: 3px 0 0; font-size: 17px; }
.library-head span { color: var(--muted); font-size: 8px; font-weight: 900; }
.library-list { min-height: 0; display: grid; gap: 6px; overflow: auto; }
.library-item { padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; text-align: left; cursor: pointer; }
.library-item:hover, .library-item.selected { border-color: var(--blue); background: var(--blue-soft); }
.library-item p { margin: 0 0 5px; font-family: Georgia, serif; font-size: 11px; line-height: 1.4; }
.library-item span { color: var(--muted); font-size: 8px; font-weight: 750; }
.library-item .tags { margin-top: 6px; display: flex; gap: 4px; }
.library-item i { padding: 3px 5px; border-radius: 3px; background: var(--secondary); font-size: 7px; font-style: normal; font-weight: 900; }
.add-sentence { padding-top: 8px; border-top: 1px solid var(--border); }
.add-sentence textarea { width: 100%; min-height: 62px; padding: 9px; border: 1px solid var(--border); border-radius: 6px; resize: vertical; font-size: 10px; line-height: 1.45; }
.add-sentence footer { margin-top: 5px; display: flex; justify-content: space-between; align-items: center; gap: 7px; }
.add-sentence small { color: var(--muted); font-size: 8px; font-weight: 750; }
.ai-panel { padding: 11px; border-top: 4px solid var(--accent); background: #fffaf7; }
.ai-panel header { display: flex; justify-content: space-between; align-items: center; gap: 7px; }
.ai-panel h3 { margin: 0; font-size: 12px; }
.ai-panel p { margin: 7px 0; color: var(--muted); font-size: 9px; font-weight: 750; line-height: 1.5; }
.ai-suggestion { padding: 8px; border-left: 3px solid var(--accent); background: #fff; font-family: Georgia, serif; font-size: 10px; line-height: 1.4; }
.ai-actions { margin-top: 7px; display: flex; gap: 6px; }

.root-lobby { flex: 1; min-height: 490px; padding: 24px; display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: center; }
.lobby-copy h2 { margin: 6px 0; font-family: Georgia, serif; font-size: 26px; }
.lobby-copy p { margin: 0; color: var(--muted); font-size: 11px; font-weight: 750; line-height: 1.65; }
.room-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.room-card { min-height: 220px; padding: 16px; display: flex; flex-direction: column; border: 2px solid var(--border); border-bottom: 6px solid var(--room); border-radius: 8px; background: #fff; text-align: left; cursor: pointer; }
.room-card.selected { border-color: var(--room); box-shadow: 0 0 0 3px color-mix(in srgb, var(--room), transparent 78%); }
.room-card small { color: var(--room); font-size: 9px; font-weight: 950; }
.room-card h3 { margin: 8px 0; font-size: 20px; }
.room-card p { color: var(--muted); font-size: 10px; font-weight: 750; line-height: 1.5; }
.room-card code { margin-top: auto; padding: 8px; background: var(--secondary); font-family: ui-monospace, monospace; font-size: 10px; }
.root-game { flex: 1; min-height: 500px; display: grid; grid-template-columns: minmax(360px, .92fr) minmax(360px, 1.08fr); gap: 10px; }
.root-arena { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.root-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.root-player { padding: 9px; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 7px; border-top: 3px solid var(--blue); background: #f7fafc; }
.root-player.opponent { border-color: var(--accent); background: #fff8f5; }
.root-player i { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--blue); font-style: normal; font-weight: 950; }
.root-player.opponent i { background: var(--accent); }
.root-player span { display: block; color: var(--muted); font-size: 8px; font-weight: 800; }
.root-player b { font-size: 12px; }
.root-player strong { font-family: ui-monospace, monospace; font-size: 19px; }
.turn-clock { text-align: center; }
.turn-clock small { display: block; color: var(--muted); font-size: 7px; font-weight: 900; }
.turn-clock b { font-family: ui-monospace, monospace; font-size: 18px; }
.root-focus { flex: 1; min-height: 240px; display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; border: 1px solid var(--border); background: #faf9f5; }
.root-focus small { color: var(--muted); font-size: 8px; font-weight: 900; }
.root-focus strong { font-family: Georgia, serif; font-size: clamp(38px, 7vw, 76px); line-height: .9; }
.root-focus p { max-width: 330px; margin: 0; color: var(--muted); font-size: 10px; font-weight: 750; }
.root-answer { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
.root-answer input { min-width: 0; height: 44px; padding: 0 12px; border: 2px solid var(--border); border-radius: 6px; background: #fff; font-size: 16px; font-weight: 900; }
.mic-button { width: 44px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 17px; cursor: pointer; }
.root-message { min-height: 24px; color: var(--muted); font-size: 9px; font-weight: 800; text-align: center; }
.root-side { min-height: 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.tool-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tool-card { min-height: 80px; padding: 9px; border: 1px solid var(--border); border-top: 4px solid var(--tool); border-radius: 6px; background: #fff; text-align: left; cursor: pointer; }
.tool-card:disabled { cursor: not-allowed; opacity: .42; }
.tool-card b { display: block; font-size: 10px; }
.tool-card span { display: block; margin-top: 5px; color: var(--muted); font-size: 8px; font-weight: 750; line-height: 1.35; }
.hint-reveal { min-height: 40px; padding: 8px; border-left: 3px solid var(--yellow); background: var(--yellow-soft); font-size: 9px; font-weight: 800; line-height: 1.45; }
.unlocks { padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.unlock-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.unlock-head h3 { margin: 0; font-size: 12px; }
.word-chips { min-height: 40px; margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.word-chip { padding: 6px 8px; border-radius: 5px; color: #345f7e; background: var(--blue-soft); font-size: 9px; font-weight: 900; }
.root-card-preview { padding: 11px; border: 1px solid var(--border); border-top: 4px solid var(--primary); background: #f8fbf9; }
.root-card-preview.locked { filter: grayscale(1); opacity: .68; }
.root-card-preview h3 { margin: 4px 0; font-family: Georgia, serif; font-size: 19px; }
.root-card-preview p { margin: 0; color: var(--muted); font-size: 9px; font-weight: 750; line-height: 1.5; }
.turn-log { min-height: 0; display: grid; align-content: start; gap: 5px; overflow: auto; }
.log-item { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; gap: 7px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 9px; }
.log-item span { color: var(--muted); font-weight: 800; }
.log-item b { font-family: ui-monospace, monospace; }
.log-item i { color: var(--primary); font-style: normal; font-weight: 900; }
.result-layout { flex: 1; min-height: 470px; padding: 24px; display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 22px; align-items: center; }
.result-hero { text-align: center; }
.result-hero strong { display: block; font-family: Georgia, serif; font-size: 42px; }
.result-hero p { color: var(--muted); font-size: 10px; font-weight: 750; }
.result-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.result-stat { padding: 13px; border-top: 4px solid var(--primary); background: #f7faf8; }
.result-stat span { display: block; color: var(--muted); font-size: 8px; font-weight: 900; }
.result-stat b { display: block; margin: 4px 0; font-size: 16px; }
.result-stat p { margin: 0; color: var(--muted); font-size: 9px; font-weight: 750; line-height: 1.45; }
.result-actions { margin-top: 10px; display: flex; gap: 7px; }

.review-panel { padding: 18px; }
.review-panel header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.review-panel h2 { margin: 0; font-size: 19px; }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.review-item { padding: 12px 0; border-top: 3px solid var(--primary); }
.review-item span { color: var(--muted); font-size: 8px; font-weight: 900; }
.review-item strong { display: block; margin: 4px 0; font-size: 14px; }
.review-item p { margin: 0; color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1.5; }

.guide-sidebar { z-index: 60; min-width: 0; padding: 17px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 10px 26px rgb(40 42 36 / 9%); position: relative; }
.guide-head { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; font-weight: 900; }
.guide-head b { margin-left: auto; color: var(--primary); }
.guide-head button { min-height: 29px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--muted); font-size: 9px; font-weight: 850; cursor: pointer; }
.guide-current { margin-top: 15px; padding: 15px 0; border-top: 4px solid var(--primary); border-bottom: 1px solid var(--border); }
.guide-current span { color: var(--primary); font-size: 9px; font-weight: 900; }
.guide-current h2 { margin: 6px 0 10px; font-size: 21px; line-height: 1.2; }
.guide-current p { margin: 0; color: var(--muted); font-size: 11px; font-weight: 750; line-height: 1.55; }
.guide-steps { margin-top: auto; display: grid; gap: 6px; }
.guide-step { min-height: 36px; padding: 4px 6px; display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 7px; border-radius: 6px; color: #aaa89f; }
.guide-step b { width: 23px; height: 23px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 50%; font-size: 8px; }
.guide-step span { font-size: 10px; font-weight: 800; }
.guide-step.active { color: var(--primary-deep); background: var(--primary-soft); }
.guide-step.active b { color: #fff; border-color: var(--primary); background: var(--primary); }
.guide-step.done { color: var(--primary); }
.guide-followup { margin: 9px 0 0; padding-top: 9px; border-top: 1px solid var(--border); color: var(--muted); font-size: 8px; font-weight: 800; line-height: 1.4; }
.guide-overlay { z-index: 45; pointer-events: none; position: fixed; inset: 0; }
.guide-shade { position: fixed; background: rgb(34 36 31 / 57%); transition: all .2s; }
.guide-frame { position: fixed; border: 3px solid var(--primary); border-radius: 10px; box-shadow: 0 0 0 4px rgb(56 108 86 / 18%); transition: all .2s; }
.toast { z-index: 100; position: fixed; left: 50%; bottom: 24px; max-width: min(520px, calc(100vw - 32px)); transform: translateX(-50%); padding: 11px 15px; border-radius: 7px; color: #fff; background: #30352f; box-shadow: 0 10px 26px rgb(35 37 32 / 22%); font-size: 10px; font-weight: 800; text-align: center; }

@media (max-width: 1180px) {
  .factory-layout { grid-template-columns: 180px minmax(390px, 1fr) 300px; }
  .root-game { grid-template-columns: minmax(340px, .9fr) minmax(330px, 1.1fr); }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { min-height: 100dvh; height: auto; overflow: visible; }
  .app-header { min-height: 70px; grid-template-columns: 145px minmax(0, 1fr); padding: 8px 12px; }
  .lab-status { display: none; }
  .demo-tabs { justify-content: flex-start; }
  .feature-page { min-height: calc(100dvh - 70px); overflow: visible; }
  .guided-layout { display: block; }
  .guide-sidebar { position: fixed; right: 10px; bottom: 10px; left: 10px; max-height: 40vh; overflow: auto; }
  .guide-current { padding: 9px 0; }
  .guide-current h2 { margin: 4px 0 5px; font-size: 17px; }
  .guide-steps { display: none; }
  .factory-layout { min-height: 0; grid-template-columns: 170px minmax(0, 1fr); }
  .factory-library { grid-column: 1 / -1; min-height: 380px; }
  .root-lobby { min-height: 0; grid-template-columns: 1fr; }
  .root-game { min-height: 0; grid-template-columns: 1fr; }
  .root-side { min-height: 550px; }
  .result-layout { min-height: 0; }
}
@media (max-width: 580px) {
  .app-header { grid-template-columns: 102px minmax(0, 1fr); }
  .brand-copy small { display: none; }
  .demo-tabs { gap: 2px; }
  .demo-tabs button { min-width: 112px; height: 42px; padding: 0 6px; font-size: 10px; }
  .feature-page { padding: 11px; }
  .feature-heading h1 { font-size: 21px; }
  .feature-heading p { max-width: 245px; }
  .factory-layout { display: block; }
  .factory-types { margin-bottom: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .factory-type { min-height: 82px; padding: 8px; }
  .factory-type span { display: none; }
  .factory-mini { display: none; }
  .essay-stage { min-height: 650px; margin-bottom: 10px; }
  .essay-part { grid-template-columns: 1fr; }
  .essay-part > b { padding: 0; }
  .sentence-slot { grid-template-columns: 26px minmax(0, 1fr); }
  .sentence-slot small { display: none; }
  .factory-library { min-height: 600px; }
  .root-lobby, .result-layout { padding: 15px; grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: 1fr; }
  .room-card { min-height: 130px; }
  .root-score { gap: 4px; }
  .root-player { grid-template-columns: 29px minmax(0, 1fr); padding: 6px; }
  .root-player > strong { display: none; }
  .root-player i { width: 28px; height: 28px; }
  .root-arena, .root-side { padding: 12px; }
  .root-answer { grid-template-columns: minmax(0, 1fr) 42px; }
  .root-answer .action-button { grid-column: 1 / -1; }
  .tool-cards { grid-template-columns: 1fr 1fr 1fr; }
  .tool-card { padding: 6px; }
  .result-stats, .review-grid { grid-template-columns: 1fr; }
  .result-actions { display: grid; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
