:root {
  color-scheme: dark;
  --bg: #1d2020; --panel: #252929; --text: #eef1ec; --muted: #a9b1ab;
  --line: #414846; --line-strong: #7f9b90; --gold: #cfbd8a;
  --green: #84c2a1; --blue: #86b7ce; --red: #d88384;
  --paper: #ecefeb; --ink: #25312e; --serif: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
[inert] { pointer-events: none; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", system-ui, sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; border-radius: 4px; }
button { cursor: pointer; color: inherit; border: 1px solid var(--line); background: var(--panel); }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid #4f97bf; outline-offset: 3px; }
input, select { min-height: 40px; border: 1px solid var(--line); padding: 8px 10px; background: #171d1b; color: var(--text); min-width: 0; }
h1, h2, h3, p { margin-top: 0; }
img { display: block; }
a { color: inherit; }
.icon { display: inline-block; flex: 0 0 auto; width: 19px; height: 19px; background: currentColor; mask: var(--icon) center/contain no-repeat; vertical-align: middle; }
.icon-send { --icon: url('/icon-send.svg'); }
.icon-log-out { --icon: url('/icon-log-out.svg'); }
.icon-download { --icon: url('/icon-download.svg'); }
.icon-pencil-line { --icon: url('/icon-pencil-line.svg'); }
.icon-plus { --icon: url('/icon-plus.svg'); }
.icon-x { --icon: url('/icon-x.svg'); }
.icon-trash-2 { --icon: url('/icon-trash-2.svg'); }
.icon-check { --icon: url('/icon-check.svg'); }
.icon-layers { --icon: url('/icon-layers.svg'); }
.icon-book-open { --icon: url('/icon-book-open.svg'); }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; flex: 0 0 auto; }
.icon-button:hover:not(:disabled) { background: #3b4942; border-color: var(--line-strong); }

.masthead { position: relative; display: flex; align-items: center; justify-content: space-between; height: 88px; padding: 0 28px; overflow: hidden; background: #202525; border-bottom: 3px solid #879489; }
.masthead::after { content: ''; position: absolute; left: 0; bottom: 0; width: 210px; height: 3px; background: linear-gradient(90deg, #eeeed8 20%, #78abc5 20% 40%, #606367 40% 60%, #c26972 60% 80%, #77a28b 80%); }
.masthead-art { position: absolute; right: 130px; top: -190px; width: 470px; height: 343px; object-fit: cover; opacity: .62; pointer-events: none; }
.brand { position: relative; display: flex; min-width: 0; gap: 14px; align-items: center; }
.brand > div { min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 48px; border: 1px solid #a4ab96; border-bottom: 4px solid var(--gold); background: #222b27; border-radius: 3px; color: var(--gold); }
.brand-mark .icon { width: 25px; height: 25px; }
.brand h1 { font: 36px/1 var(--serif); margin: 0 0 7px; }
.brand p { font-size: 12px; color: #c0cac1; margin: 0; }
.masthead-controls { position: relative; display: flex; flex-shrink: 0; gap: 18px; align-items: center; }
.edition-label { font-size: 10px; color: #ccd1c6; }
.masthead-controls .icon-button { background: #1d2723; }
.masthead-controls .sign-out-button { display: inline-flex; width: auto; padding: 0 9px; gap: 6px; font-size: 12px; }
.shell { display: grid; grid-template-columns: 210px minmax(340px, 1fr) 380px; height: calc(100dvh - 88px); min-height: 600px; }
.rail { padding: 24px 18px; background: #202726; border-right: 1px solid var(--line); overflow: auto; min-width: 0; }
.library-drawer summary { display: none; }
.rail section + section { margin-top: 36px; }
.rail h2 { font: 19px var(--serif); margin-bottom: 16px; color: #d5d9d0; }
.history { display: grid; gap: 10px; }
.history-item { width: 100%; display: grid; text-align: left; gap: 6px; padding: 10px 0 12px; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.history-item:hover { color: var(--gold); }
.history-item strong { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.history-item span, .empty-history { font-size: 11px; color: var(--muted); }
.status-card dl { margin: 0; display: grid; gap: 12px; font-size: 11px; }
.status-card dl > div { display: grid; gap: 1px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.art-credit { display: inline-block; margin-top: 32px; font-size: 10px; color: var(--muted); }
.sync-button, .model-button { width: 100%; min-height: 40px; margin-bottom: 12px; }

.chat-panel { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; background: var(--paper); color: var(--ink); }
.chat-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 24px 28px 20px; border-bottom: 1px solid #ced7ce; }
.eyebrow { margin: 0 0 7px; font-size: 10px; text-transform: uppercase; color: var(--muted); }
.chat-panel .eyebrow { color: #60726b; }
.chat-top h2 { margin: 0; font: 26px/1.15 var(--serif); }
.selectors { display: flex; gap: 10px; }
.selectors label { display: grid; gap: 4px; font-size: 10px; color: #576b61; }
.selectors select { width: 125px; }
.selectors input { width: 86px; }
.chat-panel input, .chat-panel select { color: var(--ink); background: #fafbf7; border-color: #bccac0; }
.messages { overflow: auto; min-height: 0; padding: 24px 28px; display: flex; flex-direction: column; gap: 22px; scrollbar-gutter: stable; }
.opening { margin: auto 0; padding: 4px 0 24px; }
.opening h3 { font: 27px/1.2 var(--serif); margin: 0 0 28px; }
.commander-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; align-items: start; }
.commander-choice { border: 0; background: none; color: var(--ink); text-align: left; padding: 0; min-width: 0; }
.commander-choice img { width: 100%; height: auto; aspect-ratio: 488/680; object-fit: contain; border-radius: 6px; box-shadow: 0 8px 12px #17251c25; transition: transform .16s; }
.commander-choice:hover img { transform: translateY(-5px); }
.commander-choice span { display: block; margin-top: 13px; font: 16px var(--serif); }
.commander-choice small { display: block; margin-top: 4px; font-size: 10px; color: #62756a; }
.message { display: flex; gap: 10px; width: 100%; align-items: start; }
.message.user { flex-direction: row-reverse; }
.avatar { display: grid; place-items: center; flex: 0 0 28px; height: 32px; border: 1px solid #748c7b; border-radius: 2px; background: #233a31; color: #f3f4ee; font: 11px var(--serif); }
.message.user .avatar { background: #8b4f57; border-color: #8b4f57; }
.bubble { min-width: 0; max-width: 100%; padding: 14px 16px; border: 1px solid #c5d0c6; border-left: 3px solid #729585; background: #fcfdf9; border-radius: 2px; overflow-wrap: anywhere; line-height: 1.65; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble small { color: #6c7c72; font-size: 10px; }
.message.user .bubble { background: #dde7df; border-left: 1px solid #c5d0c6; border-right: 3px solid #956673; }
.query-note { color: #737f77; font-style: italic; }
.correction-note { padding-bottom: 10px; border-bottom: 1px solid #dae2d8; font-size: 12px; color: #49675b; }
.card-choices { display: grid; gap: 6px; }
.card-choice { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; background: #eff3ec; color: var(--ink); border: 1px solid #c7d6c9; text-align: left; }
.card-choice:hover { border-color: #718d7c; background: #e0ebdf; }
.card-choice img { width: 44px; height: 61px; object-fit: contain; border-radius: 3px; }
.card-choice > span:nth-last-child(2) { flex: 1; min-width: 0; }
.card-choice strong { font: 14px var(--serif); }
.card-choice small { display: block; font-size: 10px; }
.card-choice > span:last-child { font-size: 11px; }
.composer { position: relative; display: grid; grid-template-columns: minmax(0,1fr) 48px; gap: 10px; padding: 16px 24px; border-top: 1px solid #cad4c9; background: #e1e7de; }
.composer input { width: 100%; height: 48px; padding: 0 14px; font-size: 13px; }
.composer > button { height: 48px; display: grid; place-items: center; background: #294c3d; border-color: #294c3d; color: #fafcf6; }
.composer > button:hover:not(:disabled) { background: #35604d; }
.suggestions { position: absolute; display: none; bottom: 76px; left: 24px; right: 84px; max-height: 230px; overflow: auto; background: #fbfcf7; border: 1px solid #8b9d8e; z-index: 5; box-shadow: 0 8px 24px #19341f20; }
.suggestions button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #e0e5dc; background: none; color: var(--ink); padding: 10px 12px; border-radius: 0; }
.suggestions button:hover, .suggestions [aria-selected="true"] { background: #dce8dc; }

.inspector { min-width: 0; overflow: auto; padding: 24px 20px; border-left: 1px solid #aab6aa; background: #292d2c; scrollbar-gutter: stable; }
.hero-card { display: grid; grid-template-columns: 132px minmax(0,1fr); gap: 16px; align-items: center; min-height: 200px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.hero-card h2 { font: 21px/1.2 var(--serif); margin: 0 0 10px; overflow-wrap: anywhere; }
.hero-card p:not(.eyebrow) { color: #b2bdb4; font-size: 11px; margin-bottom: 10px; }
.card-art { width: 132px; height: auto; aspect-ratio: 488/680; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 16px #0005; }
.empty-card-slot, .card-art-placeholder { width: 132px; aspect-ratio: 488/680; border: 1px solid #627167; outline: 3px double #47554b; outline-offset: -8px; border-radius: 6px; background: #202823; display: grid; place-items: center; color: #6e8e78; font-size: 11px; }
.empty-card-slot .icon { width: 38px; height: 38px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; font-size: 10px; color: #aebbb0; }
.hero-meta strong { color: var(--green); font-size: 14px; }
.role-tags { display: flex; flex-wrap: wrap; gap: 4px 8px; color: #acbbb0; font-size: 9px; }
.role-tags span { padding: 0; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); padding: 18px 0; border-bottom: 1px solid var(--line); gap: 8px; }
.metrics span { font: 19px var(--serif); color: #f0f2e8; overflow-wrap: anywhere; }
.metrics p { margin: 5px 0 0; font-size: 9px; color: var(--muted); }
.metrics div:nth-child(2) span { color: var(--green); }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.section-title h2, .deck-section h2 { font: 18px var(--serif); margin: 0; }
.chart-section, .deck-section { margin-top: 20px; }
.toolbar-actions { display: flex; gap: 6px; }
.curve { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); gap: 7px; align-items: end; height: 170px; padding-top: 12px; border-bottom: 1px solid var(--line); }
.bar { display: grid; gap: 5px; min-width: 0; }
.bar-fill { min-height: 6px; background: #81a28f; border-top: 2px solid #c4d2ba; border-radius: 1px 1px 0 0; }
.bar:nth-child(3n) .bar-fill { background: #af7980; border-color: #dbb3b5; }
.bar span { color: var(--muted); font-size: 10px; text-align: center; }
.deck-section > h2 { margin-bottom: 14px; }
.decklist { display: grid; gap: 0; }
.deck-card { display: grid; grid-template-columns: 52px minmax(0,1fr) auto; gap: 2px 10px; border: 0; border-bottom: 1px solid var(--line); background: none; border-radius: 0; text-align: left; width: 100%; padding: 10px 0; align-items: start; min-width: 0; }
.deck-card:hover { background: #323e37; }
.deck-card.selected { background: #36413a; box-shadow: inset 2px 0 #b9cba8; }
.deck-card > span { min-width: 0; }
.deck-card strong { font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.deck-card small { display: block; font-size: 9px; line-height: 1.4; color: var(--muted); }
.deck-thumb { grid-row: 1/4; width: 52px; height: 40px; object-fit: cover; margin-left: 4px; border-radius: 2px; }
.no-art { background: #242e27; }
.deck-card .price { font-size: 11px; color: var(--green); }
.deck-card .meta, .deck-card .role-tags { grid-column: 2/4; font-size: 9px; color: var(--muted); }
.loading { color: #607265; }

.editor-dialog { width: min(1100px,calc(100% - 24px)); height: min(850px,88dvh); max-height: 88dvh; padding: 0; border: 1px solid #879b87; border-radius: 6px; background: #242d27; color: var(--text); }
.editor-dialog::backdrop, .access-dialog::backdrop { background: #080d0bc4; }
.editor-shell { display: grid; grid-template-rows: auto auto auto minmax(0,1fr) auto; gap: 16px; padding: 24px; height: 100%; }
.editor-header, .editor-footer { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.editor-header { border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.editor-header h2 { font: 25px var(--serif); margin: 0; overflow-wrap: anywhere; }
.editor-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.editor-summary span { font: 22px var(--serif); color: #cbd6bd; }
.editor-summary p { color: var(--muted); font-size: 10px; margin: 4px 0 0; }
.editor-add { position: relative; display: grid; grid-template-columns: minmax(0,1fr) 85px; gap: 12px; align-items: end; }
.editor-add label { display: grid; gap: 6px; font-size: 11px; color: var(--muted); }
.editor-add button, .editor-footer button { display: flex; gap: 8px; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; }
.editor-suggestions { display: none; position: absolute; top: 100%; left: 0; right: 96px; z-index: 3; max-height: 220px; overflow: auto; border: 1px solid var(--line-strong); background: #1c2821; }
.editor-suggestions button { display: block; width: 100%; border: 0; border-radius: 0; text-align: left; padding: 10px; }
.editor-suggestions button:hover, .editor-suggestions [aria-selected="true"] { background: #3b4c40; }
.editor-body { display: grid; grid-template-columns: minmax(0,1fr) 250px; gap: 20px; min-height: 0; }
.editor-list, .editor-validation { overflow: auto; min-height: 0; }
.editor-row { display: grid; grid-template-columns: minmax(0,1fr) 60px 36px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.editor-card-select { border: 0; background: none; display: grid; min-width: 0; gap: 3px; text-align: left; padding: 4px; }
.editor-card-select strong { font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.editor-card-select span { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.editor-row > span { font-size: 12px; }
.editor-validation { border-left: 1px solid var(--line); padding-left: 18px; font-size: 12px; }
.editor-validation h3 { font: 19px var(--serif); }
.editor-validation ul { padding-left: 16px; }
.editor-validation li { margin-bottom: 8px; }
.editor-footer { justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 14px; }
#saveEditorButton { background: #52755e; border-color: #90ad91; }
.valid-text { color: var(--green); }
.invalid-text { color: var(--red); }
.access-dialog { width: min(420px,calc(100% - 32px)); padding: 32px; background: #202b25; color: var(--text); border: 1px solid #819281; border-top: 4px solid #afbd9e; border-radius: 4px; }
.access-dialog h2 { font: 26px/1.25 var(--serif); margin: 8px 0 20px; }
.access-dialog p { overflow-wrap: anywhere; }
.access-dialog [role="alert"] { font-size: 12px; }
.sign-out-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.sign-out-actions button { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px; }
#confirmSignOut { background: #633f44; border-color: #a56c75; color: #fff; }

@media (min-width: 1550px) {
  .shell { grid-template-columns: 240px minmax(0,1fr) 430px; }
  .messages { padding: 34px 48px; }
  .commander-gallery { max-width: 650px; }
  .commander-choice img { max-height: 300px; }
}
@media (max-width: 1180px) and (min-width: 1000px) {
  .shell { grid-template-columns: 170px minmax(330px,1fr) 320px; }
  .chat-top { display: grid; padding: 20px; }
  .messages { padding: 22px 20px; }
  .hero-card { grid-template-columns: 105px minmax(0,1fr); gap: 12px; }
  .card-art, .empty-card-slot, .card-art-placeholder { width: 105px; }
}
@media (max-width: 999px) {
  .masthead { height: 76px; padding: 0 20px; }
  .masthead-art { right: 0; opacity: .32; }
  .masthead-controls .edition-label { display: none; }
  .shell { grid-template-columns: minmax(0,1fr); height: auto; min-height: 0; }
  .rail { padding: 0; border: 0; border-bottom: 1px solid var(--line); }
  .library-drawer summary { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 12px 20px; font-size: 12px; }
  .library-drawer section { padding: 12px 20px; margin: 0 !important; }
  .library-drawer .art-credit { margin: 8px 20px 18px; }
  .status-card dl { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .chat-panel { height: 650px; }
  .commander-gallery { max-width: 570px; }
  .inspector { border-left: 0; }
  .hero-card { grid-template-columns: 150px minmax(0,1fr); }
  .card-art, .empty-card-slot, .card-art-placeholder { width: 150px; }
  .decklist { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 18px; }
}
@media (max-width: 600px) {
  .brand h1 { font-size: 30px; }
  .brand p { font-size: 10px; }
  .brand-mark { width: 32px; height: 40px; }
  .masthead { padding: 0 16px; gap: 10px; }
  .masthead-art { width: 260px; top: -80px; height: 190px; }
  .brand { gap: 10px; }
  .chat-top { align-items: start; flex-direction: column; padding: 18px; gap: 16px; }
  .chat-top h2 { font-size: 25px; }
  .selectors { width: 100%; }
  .selectors label:first-child { flex: 1; }
  .selectors select { width: 100%; }
  .chat-panel { height: 610px; }
  .messages { padding: 20px 16px; gap: 18px; }
  .opening h3 { font-size: 24px; margin-bottom: 18px; }
  .commander-gallery { gap: 9px; }
  .commander-choice span { font-size: 14px; margin-top: 10px; }
  .commander-choice small { font-size: 9px; }
  .bubble { padding: 11px 12px; font-size: 13px; }
  .avatar { flex-basis: 24px; height: 29px; font-size: 9px; }
  .composer { padding: 12px 16px; grid-template-columns: minmax(0,1fr) 44px; gap: 8px; }
  .composer input { padding: 0 10px; }
  .suggestions { left: 16px; right: 68px; }
  .card-choice { gap: 7px; padding: 7px; }
  .card-choice strong { font-size: 12px; }
  .card-choice > span:last-child { font-size: 10px; }
  .inspector { padding: 20px 16px; }
  .decklist { grid-template-columns: minmax(0,1fr); }
  .hero-card { grid-template-columns: 130px minmax(0,1fr); }
  .card-art, .empty-card-slot, .card-art-placeholder { width: 130px; }
  .editor-shell { padding: 16px; gap: 12px; }
  .editor-header h2 { font-size: 20px; }
  .editor-body { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(100px,1fr) minmax(100px,.6fr); gap: 12px; }
  .editor-validation { border-left: 0; border-top: 1px solid var(--line); padding: 12px 0; }
  .editor-row { grid-template-columns: minmax(0,1fr) 48px 36px; gap: 7px; }
  .editor-summary span { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

.icon-undo-2 { --icon: url('/icon-undo-2.svg'); }
.icon-redo-2 { --icon: url('/icon-redo-2.svg'); }
.icon-upload { --icon: url('/icon-upload.svg'); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.workspace-tabs { display: none; }
.constraint-bar { font-size: 12px; border-bottom: 1px solid #cbd4cb; background: #e1e7df; padding: 10px 28px; }
.constraint-bar summary { cursor: pointer; }
.constraint-bar summary span { float: right; color: #536459; font-size: 11px; }
.constraint-fields { display: grid; grid-template-columns: minmax(0,1fr) 75px minmax(0,1.1fr); gap: 10px; padding: 12px 0 4px; }
.constraint-fields label { display: grid; gap: 5px; min-width: 0; }
.constraint-fields input { width: 100%; background: #f6f8f4; color: #25312e; border-color: #b8c7bc; }
.composer:has(#cancelRequest:not([hidden])) { grid-template-columns: minmax(0,1fr) 44px 36px; }
.composer #cancelRequest { background: #633f44; color: #fff; }
.card-evidence { font-size: 12px; margin-top: 14px; }
.card-evidence summary, .deck-analysis summary { cursor: pointer; padding: 8px 0; }
.card-evidence p { margin-top: 10px; }
.oracle-text { white-space: pre-line; overflow-wrap: anywhere; }
.card-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: center; gap: 10px; margin: 14px 0 18px; font-size: 11px; }
.card-options label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.card-options input[type='checkbox'] { min-height: auto; accent-color: #84c2a1; }
.card-options input[type='number'] { width: 58px; padding: 4px 6px; min-height: 32px; }
.card-options button { min-height: 36px; padding: 4px 8px; }
.price-coverage { font-size: 11px; color: #c8d1c8; padding: 10px 0 16px; border-bottom: 1px solid var(--line); }
.deck-analysis { font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 18px; padding: 8px 0; }
.deck-analysis h3 { margin: 12px 0 6px; font-size: 14px; }
.role-counts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 16px; }
.role-counts div { display: flex; justify-content: space-between; gap: 8px; }
.section-title { flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.toolbar-actions .icon-button { width: 32px; height: 32px; }
.deck-controls { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; padding: 8px 0 14px; font-size: 11px; }
.deck-controls > input { grid-column: 1/-1; width: 100%; min-height: 36px; font-size: 12px; }
.deck-controls label { display: grid; gap: 4px; min-width: 0; }
.deck-controls select { width: 100%; min-height: 34px; padding: 4px; font-size: 12px; }
.decklist { display: block; }
.deck-group { margin: 0 0 14px; }
.deck-group h3 { margin: 8px 0 6px; font: 15px var(--serif); display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.deck-group h3 span { color: var(--muted); }
.deck-card { width: 100%; }
.recommendation-choices { display: grid; gap: 6px; margin: 12px 0; }
.recommendation-choices button { background: #edf2e9; color: #25312e; padding: 8px 10px; text-align: left; }
.proposal-dialog, .import-dialog { height: auto; max-height: 90dvh; width: min(800px,calc(100% - 24px)); }
.proposal-shell { padding: 24px; display: grid; gap: 16px; max-height: 88dvh; overflow: auto; }
.proposal-shell header, .proposal-shell footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.proposal-shell h2 { margin: 0; font: 24px var(--serif); }
.proposal-shell footer { justify-content: flex-end; }
.proposal-shell footer button { min-height: 40px; padding: 6px 14px; }
.proposal-diff { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; }
.proposal-diff pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.7 'Segoe UI',sans-serif; margin: 0; }
.proposal-diff h3 { font: 18px var(--serif); padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.import-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.import-fields label, .import-text { display: grid; gap: 6px; min-width: 0; font-size: 12px; }
.import-fields input { width: 100%; }
.import-text textarea { width: 100%; min-height: 240px; resize: vertical; color: var(--text); background: #171d1b; border: 1px solid var(--line); border-radius: 4px; padding: 12px; font: 13px/1.6 monospace; }
@media(max-width: 999px) {
  .workspace-tabs { display: flex; gap: 0; background: #202726; border-bottom: 1px solid var(--line); }
  .workspace-tabs button { flex: 1; padding: 11px 8px; border: 0; border-radius: 0; background: transparent; border-bottom: 3px solid transparent; }
  .workspace-tabs [aria-selected='true'] { border-bottom-color: var(--gold); color: var(--gold); }
  body[data-view='chat'] .inspector, body[data-view='deck'] .chat-panel, body[data-view='card'] .chat-panel { display: none; }
  body[data-view='deck'] .selected-card-panel { display: none; }
  body[data-view='card'] .inspector > :not(.selected-card-panel) { display: none; }
  .chat-panel { height: max(600px,calc(100dvh - 166px)); }
  .inspector { min-height: calc(100dvh - 166px); }
}
@media(max-width: 600px) {
  .constraint-bar { padding: 10px 18px; }
  .constraint-bar summary span { float: none; display: block; margin: 4px 0 0 16px; }
  .constraint-fields { grid-template-columns: minmax(0,1fr) 76px; }
  .constraint-fields label:last-child { grid-column: 1/-1; }
  .proposal-shell { padding: 16px; }
  .proposal-shell h2 { font-size: 20px; }
  .proposal-diff, .import-fields { grid-template-columns: minmax(0,1fr); }
}

/* Commander entry and conversation share the card table's ink surface. */
:root { --bg: #171b1c; --panel: #242a2b; --text: #eef0eb; --muted: #b2bcb5; --gold: #cbb77a; --line: #3d4645; }
.masthead { height: 72px; border-bottom: 1px solid #4e5551; background: #161b1d; }
.masthead::after { display: none; }
.brand-mark { border: 0; background: none; width: 30px; height: 38px; }
.brand h1 { font-size: 32px; }
.brand p { font-size: 11px; }
.shell { height: calc(var(--app-height,100dvh) - 72px); min-height: 0; }
.rail { background: #171d1f; }
.chat-panel { background: #1d2324; color: var(--text); }
.chat-top { grid-row: 1; padding: 26px 28px 20px; align-items: start; flex-wrap: wrap; border-color: var(--line); }
.workshop-heading { flex: 1 1 230px; min-width: 0; display: flex; align-items: start; gap: 12px; }
.chat-top h2 { font: 32px/1.16 var(--serif); max-width: 360px; overflow-wrap: anywhere; }
.has-selection .chat-top h2 { font-size: 24px; }
.chosen-anchor { flex: 0 0 44px; }
.chosen-anchor .icon-button { width: 44px; height: 44px; }
.selectors { gap: 12px; align-items: end; }
.selectors label { color: var(--muted); font-size: 12px; }
.selectors select, .selectors input { min-height: 44px; }
.chat-panel input, .chat-panel select { background: #151b1d; color: var(--text); border-color: #64736b; }
.constraint-bar { grid-row: 2; background: #222b2a; border-color: var(--line); color: var(--text); }
.constraint-bar summary span { color: #b7c1b9; }
.constraint-fields input { background: #151b1d; color: var(--text); border-color: #64736b; }
.messages { grid-row: 3; gap: 26px; padding-top: 26px; }
.opening { margin: 0; padding: 0 0 20px; max-width: 660px; width: 100%; }
.commander-search { position: relative; margin-bottom: 24px; }
.commander-search > input { width: 100%; min-height: 48px; padding: 10px 14px; }
.commander-suggestions { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 240px; overflow: auto; border: 1px solid #7c8b7e; background: #222c2b; z-index: 8; box-shadow: 0 12px 24px #0005; }
.commander-suggestions button { display: block; width: 100%; min-height: 44px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 12px; background: transparent; color: var(--text); text-align: left; }
.commander-suggestions button:hover, .commander-suggestions [aria-selected=true] { background: #3b4841; }
.commander-gallery { gap: 16px; }
.commander-choice { color: var(--text); }
.commander-choice img { box-shadow: 0 8px 18px #0006; }
.commander-choice span { font-size: 17px; }
.commander-choice small { color: #b3beb5; font-size: 12px; line-height: 1.4; }
.message { min-width: 0; }
.message .avatar { display: none; }
.message.assistant .bubble { width: 100%; padding: 0; background: transparent; border: 0; }
.message.user .bubble { max-width: 88%; background: #30393b; color: #f0f1ec; border: 1px solid #505d5c; border-radius: 4px; padding: 10px 14px; }
.bubble small, .query-note, .loading { color: #b2bfb5; }
.correction-note { color: #cbd6be; border-color: var(--line); }
.selection-question { font: 24px/1.3 var(--serif); margin-bottom: 18px !important; }
.start-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.start-actions button, .build-confirm, .inspect-recommendation { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 46px; padding: 10px 16px; border: 1px solid #8e987e; background: transparent; color: #f1f0e7; font-weight: 600; }
.start-actions button { flex: 1 1 130px; }
.start-actions button:first-child, .build-confirm, .inspect-recommendation { background: #cbb77a; border-color: #cbb77a; color: #171d1e; }
.start-actions button:hover:not(:disabled), .build-confirm:hover:not(:disabled), .inspect-recommendation:hover { filter: brightness(1.12); }
.composer { grid-row: 4; border-color: var(--line); background: #171e20; padding-top: 14px; padding-bottom: max(14px,env(safe-area-inset-bottom)); }
.composer input { min-height: 48px; font-size: 15px; }
.composer > button { color: #1b211f; background: #cbb77a; border-color: #cbb77a; }
.composer > button:hover:not(:disabled) { background: #e0cc93; }
.suggestions { background: #222c2b; border-color: #7c8b7e; }
.suggestions button { border-color: var(--line); color: var(--text); min-height: 44px; }
.suggestions button:hover, .suggestions [aria-selected=true] { background: #3b4841; }
.card-choice { background: #27312f; border-color: #52655a; color: var(--text); min-height: 60px; }
.card-choice:hover { background: #35443b; }
.card-recommendation { max-width: 570px; }
.recommendation-summary { display: grid; grid-template-columns: 112px minmax(0,1fr); align-items: center; gap: 20px; }
.recommendation-art-button { background: none; border: 0; padding: 0; border-radius: 6px; }
.recommendation-art { width: 112px; height: auto; aspect-ratio: 488/680; object-fit: contain; border-radius: 6px; box-shadow: 0 8px 18px #0006; }
.recommendation-heading { min-width: 0; }
.recommendation-context { color: #b3c0b8; font-size: 12px; margin-bottom: 8px !important; overflow-wrap: anywhere; }
.recommendation-heading h3 { margin: 0 0 12px; font: 25px/1.15 var(--serif); overflow-wrap: anywhere; }
.recommendation-price { color: #e0cc93; font: 28px/1.1 var(--serif); margin-bottom: 8px !important; }
.recommendation-price span { font: 11px "Segoe UI",sans-serif; margin-left: 7px; color: #bcc5bb; }
.recommendation-limit { color: #a9c6b4; font-size: 12px; line-height: 1.5; margin: 0 !important; }
.recommendation-fit { margin: 24px 0 20px; }
.recommendation-fit > span { display: block; color: #afc7b8; font-size: 12px; margin-bottom: 6px; }
.recommendation-fit p { font-size: 16px; line-height: 1.6; }
.inspect-recommendation { width: 100%; }
.recommendation-evidence { margin-top: 18px; font-size: 13px; line-height: 1.65; color: #c9d0ca; }
.recommendation-evidence summary { min-height: 44px; display: list-item; padding: 10px 0; cursor: pointer; border-bottom: 1px solid var(--line); }
.recommendation-evidence h4 { font-size: 13px; margin: 18px 0 8px; color: var(--text); }
.recommendation-evidence ul { padding-left: 18px; }
.recommendation-facts { display: grid; gap: 12px; padding-top: 14px; }
.recommendation-facts dt { font-size: 11px; }
.recommendation-facts dd { margin-top: 3px; }
.editor-dialog { max-height: min(88dvh,calc(var(--app-height,100dvh) - 24px)); }
body:not([data-has-result]) .inspector > :not(.selected-card-panel), body:not([data-has-result]) .card-options { display: none; }
body[data-result-kind='single_card'] #curve { display: none; }
@media(max-width: 999px) {
  body { overflow: hidden; }
  .masthead { height: 64px; padding: 0 16px; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 26px; margin: 0; }
  .brand p { display: none; }
  .brand-mark { width: 22px; height: 32px; }
  .masthead-art { opacity: .35; }
  .masthead-controls .sign-out-button { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .sign-out-button > span:last-child { display: none; }
  .workspace-tabs { height: 44px; background: #171d1f; }
  .workspace-tabs button { min-height: 44px; padding: 8px; font-size: 14px; }
  .shell { display: block; height: calc(var(--app-height,100dvh) - 108px); min-height: 0; }
  .chat-panel { height: 100%; }
  .chat-top { display: block; padding: 20px 16px; }
  .chat-top h2 { font-size: 32px; max-width: 300px; }
  .has-selection .chat-top h2 { font-size: 24px; }
  .workshop-heading { justify-content: space-between; }
  .selectors { margin-top: 20px; display: grid; grid-template-columns: minmax(0,1fr) 124px; width: 100%; }
  .selectors select, .selectors input { width: 100%; }
  .selectors label { font-size: 12px; }
  .chat-panel input, .chat-panel select { font-size: 16px; }
  .messages { padding: 20px 16px; gap: 22px; }
  .commander-gallery { gap: 10px; }
  .commander-choice span { font-size: 16px; margin-top: 12px; }
  .commander-choice small { font-size: 11px; }
  .bubble { font-size: 15px; }
  .composer { padding-left: 16px; padding-right: 16px; grid-template-columns: minmax(0,1fr) 48px; }
  .composer:has(#cancelRequest:not([hidden])) { grid-template-columns: minmax(0,1fr) 44px 36px; }
  .composer input { font-size: 16px; }
  .rail { position: absolute; top: 10px; right: 72px; width: 44px; height: 44px; overflow: visible; padding: 0; border: 0; z-index: 12; background: transparent; }
  .library-drawer summary { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid #59645b; border-radius: 4px; background: #202927; color: #d6c88d; }
  .library-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .library-content { position: absolute; right: -56px; top: 56px; width: min(400px,calc(100vw - 32px)); max-height: min(70dvh,calc(var(--app-height,100dvh) - 100px)); overflow: auto; padding: 12px 0; border: 1px solid #68746a; background: #1d2725; box-shadow: 0 14px 28px #0007; }
  .library-drawer .art-credit { margin-top: 18px; font-size: 12px; }
  .inspector { height: 100%; min-height: 0; overflow: auto; }
  body[data-view='card'] .hero-card { display: flex; flex-direction: column; align-items: stretch; }
  body[data-view='card'] .card-art, body[data-view='card'] .card-art-placeholder { width: min(280px,100%); margin: 0 auto 12px; }
  body[data-view='card'] .hero-card h2 { font-size: 26px; }
  .card-evidence { font-size: 15px; line-height: 1.7; }
  .card-evidence summary { min-height: 44px; }
  .card-options { font-size: 13px; }
  .card-options button { min-height: 44px; }
}
