:root {
  --bg: #f6efe7; --bg-2: #fbf7f2; --card: #fffdfa; --line: #e8dccd; --line-2: #f0e7dc;
  --ink: #3a2e2c; --soft: #6b5a55; --muted: #9a8a82;
  --accent: #c4705f; --accent-2: #a95646; --accent-bg: #f8e3dc; --sage: #8ea283;
  --radius: 18px; --serif: "Fraunces", Georgia, serif; --sans: "DM Sans", system-ui, sans-serif;
  --current: #c97b6b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .5; z-index: 0;
  background: radial-gradient(1200px 600px at 85% -10%, #f8dcd2 0, transparent 60%), radial-gradient(900px 500px at -10% 110%, #e3ebdc 0, transparent 60%); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
[hidden] { display: none !important; }

/* header */
.top { position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 9px; background: none; border: 0; padding: 4px; font: 500 22px var(--serif); letter-spacing: -.01em; }
.brand svg { width: 30px; height: 30px; }
.brand .petals ellipse { fill: var(--accent-bg); stroke: var(--accent); stroke-width: 1.3; }
.brand .heart { fill: #e9b949; stroke: var(--accent-2); stroke-width: 1.1; }
.topright { display: flex; align-items: center; gap: 10px; }
.link { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 500; color: var(--soft); background: var(--card); }
.link:hover { border-color: var(--accent); color: var(--accent-2); }

.screen { display: none; position: relative; z-index: 1; }
.screen.active { display: block; }

/* home */
#home { max-width: 980px; margin: 0 auto; padding: 18px 20px 80px; }
.hero { text-align: center; margin: 26px auto 26px; max-width: 640px; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 600; color: var(--accent); margin: 0 0 12px; }
h1 { font: 400 clamp(34px, 6vw, 54px)/1.06 var(--serif); letter-spacing: -.025em; margin: 0; }
h1 em { color: var(--accent); }
.lede { color: var(--soft); font-size: 17px; margin: 14px 0 0; }
.create { background: var(--card); border: 1px solid var(--line); border-radius: 26px; padding: 22px; max-width: 720px; margin: 0 auto;
  box-shadow: 0 1px 2px rgba(58, 46, 44, .04), 0 18px 50px -20px rgba(150, 90, 70, .22); }
.create textarea { width: 100%; resize: none; border: 1px solid var(--line); background: var(--bg-2); border-radius: 16px; padding: 14px 16px; font-size: 18px; outline: none; transition: border-color .2s, box-shadow .2s; }
.create textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 4px; }
.chips button { border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; color: var(--soft); }
.chips button:hover { border-color: var(--accent); color: var(--accent-2); background: var(--accent-bg); }
.chips .more { width: 34px; padding: 6px 0; }
.opts { display: flex; flex-wrap: wrap; gap: 14px 20px; margin-top: 14px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
select { appearance: none; border: 1px solid var(--line); background: var(--bg-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239a8a82' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  border-radius: 12px; padding: 9px 34px 9px 12px; min-width: 190px; outline: none; }
.seg { display: inline-flex; background: var(--line-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 7px 13px; font-size: 14px; color: var(--soft); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(58, 46, 44, .12); font-weight: 500; }
.seg.small button { padding: 6px 10px; font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.primary { border: 0; background: var(--accent); color: #fff; border-radius: 14px; padding: 11px 20px; font-weight: 600; transition: background .2s, transform .15s; }
.primary:hover { background: var(--accent-2); }
.primary:active { transform: scale(.98); }
.ghost { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 16px; font-weight: 500; color: var(--soft); }
.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-2); }
.fine { text-align: right; color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.error { background: #fbe4df; color: #9a3b2c; border-radius: 12px; padding: 10px 14px; margin: 12px 0 0; font-size: 14.5px; }

.shelf { max-width: 980px; margin: 44px auto 0; }
.shelf.wide { padding: 18px 20px 80px; margin-top: 0; }
.shelf h2 { font: 400 26px var(--serif); letter-spacing: -.02em; margin: 0 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .25s cubic-bezier(.2, .8, .3, 1), box-shadow .25s; }
.card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px -16px rgba(120, 70, 55, .3); }
.card .open { display: block; width: 100%; padding: 0; border: 0; background: #fff; aspect-ratio: 1; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .meta { display: flex; flex-direction: column; padding: 10px 14px 12px; gap: 1px; }
.card .meta b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta span { font-size: 13px; color: var(--muted); }
.card .del { align-self: flex-start; margin-top: 6px; border: 0; background: none; padding: 0; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.card .del[data-sure] { color: #b0412e; }

/* making */
.making { min-height: calc(100vh - 64px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; margin-top: -40px; }
.making h2 { font: 400 30px var(--serif); margin: 18px 0 0; letter-spacing: -.02em; }
.sketch { width: 170px; height: 170px; }
.sketch path { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 320; stroke-dashoffset: 320; animation: draw 3.2s ease-in-out infinite; }
.sketch path:nth-child(2) { animation-delay: .35s; } .sketch path:nth-child(3) { animation-delay: .7s; }
.sketch path:nth-child(4) { animation-delay: 1.05s; } .sketch path:nth-child(5) { animation-delay: 1.4s; }
@keyframes draw { 0% { stroke-dashoffset: 320; } 45%, 70% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -320; } }

/* studio */
body[data-screen="studio"] { overflow: hidden; }
.studio { display: grid; grid-template-columns: 1fr 360px; height: calc(100vh - 64px); height: calc(100dvh - 64px); }
.stage { position: relative; overflow: hidden; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.stage[data-tool="fill"] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='%23fff' stroke='%233a2e2c' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M5 11l6-6 8 8-6 6a2 2 0 0 1-2.8 0L5 13.8a2 2 0 0 1 0-2.8z'/%3E%3Cpath d='M20 15s2 2.4 2 3.6a2 2 0 0 1-4 0c0-1.2 2-3.6 2-3.6z' fill='%23c4705f'/%3E%3C/svg%3E") 20 22, crosshair; }
.stage[data-tool="brush"] { cursor: none; }
.stage.panning, .stage.panning * { cursor: grab !important; }
.paper { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 2px 4px rgba(58, 46, 44, .06), 0 30px 60px -30px rgba(110, 70, 55, .35); background: #fff; }
.paper canvas { display: block; }
.ring { position: absolute; border: 1.5px solid rgba(58, 46, 44, .55); border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, .6) inset; }
.burst { position: absolute; width: 0; height: 0; pointer-events: none; }
.burst::before, .burst::after { content: ""; position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; transform: scale(var(--s));
  border: 3px solid var(--c); animation: burst .55s ease-out forwards; }
.burst::after { border-style: dotted; border-width: 4px; animation-delay: .05s; }
@keyframes burst { from { opacity: .9; scale: .2; } to { opacity: 0; scale: 1.4; } }
.zoom { position: absolute; left: 16px; bottom: 16px; display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 6px 20px -10px rgba(58, 46, 44, .3); }
.zoom button { border: 0; background: none; min-width: 40px; height: 36px; font-size: 16px; color: var(--soft); }
.zoom button + button { border-left: 1px solid var(--line-2); }
.zoom #zoomFit { font-size: 13px; font-weight: 500; padding: 0 10px; }
.zoom button:hover { background: var(--bg-2); color: var(--ink); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--soft); font: italic 400 20px var(--serif); background: var(--bg); }

.panel { border-left: 1px solid var(--line); background: var(--card); padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.titlebar { display: flex; align-items: center; gap: 10px; }
.titlebar input { flex: 1; min-width: 0; border: 1px solid transparent; background: none; border-radius: 10px; padding: 5px 8px; margin-left: -8px; font: 400 22px var(--serif); letter-spacing: -.015em; outline: none; }
.titlebar input:hover { border-color: var(--line); }
.titlebar input:focus { border-color: var(--accent); background: var(--bg-2); }
.saved { font-size: 12.5px; color: var(--sage); white-space: nowrap; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tools button { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--bg-2); border-radius: 14px; padding: 10px 4px 8px; font-size: 13px; font-weight: 500; color: var(--soft); }
.tools svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tools button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tools button.on[data-tool="fill"] svg path:last-child, .tools button.on[data-tool="brush"] svg path:last-child { fill: var(--current); stroke: #fff; }
.opts2 { display: flex; align-items: center; gap: 12px; min-height: 36px; }
.size { display: flex; align-items: center; gap: 10px; flex: 1; font-size: 13px; color: var(--muted); }
.size input { flex: 1; accent-color: var(--accent); }

.palettes { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.palettes button { flex: none; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 11px 5px 6px; font-size: 13px; color: var(--soft); white-space: nowrap; }
.palettes button i { width: 18px; height: 18px; border-radius: 50%; }
.palettes button.on { border-color: var(--ink); color: var(--ink); font-weight: 500; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatches button, .recent button { aspect-ratio: 1; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(58, 46, 44, .12); transition: transform .15s; }
.swatches button:hover, .recent button:hover { transform: scale(1.08); }
.swatches button.on, .recent button.on { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
.custom { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.pickcolor { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); cursor: pointer; flex: none; }
.pickcolor input { width: 30px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }
.pickcolor input::-webkit-color-swatch-wrapper { padding: 0; }
.pickcolor input::-webkit-color-swatch { border-radius: 50%; border: 1px solid rgba(58, 46, 44, .15); background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red) !important; }
.recent { display: flex; gap: 6px; flex: 1; justify-content: flex-end; }
.recent button { width: 24px; }
.bottom { display: flex; gap: 8px; align-items: center; margin-top: auto; flex-wrap: wrap; }
.bottom .grow { flex: 1; }
.bottom button { padding: 9px 13px; font-size: 14px; }
.bottom .icon { padding: 8px 10px; line-height: 0; }
.bottom .icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 0; }

@media (max-width: 820px) {
  .studio { grid-template-columns: 1fr; grid-template-rows: minmax(300px, 1fr) auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: 46vh; padding: 12px 14px; gap: 12px; }
  .hint { display: none; }
  .swatches { grid-template-columns: repeat(12, 1fr); gap: 5px; }
  .titlebar input { font-size: 18px; }
  .tools button { flex-direction: row; justify-content: center; padding: 8px 4px; }
  .tools svg { width: 18px; height: 18px; }
}
@media (max-width: 520px) {
  .top { padding: 12px 14px; }
  .create { padding: 16px; border-radius: 22px; }
  .opts { flex-direction: column; align-items: stretch; }
  select { width: 100%; }
  .seg { width: 100%; } .seg button { flex: 1; }
  .actions button { flex: 1; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .swatches { grid-template-columns: repeat(6, 1fr); }
}

/* Tolan theme */
[data-theme="tolan"] { --bg: #f4f2e7; --bg-2: #faf8f3; --card: #fff; --line: #e2e0c3; --line-2: #edece2; --ink: #2c2c2c; --soft: #474744; --muted: #7a7869;
  --accent: #8f6cf0; --accent-2: #7552e0; --accent-bg: #f1ecff; --sage: #2fae78; --serif: "Inter Tight", system-ui, sans-serif; --sans: "Inter Tight", system-ui, sans-serif; }
[data-theme="tolan"] body { letter-spacing: -.01em; }
[data-theme="tolan"] body::before { display: none; }
[data-theme="tolan"] h1 { font-weight: 600; letter-spacing: -.045em; }
[data-theme="tolan"] h1 em { font-style: normal; }
[data-theme="tolan"] .brand { font-weight: 600; letter-spacing: -.03em; }
[data-theme="tolan"] .brand .petals ellipse { fill: #3cc8d8; stroke: none; opacity: .9; }
[data-theme="tolan"] .brand .heart { fill: #8f6cf0; stroke: #fff; stroke-width: 1.4; }
[data-theme="tolan"] .eyebrow { text-transform: none; letter-spacing: -.01em; font-size: 15px; font-weight: 500; }
[data-theme="tolan"] .create { border-radius: 28px; box-shadow: none; }
[data-theme="tolan"] .create textarea { background: #fff; border-radius: 18px; }
[data-theme="tolan"] .primary { background: #2c2c2c; border-radius: 12px; }
[data-theme="tolan"] .primary:hover { background: #474744; }
[data-theme="tolan"] .ghost, [data-theme="tolan"] .link { border-radius: 12px; }
[data-theme="tolan"] .link { border-radius: 999px; }
[data-theme="tolan"] .shelf h2, [data-theme="tolan"] .making h2 { font-weight: 600; letter-spacing: -.03em; }
[data-theme="tolan"] .card { border-radius: 24px; }
[data-theme="tolan"] .card:hover { box-shadow: 0 18px 44px rgba(44, 44, 44, .10); }
[data-theme="tolan"] .titlebar input { font-weight: 600; letter-spacing: -.03em; }
[data-theme="tolan"] .tools button { border-radius: 16px; background: #fff; }
[data-theme="tolan"] .tools button.on { background: #8f6cf0; border-color: #8f6cf0; }
[data-theme="tolan"] .paper { box-shadow: 0 0 0 1px #e2e0c3, 0 18px 44px rgba(44, 44, 44, .10); }
[data-theme="tolan"] .loading { font-style: normal; font-weight: 500; }
[data-theme="tolan"] .sketch path { stroke: #8f6cf0; }

/* Marc, the cartoon glam-rocker who hangs out across the Tolan demos */
.marchi { display: inline-flex; align-items: center; gap: 12px; margin: 0 auto 18px; padding: 6px 18px 6px 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; text-align: left; }
.marchi img { width: 58px; height: 58px; object-fit: contain; flex: none; }
.marchi p { margin: 0; font-size: 15px; color: var(--soft); max-width: 320px; line-height: 1.35; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 30px 0; }
.empty[hidden] { display: none; }
.empty img { width: 150px; }
.empty .lede { max-width: 380px; margin: 0 0 6px; }
