:root {
  color-scheme: light;
  --ink: #354538;
  --muted: #59665a;
  --accent: #48624c;
  --line: #d9ded3;
  --paper: #faf9f3;
  --mat: #e9ece3;
  --rose: #b98775;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #f5f5ee;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input, select, textarea { font: inherit; }
button, select, input, textarea { color: var(--ink); }
button {
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
  color: var(--ink); padding: 9px 12px; cursor: pointer; min-height: 38px;
  transition: background .15s, transform .15s;
}
button:hover:not(:disabled) { background: #e4e9dd; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #8ea987; outline-offset: 3px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #354d3a; }
button[aria-pressed="true"] { background: #e1e7d9; border-color: #81967b; }
a { color: var(--accent); text-underline-offset: 3px; }
[hidden] { display: none !important; }

.app-header { display: flex; align-items: center; gap: 25px; padding: 17px 4%; border-bottom: 1px solid var(--line); background: var(--paper); }
.brand { font: 29px Georgia, serif; color: var(--ink); text-decoration: none; letter-spacing: -1px; white-space: nowrap; }
.brand em { font-style: normal; color: var(--rose); }
.edition { font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.review-link { margin-left: auto; font-size: 12px; white-space: nowrap; }
.app-header .primary { white-space: nowrap; }
main { max-width: 1500px; margin: auto; padding: 27px 4% 20px; min-width: 0; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 23px; }
.intro-copy { min-width: 0; }
.runtime-note { max-width: 450px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.eyebrow { font-size: 10px; font-weight: 500; letter-spacing: 1.8px; margin: 0 0 8px; color: var(--muted); }
h1 { font: 32px/1.15 Georgia, serif; margin: 0; letter-spacing: -.6px; }
h2 { font: 21px Georgia, serif; margin: 0; }
h3 { font: 17px Georgia, serif; margin: 0; }
.model-status { font-size: 12px; color: var(--muted); max-width: 260px; text-align: right; line-height: 1.45; }
.model-status:before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #b7a275; margin-right: 7px; }
.model-status.ready:before { background: #729767; }
.model-status.error:before { background: #ba7058; }
.connection-tools { display: flex; align-items: center; gap: 10px; min-width: 0; }
.connection-tools button { font-size: 12px; }
#model-progress { width: 92px; height: 8px; accent-color: var(--accent); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 26px; align-items: start; min-width: 0; }
.magazine-panel, .collage-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; min-width: 0; }
.section-header { display: flex; justify-content: space-between; align-items: center; padding: 19px 20px; gap: 15px; min-width: 0; }
.section-header button { font-size: 12px; }
.canvas-heading { align-items: flex-start; }
.format-control { display: grid; gap: 5px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.format-control select, .note-options select, .feedback-grid select, #material-filter {
  border: 1px solid var(--line); border-radius: 7px; background: var(--paper); padding: 8px 28px 8px 9px; max-width: 100%; min-height: 38px;
}
.format-control small { font-size: 9px; color: var(--muted); }
.source-bar { display: flex; align-items: center; gap: 8px; padding: 0 20px 14px; flex-wrap: wrap; }
.source-bar label { font-size: 11px; color: var(--muted); }
#sample-filter-wrap { display: flex; align-items: center; gap: 6px; width: auto; white-space: nowrap; }
#sample-filter { min-height: 32px; padding: 5px 22px 5px 7px; font-size: 11px; }
.source-bar select { flex: 1; min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 8px; background: var(--paper); font-size: 12px; }
.source-bar button { padding: 5px 10px; min-height: 32px; }
.source-bar #page-number { font-size: 11px; color: var(--muted); white-space: nowrap; }
.page-mat { background: var(--mat); padding: 20px 40px; min-height: 390px; display: flex; align-items: center; justify-content: center; }
.page { position: relative; width: 100%; max-width: 420px; line-height: 0; box-shadow: 0 7px 18px #2f402524; touch-action: manipulation; }
.page > img#page-image { display: block; width: 100%; height: auto; min-height: 120px; transition: opacity .2s; cursor: crosshair; }
.page.has-selection #page-image { opacity: .72; }
.page#page .lift-preview { position: absolute; z-index: 3; transform: translateY(-5px) rotate(-1deg); transform-origin: center; filter: drop-shadow(0 6px 4px #2c3d2c66); cursor: grab; touch-action: none; transition: transform .18s; user-select: none; }
.page#page .lift-preview:active { cursor: grabbing; }
.point { position: absolute; z-index: 5; display: grid; place-items: center; width: 18px; height: 18px; transform: translate(-50%,-50%); border: 2px solid #fff; border-radius: 50%; background: #48664c; color: #fff; font: 12px Arial, sans-serif; pointer-events: none; box-shadow: 0 1px 4px #0005; }
.point.exclude { background: #a85140; }
.page-loading { position: absolute; inset: 0; background: #f5f4ead9; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; font-size: 13px; line-height: 1.5; z-index: 10; }
.page-loading progress { width: min(220px, 72%); height: 8px; accent-color: var(--accent); }
.spinner { width: 24px; height: 24px; border: 2px solid #c3cfbc; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.selection-tools { padding: 14px 16px 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.selection-tools button { font-size: 12px; padding: 7px 10px; }
.selection-result { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 8px 16px 16px; }
.selection-result > span { flex: 1; min-width: 150px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.selection-result > .primary { font-size: 12px; }
.selection-result #alternatives { display: flex; gap: 4px; flex-wrap: wrap; }
.selection-result #alternatives button { padding: 5px 8px; min-height: 28px; font-size: 11px; }
.source-credit { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 10px; color: var(--muted); line-height: 1.5; }
.source-credit a { font-size: 11px; }
.source-links { display: flex; gap: 12px; flex-wrap: wrap; }

.starter-shelf { margin: 0 13px 8px; border: 1px solid #e3e5db; border-radius: 10px; background: #f8f8f1; padding: 13px; }
.starter-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.starter-heading .eyebrow { margin-bottom: 5px; }
.starter-heading button { min-height: 34px; padding: 6px 9px; font-size: 11px; white-space: nowrap; }
.starter-intro { margin: 9px 0 12px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.starter-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.starter-card { min-width: 0; padding: 7px; text-align: left; background: #fffdf8; border-color: #e0e2d8; min-height: 0; }
.starter-card:hover:not(:disabled) { transform: translateY(-2px); }
.starter-card canvas { display: block; width: 100%; aspect-ratio: 1.35; object-fit: contain; border-radius: 4px; background: #eee8d9; margin-bottom: 7px; }
.starter-card strong { display: block; font: 13px Georgia, serif; line-height: 1.25; }
.starter-card small { display: block; color: var(--muted); font-size: 10px; line-height: 1.35; margin-top: 3px; }
.paper-colors { display: flex; align-items: center; gap: 9px; padding: 5px 20px 14px; }
.paper-colors span { color: var(--muted); font-size: 11px; margin-right: 6px; }
.paper-colors button { width: 25px; height: 25px; min-height: 25px; padding: 0; border-radius: 50%; background: var(--swatch); }
.paper-colors button:hover:not(:disabled) { background: var(--swatch); transform: scale(1.1); }
.paper-colors button[aria-pressed="true"] { outline: 1px solid var(--accent); outline-offset: 3px; border-color: transparent; }
.board-mat { padding: 24px; background: var(--mat); }
.board { width: 100%; aspect-ratio: 1 / 1; background: #efe7d5; position: relative; overflow: hidden; box-shadow: 0 7px 18px #2f402520; isolation: isolate; }
.board:before { position: absolute; content: ''; inset: 0; z-index: -1; pointer-events: none; opacity: .35; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%2390826b' opacity='.15' filter='url(%23n)' d='M0 0h120v120H0z'/%3E%3C/svg%3E"); }
#board-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; color: #77806c; text-align: center; pointer-events: none; }
.empty-mark { font: 43px Georgia, serif; opacity: .55; }
#board-empty p { font: 21px Georgia, serif; margin: 16px 0 9px; }
#board-empty span:last-child { font-size: 12px; line-height: 1.7; }
.piece { position: absolute; display: block; border: 0; border-radius: 0; padding: 0; min-height: 0; background: transparent !important; touch-action: none; cursor: grab; transform-origin: center; }
.piece:active { cursor: grabbing; }
.piece img { display: block; width: 100%; pointer-events: none; filter: drop-shadow(1px 4px 2px #453b343b); user-select: none; }
.piece[aria-pressed="true"] { outline: 1px dashed #536b4d; outline-offset: 5px; }
.piece:focus-visible { outline: 2px solid #536b4d; }
.canvas-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 13px 17px 5px; }
.canvas-actions button { font-size: 11px; padding: 7px 10px; min-height: 34px; }
.project-tools { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 12px 17px 12px; }
.project-tools > span { flex-basis: 100%; font-size: 11px; color: var(--muted); line-height: 1.5; }
.project-name-label { font-size: 11px; color: var(--muted); }
#project-title { width: min(210px, 100%); min-width: 100px; height: 36px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fffdf8; }
.project-buttons { display: flex; flex-wrap: wrap; gap: 7px; width: 100%; }
.project-buttons button { font-size: 11px; padding: 7px 9px; min-height: 34px; }
.visually-secondary { background: transparent; }
.studio-tools, .layer-details { border-top: 1px solid #e7e9e0; padding: 0 17px; }
.studio-tools summary, .layer-details summary { padding: 12px 0; color: var(--accent); font-size: 12px; cursor: pointer; }
.digital-tools { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 0 0 7px; }
.digital-tools span { flex-basis: 100%; font-size: 10px; color: var(--muted); }
.digital-tools button { font-size: 11px; min-height: 34px; padding: 7px 9px; }
.provenance-note { margin: 0 0 12px; color: var(--muted); font-size: 10px; line-height: 1.45; }
#layer-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 4px; }
.layer-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.layer-row > button:first-child { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row button { min-height: 34px; padding: 5px 8px; font-size: 10px; }
.layer-row .layer-lock[aria-pressed="true"] { background: #e4e9dd; }
.piece-tools { padding: 5px 17px 13px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; border-top: 1px solid #e7e9e0; }
.piece-tools > span { flex-basis: 100%; font-size: 11px; color: var(--muted); }
.piece-tools button { font-size: 10px; padding: 6px 8px; min-height: 34px; }
.size-control { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.size-control input { width: 95px; accent-color: var(--accent); }
.note-editor { flex-basis: 100%; margin-top: 5px; padding: 11px; border-radius: 9px; background: #f5f5ed; display: grid; gap: 8px; }
.note-editor > label { font: 15px Georgia, serif; }
.note-editor textarea { display: block; width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 7px; padding: 9px; background: #fffdf8; line-height: 1.5; }
.note-options { display: flex; flex-wrap: wrap; gap: 8px; }
.note-options label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.note-apply { justify-self: start; min-height: 36px !important; }
.board-caption { font-size: 11px; color: var(--muted); padding: 0 17px 15px; margin: 0; line-height: 1.5; }
.feedback-prompt { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 0 17px 14px; }
.feedback-prompt span { flex: 1; min-width: 150px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.feedback-prompt button { min-height: 34px; padding: 6px 9px; font-size: 10px; }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; filter: drop-shadow(0 10px 5px #22332666); opacity: .94; }
.error-message { color: #a54c39 !important; }
.privacy-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 18px; padding: 13px 16px; background: #efefe7; border-radius: 10px; }
.privacy-toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.privacy-toggle input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: 0 0 auto; }
.privacy-toggle strong, .privacy-toggle small { display: block; }
.privacy-toggle strong { font-size: 12px; font-weight: 600; }
.privacy-toggle small { margin-top: 4px; max-width: 560px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.privacy-card > a { flex: 0 0 auto; font-size: 11px; }
footer { display: flex; justify-content: space-between; gap: 15px; flex-wrap: wrap; color: var(--muted); font-size: 11px; padding-top: 18px; line-height: 1.5; }
.mobile-nav { display: none; }

.studio-dialog { width: min(720px, calc(100vw - 32px)); max-width: none; max-height: min(84vh, 850px); padding: 0; border: 1px solid #d8ddd2; border-radius: 14px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 80px #26372933; overflow: auto; }
.studio-dialog::backdrop { background: #29352da8; backdrop-filter: blur(2px); }
.dialog-shell { padding: 21px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.dialog-heading .eyebrow { margin-bottom: 7px; }
.icon-button { width: 40px; height: 40px; min-height: 40px; padding: 0; font: 25px/1 Arial,sans-serif; }
.dialog-copy { margin: 10px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dialog-message { color: var(--muted); font-size: 11px; line-height: 1.4; min-height: 1.4em; }
.saved-list { display: grid; gap: 8px; }
.saved-project, .cabinet-item { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 7px; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: #fffdf8; }
.saved-project > div, .cabinet-item > div { min-width: 0; }
.saved-project strong, .saved-project small, .cabinet-item strong, .cabinet-item small { display: block; overflow-wrap: anywhere; }
.saved-project strong, .cabinet-item strong { font: 14px Georgia,serif; }
.cabinet-item img { float: left; width: 44px; height: 44px; object-fit: contain; margin-right: 8px; border-radius: 5px; background: #f1eee4; }
.saved-project small, .cabinet-item small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.saved-project button, .cabinet-item button { font-size: 10px; min-height: 36px; padding: 6px 8px; }
.empty-library { padding: 18px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.filter-label { display: inline-block; margin-right: 7px; color: var(--muted); font-size: 11px; }
.material-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 9px; margin-top: 13px; }
.material-card { min-width: 0; padding: 7px; text-align: left; min-height: 0; }
.material-card img { display: block; width: 100%; height: 95px; object-fit: contain; border-radius: 4px; background: #f1eee4; }
.material-card strong, .material-card small { display: block; overflow-wrap: anywhere; }
.material-card strong { margin-top: 6px; font: 12px Georgia,serif; }
.material-card small { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.feedback-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
.feedback-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-actions button { min-width: 90px; }
.public-build .review-link,
.public-build .privacy-card,
.public-build #feedback-prompt,
.public-build #feedback-dialog { display: none !important; }

@media (max-width: 880px) {
  main { padding: 22px 20px; }
  .workspace { gap: 16px; }
  .section-header { padding: 17px 14px; }
  .section-header h2 { font-size: 19px; }
  .page-mat { padding: 20px 22px; }
  .source-bar { padding: 0 14px 12px; }
  .source-bar label { width: 100%; }
  .board-mat { padding: 20px; }
  .intro h1 { font-size: 27px; }
  .starter-shelf { margin-left: 10px; margin-right: 10px; padding: 10px; }
  .starter-heading { align-items: flex-start; }
}
@media (max-width: 650px) {
  body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .app-header { padding: 13px 14px; gap: 9px; }
  .brand { font-size: 23px; }
  .edition { display: none; }
  .review-link { font-size: 10px; }
  .app-header .primary { padding: 8px 9px; font-size: 11px; }
  main { padding: 18px 12px 14px; }
  .intro { align-items: flex-start; gap: 10px; flex-direction: column; margin-bottom: 15px; }
  .intro h1 { font-size: 29px; }
  .model-status { text-align: left; max-width: none; }
  .connection-tools { flex-wrap: wrap; }
  .workspace { grid-template-columns: minmax(0,1fr); }
  .page-mat { min-height: 0; padding: 17px 25px; }
  .page { max-width: 350px; }
  #sample { flex-basis: 100%; }
  .source-bar select { min-height: 44px; }
  .source-bar button { min-width: 44px; min-height: 44px; }
  .selection-result > span { flex-basis: 100%; }
  .selection-tools button { min-height: 44px; }
  .section-header button, .digital-tools button, .selection-result .primary, .piece-tools button { min-height: 44px; }
  .paper-colors button { width: 34px; height: 34px; min-height: 34px; margin: 3px 4px; }
  .paper-colors { gap: 5px; }
  .piece-tools label { min-height: 44px; }
  .section-header { flex-wrap: wrap; }
  .canvas-heading { align-items: center; }
  .format-control select { min-height: 44px; max-width: 160px; }
  .mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
  .mobile-nav button { flex: 1; min-width: 0; min-height: 46px; padding: 7px; font-size: 12px; }
  .mobile-nav span { font-size: 10px; opacity: .7; margin-left: 3px; }
  .workspace[data-mobile-view="magazine"] .collage-panel, .workspace[data-mobile-view="collage"] .magazine-panel { display: none; }
  .selection-result #alternatives button { min-height: 44px; min-width: 44px; }
  .piece-tools input { width: 115px; }
  .collage-panel, .magazine-panel { scroll-margin-top: 12px; }
  .canvas-actions { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .canvas-actions button { min-height: 44px; }
  .project-tools { padding-left: 12px; padding-right: 12px; }
  .project-buttons button { min-height: 44px; }
  .starter-heading { flex-wrap: wrap; }
  .starter-heading button { min-height: 42px; }
  .starter-cards { grid-template-columns: minmax(0,1fr); }
  .starter-card { display: grid; grid-template-columns: 92px minmax(0,1fr); align-items: center; gap: 3px 10px; min-height: 80px; }
  .starter-card canvas { grid-row: span 2; height: 66px; aspect-ratio: auto; margin: 0; }
  .starter-card strong { align-self: end; font-size: 14px; }
  .starter-card small { align-self: start; }
  .privacy-card { align-items: flex-start; flex-direction: column; gap: 10px; }
  footer { font-size: 10px; }
  .studio-dialog { width: 100%; max-height: min(86dvh, 850px); margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .dialog-shell { padding: 18px 15px calc(18px + env(safe-area-inset-bottom)); }
  .material-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; }
  .material-card img { height: 74px; }
  .saved-project, .cabinet-item { grid-template-columns: minmax(0,1fr) auto; }
  .saved-project button:last-child, .cabinet-item button:last-child { grid-column: 2; }
  .feedback-grid { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 360px) {
  main { padding-left: 9px; padding-right: 9px; }
  .app-header { padding-left: 10px; padding-right: 10px; }
  .brand { font-size: 21px; }
  .review-link { display: none; }
  .app-header .primary { margin-left: auto; }
  .page-mat { padding: 14px 16px; }
  .board-mat { padding: 14px; }
  .format-control select { max-width: 142px; font-size: 11px; }
  .starter-shelf { margin-left: 7px; margin-right: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .spinner { border-top-color: var(--accent); }
}
