:root {
  color-scheme: light;
  --back: #f4f1ea;
  --paper: #fffdf8;
  --ink: #282820;
  --muted: #615f54;
  --stone: #767369;
  --rule: #d7d2c6;
  --rule-soft: #e7e2d6;
  --accent: #aa482f;
  --accent-rich: #bd543a;
  --accent-pale: #f5e8df;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--back); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: 0; border: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .55; }
button, input, textarea { touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, pre:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.icon-bank { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.icon { display: block; flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.site-header { border-bottom: 1px solid var(--rule); }
.header-inner, .studio { width: min(calc(100% - clamp(48px, 8vw, 132px)), 1480px); margin-inline: auto; }
.header-inner { min-height: 70px; display: flex; justify-content: space-between; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 8px; user-select: none; }
.brand span { font-family: Georgia, serif; font-size: 30px; letter-spacing: -2.2px; line-height: 1; }
.brand-mark { width: 41px; height: 36px; }
.header-actions, .drawing-actions { display: flex; align-items: center; }
.header-actions { gap: 13px; }
.header-rule { width: 1px; height: 18px; background: var(--rule); }
.icon-button { height: 36px; width: 36px; flex: 0 0 36px; border-radius: 5px; }
.voice-button, .connection-button, .replay-button { font-size: 13px; font-weight: 550; line-height: 1; white-space: nowrap; }
.voice-button, .connection-button { height: 34px; padding-inline: 8px; color: #514f44; border-radius: 5px; }
.header-actions .icon-button { color: #555347; }
.voice-button .voice-off-icon, .voice-button[aria-pressed="false"] .voice-on-icon { display: none; }
.voice-button[aria-pressed="false"] .voice-off-icon { display: inline; }
.voice-button[aria-pressed="true"] { color: var(--accent); }
button:not(:disabled).icon-button:hover, button:not(:disabled).voice-button:hover, button:not(:disabled).connection-button:hover, button:not(:disabled).replay-button:hover { background: #ebe7dd; }
.studio { padding: clamp(29px, 3.05vw, 48px) 0 30px; }
.intro { margin: 0 0 clamp(23px, 2.35vw, 37px); }
h1, h2, h3, p { margin: 0; }
.intro h1 { font-family: var(--serif); font-size: clamp(43px, 4.25vw, 68px); font-weight: 450; line-height: .99; letter-spacing: -.062em; }
.period { color: var(--accent-rich); }
.intro p { margin-top: 11px; font-size: clamp(14px, 1.05vw, 16px); line-height: 1.48; color: var(--muted); }
.workspace { display: grid; grid-template-columns: minmax(0, 2.65fr) minmax(260px, 1fr); align-items: start; column-gap: clamp(24px, 3vw, 48px); }
.drawing-column, .notebook, .notebook-main { min-width: 0; }
.drawing-sheet {
  background: var(--paper);
  border: 1px solid #d5cebd;
  border-radius: 10px;
  box-shadow: 0 2px 4px #433a2910, 0 10px 26px -19px #53412655;
  overflow: hidden;
}
.drawing-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 61px; padding: 8px clamp(16px, 1.55vw, 24px); border-bottom: 1px solid var(--rule-soft); }
.drawing-toolbar h2 { margin-right: auto; font-family: var(--serif); font-weight: 500; font-size: clamp(20px, 1.6vw, 26px); line-height: 1.14; letter-spacing: -.035em; overflow-wrap: anywhere; }
.drawing-actions { flex: 0 0 auto; gap: 5px; color: #5e594d; }
.drawing-actions .icon { width: 16px; height: 16px; }
.replay-button { height: 32px; gap: 5px; padding-inline: 8px; border-radius: 4px; }
.drawing-actions .icon-button { width: 32px; height: 32px; flex-basis: 32px; }
.art-area { position: relative; width: 100%; aspect-ratio: 840 / 500; }
#art { display: block; width: 100%; height: 100%; color: var(--ink); overflow: hidden; }
.drawing-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 35px; padding: 5px clamp(16px, 1.55vw, 24px) 10px; color: var(--muted); font-size: 11.7px; line-height: 1.35; }
#run-state { display: inline-flex; align-items: center; gap: 7px; }
#run-state::before { content: ""; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #6e7e58; }
#run-state[data-state="drawing"]::before, #run-state[data-state="running"]::before, #run-state.running::before { background: var(--accent-rich); animation: statusPulse 1.3s ease-in-out infinite alternate; }
#latency { text-align: right; font-variant-numeric: tabular-nums; }
@keyframes statusPulse { to { opacity: .5; } }
.composer { background: #fbf9f3; margin-top: 15px; border: 1px solid var(--rule); border-radius: 9px; padding: 14px 16px 13px; transition: border-color .18s, box-shadow .18s; }
.composer:focus-within { border-color: #bba38d; box-shadow: 0 0 0 2px #a7513020; }
.composer-label { display: flex; align-items: center; gap: 7px; color: #504b40; font-size: 12px; letter-spacing: .012em; font-weight: 650; line-height: 1.4; }
.composer-label .icon { color: var(--accent); width: 15px; height: 15px; }
.composer-row { display: flex; align-items: center; gap: 12px; }
#prompt { display: block; width: 100%; min-width: 0; min-height: 40px; max-height: 115px; border: 0; background: transparent; resize: none; padding: 10px 0 6px; font-size: 15px; line-height: 1.45; border-radius: 0; }
#prompt::placeholder { color: #746f62; opacity: 1; }
#prompt:focus, #prompt:focus-visible { outline: none; }
.primary-button { display: inline-flex; text-decoration: none; flex-shrink: 0; justify-content: center; align-items: center; gap: 10px; min-height: 37px; padding: 0 15px; border: 1px solid #a3442d; border-radius: 6px; background: #af4c33; color: #fffdfa; font-size: 13px; font-weight: 600; line-height: 1; transition: background .15s, transform .15s; }
.primary-button .icon { width: 16px; height: 16px; }
.primary-button:hover:not(:disabled) { background: #963d29; }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
.status-message { margin: 10px 3px 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.status-message:empty { display: none; }
.status-message[data-kind="error"], .status-message.error { color: #943e2b; }
.notebook { padding: 5px 0 0; }
.notebook-main h2 { font-family: var(--serif); font-size: clamp(26px, 2.15vw, 34px); font-weight: 450; letter-spacing: -.052em; line-height: 1.05; }
.tabs { display: flex; align-items: stretch; gap: 20px; border-bottom: 1px solid #cfc8ba; margin-top: 16px; }
.tabs button { margin-bottom: -1px; padding: 8px 1px 11px; border-radius: 2px 2px 0 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 530; gap: 6px; }
.tabs .icon { width: 16px; height: 16px; }
.tabs button[aria-selected="true"], .tabs button.active, .tabs button[data-active="true"] { border-bottom-color: var(--accent); color: var(--accent); }
.tabs button:hover { color: var(--ink); }
#notes-list { list-style: none; padding: 0; margin: 0; }
#notes-list > li { position: relative; padding: 15px 0 15px 17px; margin: 0; border-bottom: 1px solid var(--rule-soft); color: #514f45; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
#notes-list > li::before { position: absolute; content: ""; top: 22px; left: 1px; width: 5px; height: 5px; background: #b77f61; border-radius: 50%; }
#notes-list > li:last-child { border-bottom: 0; }
#notes-list > li:is([aria-current="step"],[data-active="true"],.active)::before { background: var(--accent-rich); box-shadow: 0 0 0 3px #b9573824; }
#notes-list > li strong, #notes-list > li h3, #notes-list > li h4 { display: block; padding: 0; margin: 0 0 2px; color: var(--ink); font-size: 14px; font-weight: 650; line-height: 1.4; }
#program-code { display: block; width: 100%; max-height: 350px; margin: 15px 0 1px; padding: 13px; overflow: auto; background: #f9f7f0; border: 1px solid var(--rule); border-radius: 6px; color: #494438; font: 11.5px/1.55 ui-monospace, Menlo, Consolas, monospace; tab-size: 2; white-space: pre-wrap; overflow-wrap: anywhere; }
.examples-section { margin-top: 23px; border-top: 1px solid #cfc8ba; padding-top: 20px; }
.examples-section h3 { font-family: var(--serif); font-weight: 500; font-size: 21px; letter-spacing: -.036em; line-height: 1.2; }
#examples { margin-top: 8px; display: flex; flex-direction: column; }
#examples button { display: flex; width: 100%; justify-content: space-between; gap: 12px; text-align: left; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); color: #554f42; font-size: 13px; font-weight: 500; line-height: 1.38; }
#examples button:last-child { border-bottom-color: transparent; }
#examples button::after { flex-shrink: 0; content: "↗"; color: var(--accent); font: normal 15px/1 var(--sans); }
#examples button:has(svg)::after, #examples button:has(.arrow)::after { display: none; }
#examples button:hover { color: var(--accent); }
.drawing-sheet:fullscreen, .drawing-sheet:-webkit-full-screen { display: flex; flex-direction: column; width: 100%; height: 100%; border: 0; border-radius: 0; }
.drawing-sheet:fullscreen .art-area, .drawing-sheet:-webkit-full-screen .art-area { flex: 1; min-height: 0; }
.drawing-sheet:fullscreen .drawing-toolbar, .drawing-sheet:fullscreen .drawing-footer { flex-shrink: 0; }
dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); color: var(--ink); box-shadow: 0 14px 65px #29241d38; }
dialog::backdrop { background: #30291e44; }
.dialog-inner { padding: 22px 24px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 22px; }
.dialog-heading h2 { font: 500 29px/1.05 var(--serif); letter-spacing: -.045em; }
.dialog-heading .icon-button { margin-right: -6px; }
#settings-info { color: var(--muted); font-size: 13px; line-height: 1.5; }
.dialog-footer { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 9px; margin-top: 22px; }
.secondary-button { display: inline-flex; align-items: center; min-height: 37px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 6px; color: var(--ink); background: #f7f4ed; text-decoration: none; font-size: 13px; font-weight: 550; }
.secondary-button:hover { border-color: #ac9880; }
.status-message a { color: var(--accent); text-underline-offset: 3px; font-weight: 550; }

@media (max-width: 1020px) and (min-width: 761px) {
  .header-inner, .studio { width: calc(100% - 48px); }
  .workspace { grid-template-columns: minmax(0, 2.2fr) minmax(225px, 1fr); gap: 23px; }
  .drawing-toolbar { min-height: 54px; }
  .notebook { padding-top: 2px; }
  #notes-list > li { font-size: 13px; }
}
@media (max-width: 760px) {
  .header-inner, .studio { width: calc(100% - 36px); }
  .header-inner { min-height: 57px; }
  .brand span { font-size: 26px; }
  .brand { gap: 5px; }
  .brand-mark { width: 34px; height: 32px; }
  .header-actions { gap: 7px; }
  .voice-button, .connection-button { font-size: 12px; }
  .studio { padding-top: 28px; }
  .intro { margin-bottom: 20px; }
  .intro h1 { font-size: clamp(40px, 8vw, 52px); }
  .intro p { font-size: 14px; margin-top: 9px; max-width: 38ch; }
  .workspace { display: flex; flex-direction: column; gap: 29px; }
  .drawing-column, .notebook { width: 100%; }
  .drawing-toolbar { min-height: 48px; padding: 6px 11px 6px 14px; }
  .drawing-toolbar h2 { font-size: 20px; }
  .drawing-actions { gap: 2px; }
  .drawing-footer { min-height: 30px; padding: 5px 13px 8px; font-size: 11px; }
  .composer { margin-top: 11px; padding: 10px 11px 9px 13px; }
  .composer-row { gap: 6px; }
  #prompt { font-size: 16px; }
  .notebook { padding-top: 0; }
  .notebook-main h2 { font-size: 27px; }
  .tabs { margin-top: 11px; }
  #notes-list > li { padding-block: 13px; }
  #notes-list > li::before { top: 20px; }
  .examples-section { margin-top: 15px; }
  #examples button { min-height: 42px; }
}
@media (max-width: 440px) {
  .header-inner, .studio { width: calc(100% - 28px); }
  .replay-button span { display: none; }
  .drawing-toolbar h2 { font-size: 18px; }
  .replay-button { padding-inline: 6px; }
  .composer-label { font-size: 11.5px; }
  #prompt { padding-top: 10px; }
  .primary-button { padding: 0 11px; gap: 5px; }
  .drawing-actions .icon-button { width: 30px; flex-basis: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  button, .composer { transition: none; }
  #run-state::before { animation: none !important; }
}

.drawing-sheet.expanded-fallback { position:fixed; inset:0; z-index:100; display:flex; flex-direction:column; width:100%; height:100dvh; background:var(--paper,#fffaf0); border:0; border-radius:0; }
.drawing-sheet.expanded-fallback .art-area { flex:1; min-height:0; }

.live-control {display:inline-flex;align-items:center;gap:.45rem;margin:.8rem 0 .2rem;cursor:pointer;font-size:.9rem}.live-control input {accent-color:#a74730}

#pen-layer {position:absolute;inset:0;width:100%;height:100%;touch-action:none;user-select:none;cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M3 21l2-7L17 2l5 5L10 19z' fill='%23fdf9ef' stroke='%23342929' stroke-width='1.5'/%3E%3Cpath d='M3 21l2-7 5 5z' fill='%23ae235a'/%3E%3C/svg%3E") 3 21,crosshair}
#pen-chat {position:absolute;z-index:4;width:min(280px,96%);max-height:95%;overflow:auto;box-sizing:border-box;background:var(--paper,#fffaf2);border:1px solid var(--rule);border-radius:10px;padding:10px;box-shadow:0 6px 22px #241c1829;color:var(--ink)}
#pen-chat[hidden] {display:none}
#pen-chat label {font-weight:600;font-size:13px}
#pen-close {float:right;border:0;background:transparent;cursor:pointer;font-size:18px}
#pen-question {width:100%;box-sizing:border-box;margin:6px 0;padding:7px;border:1px solid var(--rule);border-radius:4px;font:inherit;font-size:14px}
#pen-reply {font-size:13px;line-height:1.4;max-height:5.6em;overflow:auto}
.pen-actions {display:flex;justify-content:flex-end;gap:8px}
.pen-actions button {min-height:30px;font-size:13px}
#key-form:not([hidden]) {display:grid;gap:.65rem;margin-top:1rem}
#api-key {padding:.65rem;border:1px solid var(--rule);border-radius:5px;font:inherit}
