/* Approved Pencil system. Load after feature styles; shared rules live here. */
:root {
  --font-ui: 'Funnel Sans', system-ui, sans-serif;
  --font-title: var(--font-ui);
  --font-data: var(--font-ui);
  --table: #f2eee5;
  --paper: #fffcf6;
  --ink: #20271f;
  --muted: #63685f;
  --line: #d9d3c6;
  --deep: #263a30;
  --grass: #f0c74b;
  --lilac: #9b83d8;
  --control: #f2eee5;
  --accent: #d9684a;
  --shadow: 0 6px 24px #20271f12;
  --radius: 7px;
}
html { scrollbar-color: #b5b4a8 var(--paper); }
body { font: 400 16px/1.5 var(--font-ui); font-synthesis: none; color: var(--ink); background: var(--table); }
html body { height: 100dvh; min-height: 580px; display: flex; flex-direction: column; }
html body>header,html body>footer,html body>#studio-toolbar { flex: none; }
html body>.workspace { flex: 1; height: auto; min-height: 280px; }
body .scene text,body #brick-preview text { font-family: var(--font-ui); }
button,input,select,textarea { font-family: var(--font-ui); font-size: 14px; line-height: 1.4; }
button,summary { -webkit-tap-highlight-color: transparent; }
button { font-weight: 600; letter-spacing: 0; }
strong,b { font-weight: 600; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible { outline: 2px solid var(--deep); outline-offset: 4px; }
body h1,body h2,body h3 { font-family: var(--font-title); font-weight: 500; font-style: normal; letter-spacing: -.02em; text-wrap: balance; }
body h1 { font-size: 44px; line-height: 1.1; }
body h2 { font-size: 34px; line-height: 1.15; }
body h3 { font-size: 24px; line-height: 1.2; }
body .eyebrow { font: 600 12px/1.4 var(--font-ui); letter-spacing: .06em; color: var(--muted); }
body .text-button { font: 500 14px/1.4 var(--font-ui); min-height: 44px; }
body .primary { border-radius: var(--radius); background: var(--deep); font: 600 14px/1.4 var(--font-ui); letter-spacing: 0; min-height: 44px; padding: 12px 18px; box-shadow: none; }
body .primary:hover { background: #344d40; }
body .secondary,body .google-button { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); font: 600 14px/1.4 var(--font-ui); color: var(--ink); min-height: 44px; padding: 12px 18px; }
body .secondary:hover,body .google-button:hover { background: var(--control); }
body header { height: 72px; min-height: 72px; padding: 0 24px; gap: 20px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: nowrap; }
body .header-left { min-width: 0; gap: 16px; }
body .brand { gap: 10px; font: 600 20px/1.2 var(--font-title); letter-spacing: -.02em; white-space: nowrap; }
body .brand-icon { width: 36px; height: 36px; border-radius: 5px; padding: 8px; gap: 5px; background: var(--accent); transform: none; box-shadow: none; flex: none; }
body .brand-icon i { width: 7px; height: 7px; background: var(--paper); box-shadow: none; }
body .tagline { margin: 0 8px; font: 400 12px/1.4 var(--font-ui); }
body #why { margin: 0; padding: 8px; }
body .header-actions { flex-wrap: nowrap; gap: 14px; }
body .header-actions .text-button { white-space: nowrap; font-size: 14px; }
body .account { border: 0; border-radius: var(--radius); background: var(--deep); color: var(--paper); font: 600 14px/1.4 var(--font-ui); padding: 10px 16px; min-height: 44px; max-width: 160px; }
body #account-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body .balance-button { background: var(--control); color: var(--ink); border-color: var(--line); border-radius: var(--radius); }
body .balance-button span { font: 500 12px/1.2 var(--font-ui); }
body .balance-button strong { font: 500 12px/1.4 var(--font-data); }
body .workspace { height: calc(100dvh - 104px); min-height: 520px; }
body .world { background: var(--table); }
body .world-title { left: 28px; top: 28px; font: 500 34px/1.1 var(--font-title); letter-spacing: -.02em; }
body .world-title em { color: var(--ink); font-style: normal; }
body .world-tag { top: 24px; right: 24px; font: 400 12px/1.4 var(--font-ui); color: var(--muted); }
body .dot { background: #527858; width: 6px; height: 6px; }
body .world-location { top: 54px; right: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); font-size: 14px; }
body .world-location button { min-height: 44px; font-family: var(--font-ui); font-weight: 500; }
body #camera-coordinate { font: 400 12px/1.4 var(--font-data); }
body .world-bottom { left: 24px; right: 24px; bottom: 20px; }
body .world-note { border: 0; padding: 0; background: transparent; box-shadow: none; }
body .world-note strong,body .world-note span { font: 400 12px/1.4 var(--font-ui); color: var(--muted); letter-spacing: 0; }
body .world-note strong { color: var(--ink); }
body .zoom { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; box-shadow: none; }
body .zoom button { min-height: 40px; min-width: 40px; background: transparent; border-radius: 5px; }
body .zoom #explore-mode { font: 500 12px/1.4 var(--font-ui); }
body .zoom #zoom-value,body .zoom .bearing { font: 400 12px/1.4 var(--font-data); }
body .build-dock { bottom: 20px; }
body .build-choices { background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 7px; gap: 7px; box-shadow: var(--shadow); }
body #start-building { min-width: 176px; min-height: 48px; padding: 12px 18px; border-radius: var(--radius); background: var(--accent); color: #20271f; box-shadow: none; font: 600 14px/1.4 var(--font-ui); }
body #start-building:hover { background: #df7b5f; }
body .area-choice { border-color: var(--line); border-radius: var(--radius); background: var(--paper); min-height: 48px; padding: 8px 14px; font: 600 14px/1.4 var(--font-ui); }
body .area-choice small { font: 400 12px/1.4 var(--font-ui); color: var(--muted); }
body .hint { background: var(--table); color: var(--muted); font: 400 12px/1.4 var(--font-ui); letter-spacing: 0; }
body .preview-bar { background: var(--table); border-color: var(--line); color: var(--muted); font: 400 12px/1.4 var(--font-ui); letter-spacing: 0; min-height: 32px; }
body .preview-bar strong { font: 600 12px/1.4 var(--font-ui); }
body .toast { font: 400 14px/1.5 var(--font-ui); border-radius: var(--radius); }

/* One set of text roles across all dialogs and feature modules. */
body dialog,body #piece-info { background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 70px #20271f26; padding: 32px; max-height: calc(100dvh - 40px); overflow: auto; }
body dialog::backdrop { background: #20271f42; backdrop-filter: none; }
body dialog h2,body .engagement-dialog h2,body #rankings-dialog h2,body #help h2,body #why-dialog h2 { font: 500 34px/1.15 var(--font-title); letter-spacing: -.02em; margin: 8px 36px 16px 0; }
body dialog h3,body .engagement-dialog h3,body .help-steps h3 { font: 500 24px/1.2 var(--font-title); letter-spacing: -.02em; }
body dialog p,body dialog li,body .engagement-dialog p,body #why-dialog p,body #help p { font: 400 16px/1.5 var(--font-ui); color: var(--muted); }
body dialog small,body dialog .small-note,body dialog .editor-note,body dialog .image-status,body dialog .side-image-note,body dialog .area-small,body dialog .rankings-note,body dialog .my-piece-edit-note,body .preference-row small { font: 400 14px/1.5 var(--font-ui); color: var(--muted); }
body dialog button,body dialog .secondary,body dialog .text-button,body .engagement-dialog button { font-family: var(--font-ui); font-size: 14px; font-weight: 600; line-height: 1.4; min-height: 44px; }
body dialog .dialog-close,body .account-close { float: right; width: 44px; height: 44px; min-width: 44px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); font: 400 24px/1 var(--font-ui); }
body #close-why,body #close-rankings,body #dismiss-help { margin: -8px -8px 0 12px; }
body dialog label,body .community-dialog label,body .my-pieces-dialog label { font: 500 14px/1.4 var(--font-ui); }
body dialog input:not([type=checkbox]):not([type=range]):not([type=color]):not([type=file]),body dialog select,body dialog textarea { font: 400 16px/1.4 var(--font-ui); min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); padding: 10px 12px; }
body dialog :is(input[type=checkbox],input[type=range]) { accent-color: var(--deep); }
body dialog .eyebrow { margin-bottom: 12px; }
body .receipt,body .demo-message,body #checkout-stack-rule,body .draft-dock { background: var(--control); border-color: var(--line); border-radius: var(--radius); }
body .receipt strong,body #shape-price,body .price,body .ranking-position,body .ranking-count,body .balance-breakdown dd,body .pack-balance strong,body .area-timer strong,body .my-piece-coordinates,body #share-coordinate,body #piece-coordinates,body .color-value,body .corner-control output,body .preference-volume output { font-family: var(--font-data); font-weight: 500; font-variant-numeric: tabular-nums; }
body .receipt strong { font-size: 20px; }
body .balance-breakdown { background: var(--control); border-color: var(--line); border-radius: var(--radius); padding: 16px; gap: 16px; }
body .balance-breakdown dt { font: 400 14px/1.4 var(--font-ui); }
body .balance-breakdown dd { font-size: 18px; }
body .balance-breakdown .covered dd { color: var(--deep); }
body .balance-breakdown .amount-due dd { font-weight: 600; }
body .balance-breakdown .balance-after dd,body .balance-breakdown>p { font-size: 14px; }
body .balance-breakdown>p { font-family: var(--font-ui); }

/* Piece editor: detailed placement behavior is managed by design-shell. */
body .builder-dialog .builder { background: var(--paper); padding: 24px; }
body .builder-dialog h2 { font: 500 24px/1.2 var(--font-title); letter-spacing: -.02em; }
body .builder-dialog .sub,body .builder-dialog .shape-footer p { font: 400 14px/1.5 var(--font-ui); }
body .builder-dialog .brick-preview { background: var(--control); border-radius: var(--radius); box-shadow: none; }
body .builder-dialog .control-heading,body .builder-dialog .stud-toggle,body .builder-dialog summary { font: 600 14px/1.4 var(--font-ui); }
body .builder-dialog .piece-option { background: var(--paper); border-color: var(--line); border-radius: var(--radius); }
body .builder-dialog .piece-option[aria-pressed=true],body .side-tabs button[aria-pressed=true] { background: var(--deep); color: var(--paper); border-color: var(--deep); }
body .builder-dialog .piece-option span,body .builder-dialog .brick-type,body .builder-dialog .range-ends { font: 400 12px/1.4 var(--font-ui); }
body .builder-dialog .swatch { border-color: var(--paper); width: 30px; height: 30px; min-width: 30px; min-height: 30px; }
body .builder-dialog .swatches { flex-wrap: wrap; gap: 12px; }
body .builder-dialog #hex { font: 400 14px/1.4 var(--font-data); width: 110px; }
body .builder-dialog .side-tabs button { font: 500 12px/1.4 var(--font-ui); }
body .texture-templates { grid-template-columns: repeat(3,minmax(0,1fr)); }
body .texture-templates button { background: var(--paper); border-color: var(--line); border-radius: var(--radius); }
body .texture-templates button span { font: 400 12px/1.4 var(--font-ui); }
body .more-options { border-color: var(--line); }
body .more-options summary span { font: 400 12px/1.4 var(--font-ui); }
body .texture-options { border-block: 1px solid var(--line); margin: 18px 0; }
body .texture-options summary { cursor: pointer; min-height: 44px; padding: 12px 0; font: 600 14px/1.4 var(--font-ui); }
body .texture-options .side-images { margin: 0; padding-top: 12px; border: 0; }

/* Welcome keeps the actual canvas behind it, rather than a decorative sample. */
body #why-dialog { width: min(760px,calc(100% - 32px)); padding: 44px; }
body #why-dialog h2 { font-size: 44px; line-height: 1.1; }
body #why-title em { font-style: normal; color: var(--ink); }
body #why-dialog .why-lead { font: 400 18px/1.5 var(--font-ui); color: var(--ink); max-width: 56ch; }
body #why-dialog .why-invitation { border-color: var(--line); }
body .why-actions { gap: 12px; flex-wrap: wrap; }
body .why-actions .primary { min-width: 0; justify-content: center; }
body .why-actions a { text-decoration: none; }
body .welcome-steps { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 24px; margin: 28px 0; padding: 24px 0; border-block: 1px solid var(--line); }
body .welcome-steps h3 { font-size: 24px; margin: 0 0 8px; }
body #why-dialog .welcome-steps p { font-size: 14px; margin: 0; }
body #why-dialog .welcome-note { margin: 16px 0 0; font-size: 14px; }
body #help { width: min(760px,calc(100% - 32px)); }
body .help-step-number { font: 500 18px/1.4 var(--font-data); }
body .help-details summary { font: 600 16px/1.4 var(--font-ui); min-height: 44px; padding-block: 12px; }

/* Rankings, personal collections and reports use the same list rhythm. */
body #rankings-dialog { width: min(760px,calc(100% - 32px)); padding: 32px; }
body #rankings-dialog .rankings-subtitle { font: 400 16px/1.5 var(--font-ui); margin-bottom: 24px; }
body .rankings-columns { color: var(--muted); border-color: var(--line); font: 500 12px/1.4 var(--font-ui); letter-spacing: .04em; }
body #rankings-list li { border-color: var(--line); font: 400 16px/1.5 var(--font-ui); padding: 18px 12px; }
body .ranking-position { font-size: 18px; }
body .ranking-name { font-family: var(--font-ui); font-weight: 600; }
body .ranking-count { font-size: 14px; color: var(--ink); }
body #rankings-status,body #ranking-personal { font: 400 14px/1.5 var(--font-ui); }
body #ranking-personal:not(:empty) { background: #ebe5f4; color: var(--ink); border: 0; border-radius: var(--radius); padding: 14px 16px; }
body .ranking-trophy { width: 26px; height: 28px; }
body #my-pieces-dialog,body #places-dialog,body #moderation-dialog { width: min(760px,calc(100% - 32px)); }
body .my-piece-card,body .place-card,body .moderation-card,body .draft-library-card { border-color: var(--line); padding-block: 20px; }
body .my-piece-preview,body .creation-preview,body .draft-library-picture,body .starter-card { background: var(--control); border-radius: var(--radius); }
body .my-piece-details h3,body .place-card h3 { font: 500 24px/1.2 var(--font-title); }
body .my-piece-details .my-piece-coordinates { font: 400 12px/1.4 var(--font-data); }
body .my-piece-actions { gap: 8px; }
body .my-piece-actions button,body .draft-items button { min-height: 44px; font: 600 14px/1.4 var(--font-ui); border-color: var(--line); border-radius: var(--radius); background: var(--paper); }
body .my-piece-actions button:first-child { background: var(--deep); color: var(--paper); }
body #my-pieces-status,body .my-piece-details .my-piece-edit-note { font: 400 14px/1.5 var(--font-ui); }
body .places-tabs { gap: 8px; flex-wrap: wrap; }
body .places-tabs button { font: 600 14px/1.4 var(--font-ui); border: 1px solid var(--line); background: var(--paper); }
body .places-tabs button[aria-pressed=true] { background: var(--deep); color: var(--paper); border-color: var(--deep); }
body .collection-tabs { display: flex; gap: 8px; padding: 8px 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
body .collection-tabs button { min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; background: var(--paper); font: 600 14px/1.4 var(--font-ui); }
body .collection-tabs button[aria-pressed=true] { background: var(--deep); border-color: var(--deep); color: var(--paper); }
body #rankings-list .ranking-you { background: #ebe5f4; }
body .preference-row { border-bottom: 1px solid var(--line); padding-block: 18px; }
body .preference-row>span { font: 500 16px/1.4 var(--font-ui); }
body .preference-row small { margin-top: 6px; }
body .studio-toolbar h1,body .studio-empty h2 { font: 500 34px/1.1 var(--font-title); letter-spacing: -.02em; }
body .studio-toolbar h1 span,body .studio-empty p,body .studio-toolbar>p { font: 400 14px/1.5 var(--font-ui); }
body .studio-metrics { font: 400 14px/1.5 var(--font-ui); }
body .studio-metrics strong { font: 500 20px/1.3 var(--font-data); }
body .studio-tools button { font: 600 14px/1.4 var(--font-ui); }
body #piece-info h2 { font: 500 24px/1.2 var(--font-title); }
body #piece-info p { font: 400 14px/1.5 var(--font-ui); }
body #piece-info #piece-coordinates { font-family: var(--font-data); font-size: 12px; }

/* The real piece editor is the only customization panel. */
html:not(.studio-page) body>.workspace { display: block; }
html:not(.studio-page) body>.workspace>.world { min-width: 0; height: 100%; }

@media(max-width:1200px) {
  body .tagline { display: none; }
  body header { gap: 12px; padding-inline: 18px; }
  body .header-actions { gap: 10px; }
  body .header-left { gap: 8px; }
  body .world-note { max-width: 180px; }
  body .world-title { font-size: 28px; }
  html:not(.studio-page) body .world .build-dock { bottom: 88px; }
}
@media(max-width:960px) {
  body header { height: auto; min-height: 72px; flex-wrap: wrap; padding-block: 10px; }
  body .header-actions { flex-wrap: wrap; width: auto; }
  body #how { display: none; }
  body .workspace { height: calc(100dvh - 128px); }
  body .world-title { top: 20px; left: 20px; font-size: 24px; }
  body .world-tag { display: none; }
  body .world-location { top: 20px; right: 20px; }
  html:not(.studio-page) body>.workspace { display: block; }
  html:not(.studio-page) body>.workspace>.world { height: 100%; }
}
@media(min-width:701px) and (max-width:1150px) {
  body header { height: auto; flex-wrap: wrap; padding-block: 10px; }
  body .header-actions { flex-wrap: wrap; }
}
@media(max-width:700px) {
  body header { padding: 8px 16px; gap: 4px 12px; }
  body .header-left { flex: 1; justify-content: space-between; }
  body .brand { font-size: 20px; }
  body .brand-icon { width: 30px; height: 30px; padding: 6px; gap: 4px; }
  body .header-actions { width: 100%; justify-content: flex-start; gap: 4px 12px; }
  body .header-actions .text-button { font-size: 14px; }
  body #my-bricks { max-width: none; }
  body .account { margin-left: auto; padding: 8px 12px; }
  body .balance-button { margin-left: auto; }
  body .balance-button:not([hidden])~.account { margin-left: 0; }
  body .world-title { font-size: 24px; top: 18px; left: 16px; }
  body .world-location { top: 86px; left: 16px; right: auto; max-width: calc(100% - 32px); }
  body .world-location button { padding: 8px; }
  body #camera-coordinate { font-size: 11px; }
  body .world-note { display: none; }
  body .world-bottom { justify-content: center; left: 8px; right: 8px; bottom: 10px; }
  body .world .build-dock { bottom: 76px; width: calc(100% - 24px); max-width: 440px; }
  body .build-choices { width: 100%; }
  body #start-building { min-width: 0; flex: 1; padding: 10px 12px; }
  body .area-choice { min-width: 0; flex: 1; padding: 8px 10px; }
  body .hint { display: none; }
  body .world .zoom button { min-width: 40px; min-height: 44px; }
  body .world .zoom #explore-mode { min-width: 90px; }
  body dialog,body #rankings-dialog,body #why-dialog,body #help { padding: 24px; width: calc(100% - 24px); max-height: calc(100dvh - 24px); }
  body dialog h2,body .engagement-dialog h2,body #rankings-dialog h2,body #help h2,body #why-dialog h2 { font-size: 34px; line-height: 1.1; }
  body .welcome-steps { grid-template-columns: 1fr; gap: 20px; margin-block: 24px; }
  body .why-actions { align-items: stretch; }
  body .why-actions .primary,body .why-actions .secondary { width: 100%; }
  body .rankings-columns,body #rankings-list li { grid-template-columns: 40px minmax(0,1fr) 65px; gap: 8px; }
  body .my-piece-actions button { padding: 8px 10px; }
  body .studio-toolbar h1 { font-size: 28px; }
  body .studio-tools button { font-size: 14px; }
  body .studio-metrics strong { font-size: 18px; }
  body .studio-metrics { max-width: 190px; font-size: 12px; }
  body .studio-page .studio-toolbar { padding: 12px 16px; }
}
@media(prefers-reduced-motion:reduce) { body *,body *::before,body *::after { scroll-behavior: auto; } }
