:root {
  color-scheme: dark;
  --bg: #101018;
  --panel: #171720;
  --line: #2b2b3a;
  --raised: #20202c;
  --ink: #f4f4fa;
  --muted: #adadbf;
  --violet: #b9a5ff;
  --lime: #d5fb83;
  font-family: "Space Grotesk", "Noto Sans Thai", system-ui, sans-serif;
  line-height: 1.48;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 285px; color: var(--ink); background: radial-gradient(ellipse 650px 440px at 51% 23%, #241b3c, transparent 90%), var(--bg); }
a { color: inherit; text-underline-offset: .22em; }
button, textarea, input { font: inherit; }
button, input[type="file"] { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
button, a, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
svg { width: 1.24em; height: 1.24em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; flex: none; vertical-align: middle; }
[hidden] { display: none !important; }
.icon-library { position: absolute; width: 0; height: 0; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; z-index: 8; top: 8px; left: 8px; background: #322455; padding: 8px; border-radius: 7px; }
.frame { width: min(1430px, calc(100% - 64px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: #13131c; }
.header-content { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: clamp(.95rem, 2vw, 1.18rem); letter-spacing: -.04em; white-space: nowrap; }
.brand-icon { display: grid; color: #161226; place-items: center; width: 35px; height: 35px; border-radius: 10px; background: var(--violet); box-shadow: inset 0 -3px 0 #38226029; font-size: 1.15rem; }
.brand-lab { color: var(--violet); }
.header-content nav { display: flex; align-items: center; gap: 8px; }
.primary, .ghost { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); font-weight: 800; text-decoration: none; font-size: .875rem; white-space: nowrap; }
.primary { background: var(--lime); border-color: var(--lime); color: #171e0b; }
.primary:hover:not(:disabled) { background: #edffbc; }
.ghost { background: var(--raised); color: var(--ink); }
.ghost:hover:not(:disabled) { background: #302742; border-color: #5b4b76; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 32px 0 23px; }
.intro h1 { font-size: clamp(2.15rem, 4.75vw, 4.45rem); font-weight: 800; margin: 0; line-height: 1.15; letter-spacing: -.055em; }
.intro h1 span { color: var(--violet); margin-inline-start: .16em; }
.intro p { color: var(--muted); margin: 8px 0 0; font-size: 1rem; }
.tracking { flex: 0 0 215px; padding: 10px 12px; background: #181823; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: .83rem; }
.tracking > div { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; }
.tracking strong { color: var(--lime); font-size: .92rem; }
.tracking progress { display: block; width: 100%; height: 5px; border: 0; margin-top: 7px; appearance: none; accent-color: var(--lime); border-radius: 12px; overflow: hidden; background: #363343; }
.tracking progress::-webkit-progress-bar { background: #363343; }
.tracking progress::-webkit-progress-value { background: var(--lime); border-radius: 12px; }
.tracking progress::-moz-progress-bar { background: var(--lime); }
.studio { display: grid; grid-template-columns: minmax(174px, .75fr) minmax(420px, 2.85fr) minmax(257px, 1.12fr); align-items: start; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; min-width: 0; }
.panel-head { min-height: 57px; padding: 13px 13px 11px; display: flex; justify-content: space-between; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.panel-head h2, .layers-head h2 { margin: 0; font-size: 1rem; font-weight: 800; }
.panel-head h2 svg { color: var(--violet); margin-inline-end: 3px; }
.panel-head a { color: var(--muted); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; }
.panel-head a:hover { color: var(--violet); background: var(--raised); }
.page-list, .layers { margin: 0; padding: 8px; list-style: none; display: grid; gap: 5px; }
.page-list button, .layer-button { text-align: left; border: 1px solid transparent; background: transparent; color: var(--muted); width: 100%; min-height: 42px; border-radius: 7px; display: flex; align-items: center; gap: 8px; padding: 6px 7px; font-size: .875rem; }
.page-list button:hover, .layer-button:hover { background: var(--raised); color: var(--ink); }
.page-list button[aria-current="page"], .layer-button[aria-pressed="true"] { background: #322748; color: #f5edff; border-color: #6b54a2; }
.page-list button > span:first-child { display: grid; place-items: center; width: 23px; height: 23px; flex: none; font-weight: 700; border-radius: 5px; background: #2b293b; color: var(--violet); font-variant-numeric: tabular-nums; }
.page-list .page-name { flex: 1; min-width: 0; }
.completed { color: var(--lime); display: inline-flex; }
.stage-panel { overflow: hidden; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 57px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.stage-info { display: flex; align-items: center; gap: 7px; }
.stage-info span { color: var(--violet); font-size: .88rem; font-weight: 700; border: 1px solid #493e60; border-radius: 6px; padding: 3px 5px; }
.stage-head h2 { margin: 0; font-size: .98rem; line-height: 1.3; }
.view-switch { display: flex; align-items: center; gap: 2px; flex: none; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #11111a; }
.view-switch button { border: 0; background: transparent; color: var(--muted); padding: 4px 6px; border-radius: 5px; font-size: .81rem; white-space: nowrap; }
.view-switch button[aria-pressed="true"] { background: #382e4d; color: #e7d8ff; }
.view-switch button:hover { color: #fff; }
.stage { --flash: transparent; display: grid; place-items: center; position: relative; overflow: hidden; isolation: isolate; height: clamp(330px, 37vw, 495px); background: radial-gradient(ellipse 80% 82% at 54% 53%, #312554, #181527 63%, #11111b); }
.stage::before { content: ""; position: absolute; z-index: -2; inset: 0; background: radial-gradient(circle, #a69ad046 1px, transparent 1.3px) 0 0 / 17px 17px; mask-image: radial-gradient(ellipse 93% 76% at 50% 45%, black, transparent 78%); }
.webgl { position: absolute; z-index: 0; inset: 0; }
.webgl canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.webgl canvas:active { cursor: grabbing; }
.scene-label { pointer-events: none; position: absolute; left: 12px; top: 12px; z-index: 2; background: #1b162b; border: 1px solid #48375f; color: #ded0f7; padding: 4px 8px; border-radius: 6px; font-size: .77rem; font-weight: 700; }
.scene-label i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--lime); margin-inline-end: 4px; vertical-align: .12em; }
.fit { position: absolute; z-index: 2; right: 12px; bottom: 12px; width: 35px; height: 35px; display: grid; place-items: center; border-radius: 8px; border: 1px solid #594272; background: #251c38; color: #eadbff; }
.fit:hover { background: #463361; }
.drop-message { position: absolute; pointer-events: none; inset: 8px; z-index: 3; display: none; place-content: center; justify-items: center; gap: 4px; border: 2px dashed var(--lime); border-radius: 10px; background: #151c11b8; color: var(--lime); font-weight: 800; }
.stage.drop-active .drop-message { display: grid; }
.stage-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-block: 1px solid var(--line); }
.stage-bottom > span { color: var(--muted); font-size: .8rem; }
.demo { color: #e4d6ff; background: #262037; border-color: #4b3c66; }
.brief { padding: 10px 12px; color: var(--muted); font-size: .87rem; }
.brief p { margin: 0; }
.brief strong, .brief a { color: #e6d8f8; }
.brief a { white-space: nowrap; }
.pieces { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 10px 11px 13px; }
.piece { --piece: var(--violet); border: 1px solid #373346; border-radius: 8px; background: #211f2f; color: var(--ink); text-align: left; padding: 7px; min-height: 52px; display: flex; align-items: center; gap: 6px; font-size: .81rem; line-height: 1.3; min-width: 0; }
.piece:hover:not(:disabled) { background: #2f2841; border-color: #775aa2; }
.piece svg { color: var(--piece); }
.piece[data-kind="image"] { --piece: var(--lime); }
.layers-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 11px; border-block: 1px solid var(--line); }
.layers-head span { font-size: .79rem; color: var(--muted); }
.layers { padding: 8px 11px; }
.layers:empty::before { content: "เพิ่มชิ้นแรกเพื่อเริ่มจัดหน้า"; color: var(--muted); font-size: .86rem; padding: 10px 0; }
.layer-button { min-height: 36px; padding: 6px 7px; gap: 6px; }
.layer-button svg { color: var(--violet); }
.layer-button span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.block-editor { padding: 9px 11px; border-top: 1px solid var(--line); background: #15141e; }
.editor-label, .editor-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: #d9d3e5; font-size: .82rem; }
.editor-label { margin-bottom: 5px; }
.editor-actions { margin-top: 6px; color: var(--muted); }
.editor-actions div { display: flex; gap: 4px; }
textarea { display: block; width: 100%; resize: vertical; padding: 7px 8px; background: #211e30; color: #fff; border: 1px solid #55456e; border-radius: 8px; line-height: 1.5; font-size: 1rem; }
textarea::placeholder { color: #b1a7be; }
.icon-button { display: grid; place-items: center; width: 29px; height: 29px; color: #e7dbfa; background: var(--raised); border: 1px solid #403751; border-radius: 7px; padding: 0; }
.icon-button:hover:not(:disabled) { background: #3c2e56; }
.icon-button.danger:hover { color: #ffc4c7; background: #4c2940; }
.file-label { display: block; font-size: .82rem; margin: 7px 0 4px; }
input[type="file"] { max-width: 100%; width: 100%; font-size: .78rem; color: var(--muted); }
input::file-selector-button { background: #352749; border: 1px solid #655181; color: #f5eaff; border-radius: 5px; padding: 3px 6px; cursor: pointer; }
.text-button { border: 0; background: transparent; color: var(--violet); text-decoration: underline; padding: 3px 0; font-size: .83rem; }
.save-state { margin: 0; padding: 9px 11px 10px; color: var(--muted); font-size: .79rem; }
.frame-footer { margin: 15px 0 22px; color: var(--muted); font-size: .875rem; }
.frame-footer a { color: var(--violet); }
dialog { width: min(540px, calc(100% - 28px)); max-height: min(84vh, 735px); color: var(--ink); background: #1b1927; border: 1px solid #55416e; border-radius: 15px; padding: 16px; }
dialog::backdrop { background: #090910bd; backdrop-filter: blur(5px); }
dialog header { display: flex; justify-content: space-between; gap: 8px; }
dialog h2 { margin: 0; font-size: 1.3rem; }
dialog p { margin: 4px 0 8px; color: var(--muted); }
dialog footer { margin-top: 12px; font-size: .88rem; }
dialog footer small { display: inline-block; margin-left: 6px; color: var(--muted); }
.review-list { display: grid; gap: 5px; padding: 0; margin: 8px 0; list-style: none; }
.review-list button { display: grid; width: 100%; padding: 7px 8px; gap: 4px; text-align: left; grid-template-columns: 25px 1fr; border-radius: 7px; border: 1px solid var(--line); color: var(--ink); background: #242034; }
.review-list button:hover { background: #38304c; }
.review-list small { display: block; color: var(--muted); font-size: .82rem; }
.sample-actions { display: flex; justify-content: end; gap: 7px; margin-top: 12px; }
.paper-fallback { background: #f9f5ff; color: #272134; width: min(48%, 240px); max-height: 89%; aspect-ratio: 210 / 297; box-shadow: 12px 15px 0 #8f6fc6, 16px 22px 45px #090512; padding: 12px; border-top: 8px solid #8b62eb; overflow: auto; font-size: .77rem; transform: perspective(650px) rotateY(-22deg) rotateX(12deg) rotateZ(-7deg); }
.paper-fallback.front { transform: none; }
.paper-fallback h3 { font-size: 1em; margin: 0 0 7px; }
.paper-fallback p { margin: 3px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.paper-fallback img { width: 100%; max-height: 72px; object-fit: contain; }
.print-pages { display: none; }
@media (max-width: 1110px) {
  .frame { width: calc(100% - 36px); }
  .studio { grid-template-columns: minmax(145px, .75fr) minmax(330px, 2.65fr) minmax(225px, 1.2fr); gap: 8px; }
  .page-list button { padding-inline: 5px; gap: 5px; }
}
@media (max-width: 850px) {
  .studio { grid-template-columns: minmax(0, 1.7fr) minmax(230px, 1fr); }
  .page-panel { grid-column: 1 / -1; }
  .page-panel .panel-head { min-height: 38px; padding-block: 5px; }
  .page-list { display: flex; overflow-x: auto; overscroll-behavior-inline: contain; padding-block: 6px; }
  .page-list li { flex: 0 0 auto; }
  .page-list button { min-height: 34px; padding-inline: 5px 8px; white-space: nowrap; }
}
@media (max-width: 620px) {
  .frame { width: calc(100% - 24px); }
  .header-content { min-height: 59px; gap: 5px; }
  .brand { gap: 5px; }
  .brand-icon { width: 29px; height: 29px; }
  .header-content nav { gap: 4px; }
  .header-content nav .ghost, .header-content nav .primary { font-size: .76rem; padding-inline: 6px; gap: 3px; }
  .intro { display: grid; gap: 9px; padding: 18px 0 12px; }
  .intro p { font-size: .91rem; margin-top: 4px; }
  .tracking { padding: 7px 9px; }
  .studio { grid-template-columns: minmax(0, 1fr); }
  .stage { height: clamp(290px, 78vw, 385px); }
  .stage-head { min-height: 43px; padding: 6px 7px; }
  .stage-head h2 { font-size: .83rem; }
  .stage-info { gap: 4px; }
  .view-switch button { font-size: .73rem; padding-inline: 5px; }
  .stage-bottom { padding: 7px; }
  .stage-bottom > span { font-size: .73rem; }
  .stage-bottom .demo { font-size: .75rem; padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; color: #241d31; }
  body > :not(.print-pages) { display: none !important; }
  .print-pages { display: block; }
  .print-sheet { width: 210mm; min-height: 297mm; break-inside: avoid; break-after: page; border-top: 7mm solid #9b7ae5; padding: 15mm 17mm; }
  .print-sheet:last-child { break-after: auto; }
  .print-sheet h2 { margin: 0 0 5mm; color: #4d3577; font-size: 13pt; }
  .print-sheet h3 { margin: 6mm 0 2mm; font-size: 15pt; }
  .print-sheet p { margin: 0 0 2mm; font-size: 12pt; white-space: pre-wrap; overflow-wrap: anywhere; }
  .print-sheet img { display: block; width: 100%; height: 42mm; object-fit: contain; object-position: left center; margin: 0 0 3mm; }
}
.paper-fallback { aspect-ratio: auto; padding: 0; overflow: hidden; }
.paper-fallback canvas { display: block; width: 100%; height: auto; }

.design-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 9px 12px; border-bottom: 1px solid var(--line); color: #e6d8f8; font-size: .85rem; }
.layout-field, .theme-field, .edit-history { display: flex; align-items: center; gap: 7px; }
.layout-field select { appearance: none; min-width: 112px; padding: 4px 18px 4px 6px; border: 1px solid #4b3c66; border-radius: 6px; background: #242034; color: var(--ink); font: inherit; font-size: .82rem; }
.layout-field { position: relative; }
.layout-field::after { content: ""; position: absolute; pointer-events: none; right: 8px; top: 10px; width: 6px; height: 6px; border: solid var(--violet); border-width: 0 1px 1px 0; transform: rotate(45deg); }
#theme-options { display: flex; gap: 5px; }
.theme-option { width: 22px; height: 22px; border-radius: 5px; background: var(--swatch); border: 1px solid #fff5; }
.theme-option[aria-pressed="true"] { outline: 1px solid #eee3ff; outline-offset: 2px; }
.theme-option:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
.edit-history { margin-inline-start: auto; gap: 4px; }
.edit-history .icon-button { width: 26px; height: 26px; }
.brief-heading { display: flex; align-items: baseline; gap: 8px; }
.brief-heading a { margin-inline-start: auto; }
#task-count { font-size: .75rem; color: var(--lime); }
.brief p { margin-top: 3px; }
.task-list { list-style: none; padding: 0; margin: 7px 0 0; display: flex; flex-wrap: wrap; gap: 5px; }
.task-list button { font-size: .77rem; display: flex; align-items: center; gap: 4px; padding: 3px 6px; color: #ded6f0; background: #242034; border: 1px solid #3e354f; border-radius: 6px; }
.task-list button:hover { background: #382b4d; }
.task-list button[data-complete="true"] { color: #e3f8be; border-color: #566644; background: #252e20; }
.task-list button svg { width: 14px; height: 14px; }
.draft-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 8px; padding: 0 10px 10px; }
.draft-actions button { font-size: .78rem; }
.webgl canvas.card-drag { cursor: move; }
.paper-fallback canvas { touch-action: pan-y; }
@media (max-width: 420px) {
  .design-bar { gap: 8px 10px; padding-inline: 7px; }
  .layout-field select { min-width: 94px; }
  .theme-option { width: 19px; height: 19px; }
  .edit-history .icon-button { width: 24px; height: 24px; }
}
@media print {
  .print-sheet { border-color: var(--print-color); }
  .print-sheet h2 { color: var(--print-ink); }
  .print-block { min-width: 0; break-inside: avoid; }
  .print-blocks.layout-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 7mm; }
  .print-blocks.layout-pair > :first-child { grid-column: 1 / -1; }
  .print-blocks.layout-feature > :first-child h3 { font-size: 20pt; }
  .print-blocks.layout-feature > :first-child img { height: 69mm; }
}
