:root {
  --ce-ink: #22304a;
  --ce-muted: #5f6d82;
  --ce-cream: #fffaf0;
  --ce-paper: #fffef9;
  --ce-pink: #f3bfd1;
  --ce-mint: #bce2ca;
  --ce-blue: #b9daed;
  --ce-yellow: #f3dfa2;
  --ce-lavender: #d9c8eb;
  --ce-peach: #f2c7a9;
  --ce-always: #487c67;
  --ce-sometimes: #8a672c;
  --ce-never: #934d59;
  --ce-success: #397657;
  --ce-warning: #8b6328;
  --ce-error: #974949;
  --ce-focus: #245e9c;
  --ce-radius: 18px;
  --ce-outline: 3px;
  --shadow: 0 12px 32px rgba(54, 60, 80, .13);
  --shadow-small: 0 5px 13px rgba(54, 60, 80, .12);
  font-family: "Trebuchet MS", "Avenir Next", Avenir, system-ui, sans-serif;
  color: var(--ce-ink);
  background: var(--ce-cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ce-cream); }
body {
  min-width: 320px; min-height: 100vh; min-height: 100dvh; margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  color: var(--ce-ink); background:
    radial-gradient(circle at 15% 12%, rgba(243,191,209,.22), transparent 25rem),
    radial-gradient(circle at 90% 85%, rgba(185,218,237,.2), transparent 28rem), var(--ce-cream);
}
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button, .button { min-height: 44px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: var(--ce-outline) solid var(--ce-focus); outline-offset: 3px;
}
.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
  margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important;
}
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 1000; padding: 12px 16px; background: white; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.toast {
  position: fixed; z-index: 1000; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(90vw, 520px); padding: 13px 18px; border-radius: 999px; color: white; background: var(--ce-ink);
  box-shadow: var(--shadow); font-weight: 800; text-align: center;
}

