:root {
  color-scheme: light;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  color: #2c3329;
  background: #d9e0cc;
  --paper: #fbf9ef;
  --paper-strong: #fffdf5;
  --muted: #5a6356;
  --border: #dddccd;
  --green: #405237;
  --green-deep: #30442d;
  --green-wash: #e4e9d9;
  --shadow: 0 10px 30px #26322223, 0 2px 6px #272c2017;
}
* { box-sizing: border-box; }
body { margin: 0; display: flex; flex-direction: column; height: 100dvh; min-height: 320px; overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; color: inherit; background: none; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, select:focus-visible, input:focus-visible, #viewport:focus-visible { outline: 2px solid #576842; outline-offset: 3px; }
button, select, input { touch-action: manipulation; }
[hidden] { display: none !important; }
.icon-definitions { position: absolute; width: 0; height: 0; pointer-events: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, p { margin: 0; }
.topbar { height: 68px; padding: 0 clamp(14px, 2.2vw, 34px); display: flex; align-items: center; justify-content: space-between; background: var(--paper); z-index: 2; border-bottom: 1px solid var(--border); flex: none; }
.brand, .header-actions, .history { display: flex; align-items: center; }
.brand, .header-actions { gap: 13px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--green); color: #f6f5e6; }
.brand-mark svg { width: 28px; height: 28px; }
.brand h1 { font-family: "DM Serif Text", Georgia, serif; font-weight: 600; font-size: 24px; line-height: 1.05; letter-spacing: -.025em; }
.brand-subtitle { color: var(--muted); font-size: 11px; margin-top: 3px; }
.history { gap: 3px; padding-right: 9px; border-right: 1px solid var(--border); }
.icon-button { display: inline-grid; place-items: center; border-radius: 9px; width: 40px; height: 40px; }
.icon-button:hover:not(:disabled), .tool:hover { background: var(--green-wash); }
.settings-glyph { display: block; width: 21px; height: 21px; object-fit: contain; filter: brightness(0) saturate(100%) invert(23%) sepia(18%) saturate(742%) hue-rotate(64deg); }
#scene-menu-toggle[aria-expanded="true"] { background: var(--green-wash); }
.primary { display: inline-flex; gap: 8px; align-items: center; justify-content: center; border-radius: 10px; min-height: 42px; padding: 0 16px; background: var(--green-deep); color: var(--paper-strong); font-weight: 700; letter-spacing: .005em; }
.primary:hover:not(:disabled) { background: #4d6243; }
.primary svg { width: 19px; height: 19px; }
#editor { flex: 1; min-height: 0; position: relative; isolation: isolate; }
#viewport { display: block; width: 100%; height: 100%; position: absolute; inset: 0; background: #c8d9cc; touch-action: none; outline: 0; }
#viewport[data-tool="decor"], #viewport[data-tool="house"], #viewport[data-tool="terrain"] { cursor: crosshair; }
#viewport[data-tool="erase"] { cursor: cell; }
.surface { background: var(--paper); box-shadow: var(--shadow); border: 1px solid #eae7da; border-radius: 15px; }
.tools { position: absolute; display: grid; gap: 3px; padding: 6px; left: 20px; top: 22px; }
.tool { width: 62px; height: 56px; border-radius: 9px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--green-deep); padding: 4px; }
.tool span { font-size: 11px; line-height: 1.2; font-weight: 650; }
.tool[aria-pressed="true"] { background: var(--green); color: #fffbed; }
.inspector { position: absolute; padding: 18px; top: 22px; right: 20px; width: 275px; max-height: calc(100% - 230px); overflow: auto; scrollbar-color: #a5aa95 transparent; }
.inspector h2, .catalog h2 { font-size: 17px; font-weight: 800; }
.inspector h2 { margin-bottom: 14px; }
.inspector p { font-size: 12px; line-height: 1.55; color: var(--muted); }
.inspector .summary { display: block; margin-top: -8px; margin-bottom: 14px; }
.controls { display: grid; gap: 13px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field--toggle { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.field--toggle input { accent-color: #b7a26a; }
.field-label { font-size: 12px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field-label output { color: var(--green-deep); font-variant-numeric: tabular-nums; }
.segment { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; background: #ebece0; padding: 3px; border-radius: 9px; }
.segment button { font-size: 12px; font-weight: 650; padding: 7px 4px; min-height: 36px; border-radius: 7px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.segment button:hover { background: #f5f4e9; }
.segment button[aria-pressed="true"] { background: var(--paper-strong); color: var(--green-deep); box-shadow: 0 1px 4px #2632222e; }
.segment svg { width: 15px; height: 15px; }
.choices-grid { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
input[type="range"] { accent-color: var(--green); width: 100%; min-height: 24px; margin: 0; cursor: pointer; touch-action: pan-y; }
select { width: 100%; background: var(--paper-strong); color: var(--green-deep); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; padding-right: 20px; }
.catalog { position: absolute; bottom: 37px; left: 20px; width: min(680px, calc(100% - 100px)); padding: 13px 15px 14px; }
.catalog-top { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.catalog h2 { white-space: nowrap; }
.categories { display: flex; gap: 4px; overflow: auto; scrollbar-width: thin; scrollbar-color: #a5aa95 transparent; }
.categories button { flex: none; padding: 5px 10px; border-radius: 999px; color: #495445; font-size: 12px; line-height: 1.4; font-weight: 700; white-space: nowrap; }
.categories button:hover { background: #efeee3; }
.categories button[aria-pressed="true"] { background: var(--green-wash); color: #32452f; }
.asset-list { display: flex; gap: 8px; overflow: auto; padding: 0 1px 2px; scrollbar-width: thin; }
.asset-choice { flex: 0 0 min(114px, 25%); min-width: 70px; display: grid; grid-template-rows: minmax(0, 70px) auto; border-radius: 10px; background: #eeeee2; border: 1px solid transparent; padding: 0 4px 5px; font-size: 11px; font-weight: 700; text-align: center; overflow: hidden; }
.asset-choice:hover { background: #e6e9d8; }
.asset-choice[aria-pressed="true"] { background: #dfe7d2; border-color: #819372; }
.asset-choice img, .asset-placeholder { pointer-events: none; width: 100%; height: 100%; object-fit: contain; }
.asset-placeholder { display: grid; place-items: center; color: #72816b; }
.asset-placeholder svg { width: 29px; height: 29px; }
.view-buttons { display: grid; padding: 4px; position: absolute; bottom: 37px; right: 20px; }
.touch-orbit { display: none; }
.touch-orbit[aria-pressed="true"] { background: var(--green); color: var(--paper); }
.viewport-footer { position: absolute; inset: auto 0 0; min-height: 28px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 21px; color: #fefdf1; font-size: 11px; background: #28382ae0; pointer-events: none; }
.hide-mouse-help .mouse-help { display: none; }
#toast { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); border-radius: 10px; background: #2f432e; color: #fdfbf0; box-shadow: var(--shadow); font-size: 13px; padding: 10px 15px; max-width: min(440px, 80vw); pointer-events: none; }
#loading { position: absolute; inset: 0; display: grid; place-content: center; background: #e6e9dacc; color: var(--green-deep); font-size: 16px; font-weight: 700; padding: 18px; text-align: center; }
.swatch-row { display: flex; align-items: center; justify-content: space-between; }
.small-button { padding: 6px 9px; border-radius: 7px; background: var(--green-wash); color: var(--green-deep); font-size: 12px; font-weight: 700; min-height: 32px; }
.small-button:hover { background: #d4e0cd; }
@media (pointer: coarse) {
  .touch-orbit { display: inline-grid; }
  .mouse-help { display: none; }
}
@media (max-width: 720px) {
  .topbar { height: 57px; padding-inline: 10px; }
  .brand h1 { font-size: 19px; }
  .brand, .header-actions { gap: 8px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  .brand-mark svg { width: 24px; height: 24px; }
  .history { padding-right: 3px; }
  .history .icon-button { width: 33px; min-height: 36px; }
  #scene-menu-toggle { width: 34px; height: 37px; }
  .primary { min-height: 37px; padding-inline: 10px; font-size: 12px; }
  .tools { left: 8px; top: 8px; padding: 4px; }
  .tool { width: 48px; height: 47px; gap: 3px; }
  .tool svg { width: 19px; height: 19px; }
  .tool span { font-size: 10px; }
  .inspector { padding: 11px; top: 8px; right: 8px; width: min(205px, calc(100% - 68px)); max-height: calc(100% - 182px); }
  .inspector h2, .catalog h2 { font-size: 14px; margin-bottom: 8px; }
  .inspector .summary { margin-top: 0; margin-bottom: 8px; }
  .controls { gap: 8px; }
  .catalog { bottom: 34px; left: 8px; width: calc(100% - 60px); padding: 9px; }
  .catalog-top { gap: 7px; margin-bottom: 6px; }
  .catalog-top h2 { margin: 0; }
  .categories button { padding-inline: 7px; font-size: 11px; }
  .asset-choice { flex-basis: 78px; grid-template-rows: 55px auto; }
  .view-buttons { right: 8px; bottom: 34px; padding: 1px; }
  .view-buttons .icon-button { width: 35px; height: 36px; }
  .viewport-footer { padding-inline: 8px; }
  .mouse-help { display: none; }
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 520px) {
  .topbar { height: 50px; padding-inline: 12px; }
  .brand-mark { width: 35px; height: 35px; }
  .brand h1 { font-size: 22px; }
  .tools { left: 8px; top: 7px; padding: 4px; }
  .tool { width: 44px; height: 41px; }
  .tool svg { width: 18px; height: 18px; }
  .tool span { font-size: 10px; }
  .catalog { left: 67px; bottom: 33px; width: calc(100% - 283px); padding: 7px 9px; }
  .catalog-top { margin-bottom: 5px; gap: 8px; }
  .catalog h2 { font-size: 14px; }
  .categories button { font-size: 11px; padding-inline: 7px; }
  .asset-choice { flex-basis: 76px; grid-template-rows: 43px auto; }
  .inspector { top: 7px; right: 8px; width: 200px; padding: 11px; max-height: calc(100% - 81px); }
  .inspector h2 { font-size: 14px; margin-bottom: 9px; }
  .inspector .summary { margin-top: -3px; margin-bottom: 9px; }
  .controls { gap: 8px; }
  .view-buttons { display: flex; justify-content: space-between; width: 200px; right: 8px; bottom: 33px; padding: 3px; }
  .view-buttons .icon-button { width: 40px; height: 32px; }
}
