:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: #f3f5f7;
  color: #18222d;
}

* { box-sizing: border-box; }
body { margin: 0; }
.shell { width: min(1500px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 28px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 2px; font-size: 1.45rem; }
.app-header { margin-bottom: 12px; }
.app-header p { margin-bottom: 0; color: #687786; font-size: .88rem; }
.panel { background: #fff; border: 1px solid #d9e0e7; border-radius: 10px; box-shadow: 0 5px 20px #172b4d0d; }
.workspace { display: grid; grid-template-columns: 245px minmax(460px, 1fr) 245px; gap: 14px; align-items: start; }
.left-panel, .right-panel { display: grid; gap: 12px; }
.tool-panel, .background-panel { display: grid; gap: 10px; padding: 13px; }
.tool-panel h2, .background-panel h2 { margin: 0; font-size: .76rem; letter-spacing: .12em; color: #607080; }
.source-panel { gap: 9px; }
label { display: grid; gap: 5px; font-size: .82rem; font-weight: 650; }
input[type="file"], input[type="url"] { width: 100%; min-width: 0; padding: 7px; border: 1px solid #c9d2dc; border-radius: 7px; background: #fff; font: inherit; font-size: .78rem; }
input[type="file"] { padding: 5px; }
button { border: 0; border-radius: 7px; padding: 8px 10px; cursor: pointer; background: #165dce; color: #fff; font-size: .78rem; font-weight: 700; }
button:disabled { opacity: .45; cursor: not-allowed; }
.tool-row, .zoom-row, .background-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tool-row button { flex: 1 1 auto; }
.tool { background: #637386; }
.tool.active { background: #165dce; }
.tool-hint { margin: 0; color: #687786; font-size: .72rem; line-height: 1.35; }
.toggle { display: flex; align-items: center; gap: 7px; }
.toggle input { width: 16px; height: 16px; margin: 0; }
.toggle strong { color: #087443; }
.range-row { display: grid; gap: 4px; }
.range-row label { display: flex; justify-content: space-between; gap: 6px; font-size: .78rem; }
.range-row output { color: #607080; font-weight: 500; }
input[type="range"] { width: 100%; accent-color: #165dce; }
.zoom-row { font-size: .8rem; }
.zoom-row span { margin-right: auto; }
.zoom-row button { padding: 6px 9px; }
.download-panel button { width: 100%; }
.center-panel { min-width: 0; }
.status { min-height: 2.25em; margin: 0 0 8px; color: #405163; white-space: pre-wrap; font-size: .8rem; }
.center-view { padding: 10px; }
.editor-viewport { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; height: min(78vh, 760px); min-height: 420px; touch-action: none; background: #eef2f5; }
.editor-stage { position: relative; flex: 0 0 auto; width: 100%; height: 100%; aspect-ratio: 2 / 3; transform-origin: center center; background: repeating-conic-gradient(#e2e6ea 0 25%, #f8fafb 0 50%) 0 / 18px 18px; }
.editor-stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: 100%; max-height: none; object-fit: fill; background: repeating-conic-gradient(#e2e6ea 0 25%, #f8fafb 0 50%) 0 / 18px 18px; }
#composition-view { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: #dae4ef; }
#brush-cursor { position: absolute; display: none; pointer-events: none; border: 2px solid #165dce; border-radius: 50%; box-shadow: 0 0 0 1px #fff; transform: translate(-50%, -50%); z-index: 2; }
.background-label { margin: 0; padding: 8px; border-radius: 7px; background: #f4f7fa; color: #405163; font-size: .82rem; }
.background-section-label { margin: 0; color: #607080; font-size: .73rem; font-weight: 700; }
.trobo-backgrounds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.trobo-background-option { min-width: 0; padding: 3px; border: 2px solid transparent; border-radius: 7px; background: #f4f7fa; color: #405163; }
.trobo-background-option:hover, .trobo-background-option.selected { border-color: #165dce; }
.trobo-background-option img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; }
.trobo-background-option span { display: block; overflow: hidden; margin-top: 3px; font-size: .61rem; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.background-actions { align-items: stretch; }
.background-actions > button, .file-button { flex: 1 1 0; }
.file-button { display: block; padding: 8px 10px; border-radius: 7px; background: #165dce; color: #fff; text-align: center; cursor: pointer; font-size: .78rem; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.url-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.light-wrap-toggle { margin-top: 3px; padding-top: 10px; border-top: 1px solid #e4e9ee; }
.note { margin: 8px 0 0; color: #687786; font-size: .76rem; }
#render-cache { display: none; }
@media (max-width: 1050px) {
  .workspace { grid-template-columns: 220px minmax(380px, 1fr) 220px; gap: 10px; }
  .shell { width: min(100% - 18px, 1100px); }
}
@media (max-width: 780px) {
  .workspace { grid-template-columns: 1fr; }
  .center-panel { grid-row: 1; }
  .left-panel, .right-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-panel, .download-panel, .background-panel { grid-column: 1 / -1; }
  .editor-viewport { height: 68vh; min-height: 320px; }
}