.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  min-height: 72px; padding: 10px clamp(16px, 3vw, 44px); border-bottom: 1px solid rgba(34,48,74,.1);
  background: rgba(255,250,240,.92); backdrop-filter: blur(12px);
}
.brand-button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 2px; }
.brand-button strong, .brand-button small { display: block; }
.brand-button strong { font-size: 1.12rem; }
.brand-button small { color: var(--ce-muted); font-size: .73rem; }
.brand-mark {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px;
  color: var(--ce-ink); background: var(--ce-yellow); box-shadow: var(--shadow-small); font-size: 1.7rem; font-weight: 900;
}
.topbar nav { display: flex; gap: 6px; }
.topbar nav button {
  border: 0; border-radius: 12px; padding: 8px 12px; background: transparent; font-weight: 800;
}
.topbar nav button:hover { background: rgba(185,218,237,.4); }
main { width: 100%; }
.screen { width: min(100%, 1500px); min-height: calc(100dvh - 72px); margin: 0 auto; padding: clamp(18px, 3vw, 44px); }
.screen[hidden] { display: none !important; }
.screen-heading { max-width: 800px; margin-bottom: 28px; }
.screen-heading h1, .play-heading h1 { margin: 4px 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.1rem, 5vw, 4rem); line-height: .98; letter-spacing: -.035em; }
.screen-heading p { color: var(--ce-muted); font-size: 1.06rem; }
.eyebrow { margin: 0; color: #6b557e; font-size: .78rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid transparent; border-radius: 14px;
  padding: 11px 16px; font-weight: 900; text-decoration: none; box-shadow: var(--shadow-small);
}
.button.primary { color: white; background: var(--ce-ink); }
.button.primary:hover { background: #334566; }
.button.secondary { border-color: rgba(34,48,74,.15); background: var(--ce-paper); }
.button.secondary:hover { border-color: var(--ce-focus); }
.button.ghost { border: 0; box-shadow: none; background: rgba(255,255,255,.65); }
.button.attention, .attention { color: white; background: var(--ce-error); border: 0; }
.panel { border: 1px solid rgba(34,48,74,.11); border-radius: var(--ce-radius); background: rgba(255,254,249,.96); box-shadow: var(--shadow); }

/* Entrance */
.home-screen { padding-top: clamp(16px, 2.5vw, 34px); }
.bureau-room {
  position: relative; min-height: min(760px, calc(100dvh - 110px)); overflow: hidden; border: 8px solid #e7b896; border-radius: 34px;
  background:
    linear-gradient(to bottom, transparent 0 68%, #cfa982 68% 70%, #e7ccaa 70%),
    linear-gradient(135deg, #fbe8d8, #fff6e9 60%, #e4f0e8);
  box-shadow: 0 22px 55px rgba(60,45,40,.17), inset 0 0 0 2px rgba(255,255,255,.7);
}
.bureau-room::after {
  content: ""; position: absolute; inset: 70% 0 0; opacity: .22; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 100px, #8a6a50 101px 103px);
}
.entrance-copy {
  position: relative; z-index: 5; width: min(58%, 760px); margin: clamp(34px, 7vw, 86px) 0 0 clamp(24px, 6vw, 88px);
}
.entrance-copy h1 { margin: 8px 0 2px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.4rem, 8vw, 7rem); line-height: .82; letter-spacing: -.07em; }
.tagline { margin: 20px 0 8px; color: #694a73; font-size: clamp(1.3rem, 2.4vw, 2rem); font-weight: 900; }
.intro-copy { max-width: 630px; color: var(--ce-muted); font-size: 1.05rem; line-height: 1.55; }
.home-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: 590px; margin-top: 24px; }
.home-actions .primary { grid-column: 1 / -1; font-size: 1.07rem; }
.home-secondary { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 20px; }
.home-secondary button, .home-secondary a { min-height: 44px; border: 0; padding: 10px 2px; color: var(--ce-muted); background: transparent; font-weight: 800; }
.family-stage {
  position: absolute; z-index: 4; right: 3%; bottom: 13%; display: flex; align-items: flex-end; justify-content: center;
  width: 39%; min-height: 260px; filter: drop-shadow(0 10px 8px rgba(45,45,55,.2));
}
.family-stage .character { margin-left: -18px; }
.evidence-table {
  position: absolute; z-index: 3; right: 4%; bottom: 4%; width: 39%; height: 90px; border-radius: 50% 50% 18px 18px;
  background: #9c6f53; box-shadow: inset 0 8px rgba(255,255,255,.18), 0 14px 0 #714c3a;
}
.evidence-table .magnifier { position: absolute; left: 14%; top: 8px; font-size: 3rem; transform: rotate(-15deg); }
.evidence-table .note { position: relative; display: inline-block; margin: 18px 0 0 24%; padding: 8px; background: var(--ce-yellow); transform: rotate(2deg); font-size: .72rem; font-weight: 900; }
.room-window { position: absolute; right: 8%; top: 7%; width: 260px; height: 180px; border: 12px solid white; border-radius: 100px 100px 16px 16px; background: linear-gradient(#bce5f4, #eaf7e8); box-shadow: var(--shadow); }
.room-window::before, .room-window::after { content: ""; position: absolute; background: white; }
.room-window::before { left: 50%; top: 0; bottom: 0; width: 8px; }
.room-window::after { top: 52%; left: 0; right: 0; height: 8px; }
.room-shelves { position: absolute; right: 0; top: 36%; width: 24%; height: 35%; background: #c28d68; border-radius: 18px 0 0 18px; opacity: .7; }
.room-shelves i { display: block; height: 33%; border-bottom: 7px solid #8f6046; }

/* Characters */
.character { position: relative; display: inline-grid; place-items: end center; flex: 0 0 auto; }
.character-sprite { display: block; width: var(--character-width); height: var(--character-height); object-fit: contain; object-position: center bottom; user-select: none; }
.character-prop {
  position: absolute; right: -7px; top: 28%; display: grid; place-items: center; width: 44px; height: 44px;
  border: 3px solid white; border-radius: 50%; background: var(--ce-yellow); box-shadow: var(--shadow-small);
  font-size: 1.55rem; font-weight: 900;
}
.pose-magnify .character-prop { font-size: 2.2rem; transform: rotate(-16deg); }
.pose-reveal .character-prop { color: white; background: var(--ce-never); }
.expression-excited, .expression-proud { animation: character-pop .4s ease-out; }
@keyframes character-pop { 50% { transform: translateY(-8px) scale(1.025); } }
.character-head { overflow: hidden; width: 88px; height: 88px; border-radius: 50%; background: var(--ce-blue); }
.character-head img { transform: scale(1.65) translateY(19%); transform-origin: center top; }

/* Station map */
.concept-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 4px 16px; scrollbar-width: thin; }
.concept-file { flex: 0 0 auto; padding: 8px 12px; border: 1px dashed #9e7c56; border-radius: 10px; color: var(--ce-muted); background: #fff7d8; font-size: .78rem; font-weight: 800; }
.concept-file.complete { border-style: solid; color: var(--ce-success); background: #e7f5eb; }
.station-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.station-card {
  display: flex; align-items: flex-start; gap: 14px; min-height: 190px; padding: 22px; border: 1px solid rgba(34,48,74,.12);
  border-radius: 22px; background: var(--ce-paper); box-shadow: var(--shadow); text-align: left;
  transition: transform .18s ease, box-shadow .18s ease;
}
.station-card:nth-child(4n+1) { background: linear-gradient(145deg, #fffef9, #edf7f0); }
.station-card:nth-child(4n+2) { background: linear-gradient(145deg, #fffef9, #fff3f7); }
.station-card:nth-child(4n+3) { background: linear-gradient(145deg, #fffef9, #eff7fb); }
.station-card:nth-child(4n+4) { background: linear-gradient(145deg, #fffef9, #f7f1fb); }
.station-card:hover { transform: translateY(-4px); box-shadow: 0 16px 38px rgba(54,60,80,.18); }
.station-icon { display: grid; place-items: center; flex: 0 0 52px; height: 52px; border-radius: 16px; background: var(--ce-yellow); font-size: 1.7rem; font-weight: 900; }
.station-card strong, .station-card small, .station-card em { display: block; }
.station-card strong { margin: 4px 0 9px; font-size: 1.05rem; }
.station-card small { color: var(--ce-muted); line-height: 1.4; }
.station-card em { margin-top: 16px; color: #6b557e; font-size: .73rem; font-style: normal; font-weight: 900; }

/* Investigation */
.play-screen { width: min(100%, 1500px); }
.play-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.play-heading h1 { font-size: clamp(2rem, 3.5vw, 3.35rem); }
.investigation-layout { display: grid; grid-template-columns: minmax(230px, 24fr) minmax(440px, 46fr) minmax(280px, 30fr); gap: 16px; align-items: start; }
.claim-panel, .workspace-panel, .evidence-panel { padding: clamp(16px, 2vw, 25px); }
.claim-panel { position: sticky; top: 90px; text-align: center; background: linear-gradient(180deg, #f8f1fb, #fffef9 48%); }
.host-wrap { display: grid; place-items: center; min-height: 202px; }
.speech-card { position: relative; margin: -12px 0 17px; padding: 13px 14px; border-radius: 15px; background: white; box-shadow: var(--shadow-small); text-align: left; }
.speech-card::before { content: ""; position: absolute; top: -9px; left: 50%; width: 18px; height: 18px; background: white; transform: rotate(45deg); }
.speech-card h2 { position: relative; margin: 0 0 5px; font-size: 1rem; }
.speech-card p { position: relative; margin: 0; color: var(--ce-muted); font-size: .82rem; line-height: 1.4; }
.claim-card { position: relative; padding: 22px 16px 18px; border: 1px solid #e0d4bd; border-radius: 8px 8px 15px 15px; background: #fffdf5; box-shadow: 0 5px 0 #e8ddca; text-align: left; }
.claim-pin { position: absolute; top: 8px; left: 50%; width: 10px; height: 10px; border-radius: 50%; background: var(--ce-never); box-shadow: 0 1px 3px #777; }
.claim-label { margin: 0 0 6px; color: var(--ce-muted); font-size: .7rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.claim-statement { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.15rem, 1.5vw, 1.45rem); line-height: 1.35; }
.domain-card { margin-top: 15px; padding: 12px; border-left: 5px solid var(--ce-focus); border-radius: 9px; background: #edf6fb; text-align: left; }
.domain-card p { margin: 0; font-size: .83rem; line-height: 1.4; }
.domain-card strong, .domain-card span { display: block; }
.domain-card strong { font-size: .69rem; letter-spacing: .08em; text-transform: uppercase; }
.premise-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; text-align: left; }
.premise-list h3 { width: 100%; margin: 0; font-size: .75rem; }
.premise-chip { display: inline-block; padding: 6px 9px; border-radius: 999px; background: #f7e8c4; font-size: .72rem; font-weight: 800; }
.premise-chip.quiet { color: var(--ce-muted); background: #edf0f4; }
.workspace-panel { min-height: 650px; }
.workspace-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; border-bottom: 1px solid #e4e6e8; padding-bottom: 15px; }
.workspace-heading h2 { margin: 4px 0 0; font-size: clamp(1.25rem, 2vw, 1.65rem); }
.concept-badge { padding: 6px 10px; border-radius: 999px; background: var(--ce-lavender); font-size: .7rem; font-weight: 900; white-space: nowrap; }
.examples-panel { display: flex; flex-wrap: wrap; gap: 8px; margin: 15px 0; }
.examples-panel span { padding: 8px 11px; border-radius: 10px; background: #edf6fb; font-weight: 900; }
.classification-fieldset { margin: 18px 0; padding: 0; border: 0; }
.classification-fieldset legend { margin-bottom: 9px; font-size: .84rem; font-weight: 900; }
.classification-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.classification {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 8px; min-height: 82px; padding: 10px;
  border: 2px solid #d6dae0; border-radius: 15px; background: white; text-align: left;
}
.classification b { grid-row: 1 / 3; display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; color: white; }
.classification span { font-weight: 900; }
.classification small { color: var(--ce-muted); font-size: .65rem; }
.classification.always b { background: var(--ce-always); }
.classification.sometimes b { background: var(--ce-sometimes); }
.classification.never b { background: var(--ce-never); }
.classification[aria-pressed="true"] { border-width: 3px; box-shadow: 0 0 0 3px rgba(36,94,156,.16); }
.classification.always[aria-pressed="true"] { border-color: var(--ce-always); background: #edf7f2; }
.classification.sometimes[aria-pressed="true"] { border-color: var(--ce-sometimes); background: #fff8e9; }
.classification.never[aria-pressed="true"] { border-color: var(--ce-never); background: #fff1f4; }
.mission-card { display: flex; gap: 9px; margin: 15px 0; padding: 12px 14px; border-radius: 12px; background: #f7f1fb; font-size: .84rem; line-height: 1.4; }
.mission-card strong { flex: 0 0 auto; }
#candidateForm { margin-top: 17px; }
.field { display: grid; gap: 6px; font-weight: 900; }
.field span { color: var(--ce-muted); font-size: .77rem; }
.field input, .field select, .field textarea, textarea {
  width: 100%; min-height: 48px; border: 2px solid #cfd6df; border-radius: 12px; padding: 9px 11px; background: white; font-size: 16px;
}
.field textarea { min-height: 110px; resize: vertical; }
.pair-builder { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px; padding: 18px; border-radius: 16px; background: #f2f7f9; }
.operation-symbol { padding-bottom: 12px; font-size: 1.8rem; font-weight: 900; }
.calculation-preview { display: block; min-height: 38px; margin: 12px 0 0; padding: 8px; border-radius: 10px; background: #fff7d8; text-align: center; font-size: 1.15rem; font-weight: 900; }
.number-builder { display: grid; grid-template-columns: 1fr minmax(150px, .8fr); gap: 16px; align-items: start; }
.number-builder .field input { min-height: 80px; text-align: center; font-size: 2rem; font-weight: 900; }
.number-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.number-pad button { min-width: 44px; border: 1px solid #d5dce4; border-radius: 9px; background: white; font-weight: 900; }
.fraction-builder { display: grid; grid-template-columns: minmax(100px, 180px); justify-content: center; gap: 4px; }
.fraction-bar { height: 3px; background: var(--ce-ink); }
.shape-builder { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; align-items: center; padding: 16px; border-radius: 16px; background: #f2f7f9; }
.shape-preview-wrap { display: grid; place-items: center; min-height: 240px; overflow: hidden; }
.shape-preview-wrap p { align-self: end; color: var(--ce-muted); font-size: .76rem; text-align: center; }
.semantic-shape { max-width: 180px; max-height: 150px; border: 5px solid #476f91; background: rgba(185,218,237,.5); transition: .2s ease; }
.shape-controls { display: grid; gap: 12px; }
.check { display: flex; align-items: center; gap: 9px; min-height: 44px; font-size: .83rem; font-weight: 800; }
.check input { width: 24px; height: 24px; }
.card-choice { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.number-card { min-height: 90px; border: 3px solid #e2d6bd; border-radius: 15px; background: #fffdf4; box-shadow: 0 6px 0 #ddceb0; font-size: 1.7rem; font-weight: 900; }
.number-card[aria-pressed="true"] { border-color: var(--ce-focus); background: #eaf4fb; transform: translateY(3px); box-shadow: 0 3px 0 #a5bbcd; }
.repair-builder, .reason-builder { display: grid; gap: 10px; border: 0; padding: 0; }
.repair-builder legend, .reason-builder legend { margin-bottom: 8px; font-weight: 900; }
.choice-card { display: flex; align-items: center; gap: 11px; min-height: 58px; padding: 12px; border: 2px solid #d8dce2; border-radius: 13px; background: white; }
.choice-card:has(input:checked) { border-color: var(--ce-focus); background: #eef6fb; }
.choice-card input { width: 22px; height: 22px; flex: 0 0 auto; }
.builder-error { min-height: 1px; color: var(--ce-error); font-weight: 800; }
.test-button { width: 100%; margin-top: 18px; font-size: 1.05rem; }
.evidence-panel { position: sticky; top: 90px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-title-row h2 { margin: 0; font-size: 1.17rem; }
.evidence-count { padding: 5px 8px; border-radius: 999px; background: #edf0f4; color: var(--ce-muted); font-size: .67rem; font-weight: 900; }
.evidence-trays { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.evidence-trays section { min-height: 130px; padding: 10px; border: 2px dashed #ccd3db; border-radius: 13px; background: #fafbfc; }
.evidence-trays h3 { margin: 0 0 8px; font-size: .74rem; }
.evidence-trays section:first-child h3 { color: var(--ce-always); }
.evidence-trays section:last-child h3 { color: var(--ce-never); }
.evidence-list { display: grid; gap: 7px; }
.evidence-card { padding: 8px; border-radius: 9px; background: white; box-shadow: var(--shadow-small); font-size: .72rem; animation: evidence-in .25s ease-out; }
.evidence-card strong, .evidence-card span { display: block; }
.evidence-card span { margin-top: 3px; color: var(--ce-muted); }
@keyframes evidence-in { from { opacity: 0; transform: translateY(10px); } }
.feedback-panel { margin-top: 16px; padding: 15px; border: 2px solid #d7dce2; border-radius: 14px; background: #f7f8fa; }
.feedback-panel.warning { border-color: #d7ba7a; background: #fff8e8; }
.feedback-panel.success { border-color: #8bb69e; background: #edf8f1; }
.feedback-panel.progress { border-color: #9bbcd2; background: #eff7fb; }
.feedback-kicker { margin: 0 0 5px; font-weight: 900; }
.feedback-panel > p:last-of-type { margin: 0; color: #48576e; font-size: .87rem; line-height: 1.48; }
.support-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.support-actions .button { padding: 9px; font-size: .78rem; }
.mobile-action-bar, .mobile-action-spacer { display: none; }

/* Create */
.create-layout { display: grid; grid-template-columns: minmax(240px, 30%) 1fr; gap: 20px; }
.create-guide { padding: 26px; text-align: center; }
.create-guide #createCharacter { min-height: 240px; display: grid; place-items: center; }
.create-guide h2 { margin-bottom: 6px; }
.create-guide p { color: var(--ce-muted); line-height: 1.5; }
.create-paper { padding: clamp(22px, 4vw, 54px); background: linear-gradient(90deg, transparent 49px, rgba(225,105,115,.2) 50px 51px, transparent 52px), repeating-linear-gradient(#fffef9 0 35px, #dbe8ef 36px 37px); }
.created-sentence { padding: 22px; border-radius: 15px; background: rgba(255,255,255,.92); box-shadow: var(--shadow-small); font-family: Georgia, serif; font-size: clamp(1.4rem, 3vw, 2.3rem); line-height: 1.35; text-align: center; }
.create-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 30px 0 15px; }
.search-range { padding: 10px; border-radius: 10px; background: rgba(255,255,255,.8); color: var(--ce-muted); font-size: .82rem; font-weight: 800; }
.created-result { margin: 18px 0; padding: 16px; border-radius: 14px; background: white; box-shadow: var(--shadow-small); }
.created-result.found-counter { border-left: 6px solid var(--ce-never); }
.created-result.no-counter { border-left: 6px solid var(--ce-sometimes); }
.created-result p { margin-bottom: 0; line-height: 1.5; }

/* Casebook */
.casebook-toolbar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 18px; }
.file-button { position: relative; overflow: hidden; cursor: pointer; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.casebook-layout { display: grid; grid-template-columns: minmax(230px, 28%) 1fr; min-height: 540px; border: 1px solid #bca57d; border-radius: 22px; overflow: hidden; background: #76523f; box-shadow: var(--shadow); }
.casebook-list { display: grid; align-content: start; gap: 7px; padding: 16px; background: #8b6149; }
.case-list-item { min-height: 68px; padding: 10px 12px; border: 0; border-radius: 11px; background: #f4e2bb; text-align: left; }
.case-list-item.selected { background: white; box-shadow: inset 5px 0 var(--ce-focus); }
.case-list-item strong, .case-list-item small { display: block; }
.case-list-item small { margin-top: 5px; color: var(--ce-muted); }
.casebook-detail { padding: clamp(18px, 4vw, 48px); background: #f5ead1; }
.case-paper { min-height: 450px; padding: clamp(20px, 4vw, 44px); background: repeating-linear-gradient(#fffef9 0 35px, #dbe8ef 36px 37px); box-shadow: var(--shadow-small); }
.case-paper h2 { font-family: Georgia, serif; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.case-explanation { margin: 20px 0; padding: 16px; border-left: 5px solid var(--ce-focus); background: rgba(237,246,251,.92); line-height: 1.5; }
.case-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.empty-casebook { color: white; padding: 25px; text-align: center; }
.empty-casebook span { font-size: 3rem; }

/* Dialogs */
dialog { width: min(92vw, 720px); max-height: 88dvh; padding: 0; border: 0; border-radius: 22px; color: var(--ce-ink); background: transparent; box-shadow: 0 24px 80px rgba(20,25,40,.35); }
dialog::backdrop { background: rgba(25,32,48,.55); backdrop-filter: blur(4px); }
.dialog-card { position: relative; max-height: 88dvh; overflow-y: auto; padding: clamp(24px, 5vw, 46px); border-radius: 22px; background: var(--ce-paper); }
.dialog-card h1 { font-family: Georgia, serif; }
.dialog-close { position: absolute; right: 14px; top: 14px; width: 44px; border: 0; border-radius: 50%; background: #edf0f4; font-size: 1.5rem; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.help-grid section { padding: 15px; border-radius: 13px; background: #f1f6f7; }
.help-grid h2 { margin: 0 0 5px; font-size: 1rem; }
.help-grid p { margin: 0; color: var(--ce-muted); font-size: .85rem; line-height: 1.4; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 58px; border-bottom: 1px solid #e0e4e8; font-weight: 900; }
.setting-row input { width: 26px; height: 26px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

@media (min-width: 600px) and (max-width: 1023px) {
  .station-grid { grid-template-columns: repeat(2, 1fr); }
  .investigation-layout { grid-template-columns: minmax(200px, 31%) 1fr; }
  .evidence-panel { position: static; grid-column: 1 / -1; display: grid; grid-template-columns: 1.2fr 1fr; gap: 15px; }
  .evidence-panel .panel-title-row { grid-column: 1 / -1; }
  .support-actions { align-content: start; }
  .claim-panel { top: 86px; }
  .bureau-room { min-height: 800px; }
  .entrance-copy { width: 70%; }
  .family-stage, .evidence-table { width: 45%; }
}

@media (max-width: 599px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar { min-height: 62px; padding: 8px 12px; }
  .brand-mark { width: 42px; height: 42px; }
  .brand-button small { display: none; }
  .topbar nav button { display: none; }
  .topbar nav #quickSoundButton { display: block; padding: 8px; font-size: .75rem; }
  .screen { min-height: calc(100dvh - 62px); padding: 14px; }
  .bureau-room { min-height: 830px; border-width: 5px; border-radius: 24px; }
  .entrance-copy { width: auto; margin: 28px 18px 0; text-align: center; }
  .entrance-copy h1 { font-size: clamp(3.3rem, 17vw, 5rem); }
  .intro-copy { font-size: .9rem; }
  .home-actions { grid-template-columns: 1fr; }
  .home-actions .primary { grid-column: auto; }
  .home-secondary { justify-content: center; margin-top: 12px; }
  .family-stage { right: 2%; bottom: 9%; width: 96%; transform: scale(.78); transform-origin: center bottom; }
  .evidence-table { right: 5%; bottom: 3%; width: 90%; }
  .room-window { width: 160px; height: 120px; right: -25px; top: 32%; opacity: .7; }
  .room-shelves { display: none; }
  .station-grid { grid-template-columns: 1fr; }
  .station-card { min-height: 130px; }
  .play-screen { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .play-heading { align-items: center; }
  .play-heading h1 { font-size: 1.7rem; }
  .play-heading .button { display: none; }
  .investigation-layout { display: block; }
  .claim-panel, .workspace-panel, .evidence-panel { position: static; margin-bottom: 12px; padding: 14px; }
  .claim-panel { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; text-align: left; }
  .host-wrap { grid-row: 1; min-height: 90px; overflow: hidden; border-radius: 15px; background: #edf4f7; }
  .host-wrap .character { transform: scale(.62); transform-origin: center center; height: 90px; }
  .speech-card { grid-column: 2; grid-row: 1; margin: 0; }
  .speech-card::before { left: -7px; top: 30px; }
  .claim-card, .domain-card, .premise-list { grid-column: 1 / -1; }
  .claim-statement { font-size: 1.2rem; }
  .workspace-panel { min-height: 0; }
  .workspace-heading { display: block; }
  .concept-badge { display: inline-block; margin-top: 8px; }
  .classification-controls { grid-template-columns: 1fr; }
  .classification { min-height: 61px; }
  .number-builder { grid-template-columns: 1fr; }
  .number-pad { grid-template-columns: repeat(6, 1fr); }
  .number-pad button { min-width: 0; }
  .pair-builder { grid-template-columns: 1fr auto 1fr; padding: 12px; }
  .shape-builder { grid-template-columns: 1fr; }
  .shape-preview-wrap { min-height: 190px; }
  .card-choice { grid-template-columns: 1fr 1fr; }
  .evidence-panel { display: block; }
  .support-actions { grid-template-columns: 1fr 1fr; }
  .mobile-action-bar {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid #cfd4da;
    background: rgba(255,254,249,.96); box-shadow: 0 -6px 20px rgba(45,50,65,.12); backdrop-filter: blur(10px);
  }
  .mobile-action-bar button { border: 0; border-radius: 11px; background: #eaf1f4; font-size: .75rem; font-weight: 900; }
  .mobile-action-bar button:first-child { color: white; background: var(--ce-ink); }
  .mobile-action-spacer { display: block; height: 6px; }
  .create-layout, .casebook-layout { grid-template-columns: 1fr; }
  .create-guide { display: grid; grid-template-columns: 100px 1fr; text-align: left; }
  .create-guide #createCharacter { grid-row: 1 / 3; min-height: 150px; overflow: hidden; }
  .create-guide #createCharacter .character { transform: scale(.72); }
  .create-controls { grid-template-columns: 1fr; }
  .casebook-list { max-height: 260px; overflow-y: auto; }
  .casebook-detail { padding: 12px; }
  .help-grid { grid-template-columns: 1fr; }
}

@media (max-width: 880px) and (orientation: landscape) {
  .play-screen { padding-bottom: 74px; }
  .investigation-layout { display: grid; grid-template-columns: 35% 1fr; }
  .claim-panel { position: static; max-height: calc(100dvh - 150px); overflow-y: auto; }
  .workspace-panel { min-height: 0; max-height: calc(100dvh - 150px); overflow-y: auto; }
  .evidence-panel { grid-column: 1 / -1; }
  .host-wrap { min-height: 110px; }
  .host-wrap .character { transform: scale(.68); transform-origin: center bottom; height: 110px; overflow: hidden; }
}

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

@media print {
  .topbar, .screen:not(.casebook-screen), .casebook-toolbar, .casebook-list, .case-actions { display: none !important; }
  .casebook-screen { display: block !important; padding: 0; }
  .casebook-layout { display: block; border: 0; box-shadow: none; }
  .casebook-detail { padding: 0; background: white; }
  .case-paper { box-shadow: none; }
}
