:root {
  --bg: #fbf6ee;
  --bg-dots: #f1e7d8;
  --surface: #ffffff;
  --surface-2: #f6efe4;
  --text: #2f2a24;
  --muted: #6f665a;
  --line: #ece3d5;
  --accent: #d4561c;
  --accent-2: #ffb547;
  --accent-soft: #ffe7d6;
  --accent-text: #ffffff;
  --mint: #3fb68b;
  --user-bubble: #ffe2cf;
  --error: #c4321f;
  --radius: 18px;
  --shadow: 0 2px 0 rgba(120, 80, 30, .06), 0 8px 24px rgba(120, 80, 30, .06);
  --font: "M PLUS Rounded 1c", system-ui, -apple-system, "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", sans-serif;

  --m-skin: #f2884e;
  --m-skin-edge: #d96a30;
  --m-hat: #ffd34d;
  --m-ink: #3a2a20;
  --m-cheek: #ff9f9f;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1b17;
    --bg-dots: #29241f;
    --surface: #2a2520;
    --surface-2: #342e27;
    --text: #f1ebe2;
    --muted: #b0a596;
    --line: #3d362e;
    --accent: #ff8a4f;
    --accent-2: #ffc36b;
    --accent-soft: #4a3020;
    --accent-text: #1f1b17;
    --mint: #5fd1a6;
    --user-bubble: #4d3122;
    --error: #ff8e7d;
    --shadow: 0 2px 0 rgba(0, 0, 0, .2), 0 8px 24px rgba(0, 0, 0, .25);
    --m-ink: #2a1d15;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dots) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--text);
  font: 16px/1.7 var(--font);
  -webkit-text-size-adjust: 100%;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- buttons ---- */
.btn {
  appearance: none;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: transform .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
  box-shadow: 0 4px 0 var(--m-skin-edge);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.05); }
.btn-primary:active { box-shadow: 0 1px 0 var(--m-skin-edge); transform: translateY(3px); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-small { padding: 5px 12px; font-size: 14px; }
.btn-icon { padding: 6px 10px; min-width: 40px; min-height: 40px; }
.btn-big { padding: 14px 28px; font-size: 18px; }
.btn-wide { width: 100%; }

/* ---- mascot ---- */
.mascot { flex: none; display: inline-block; line-height: 0; }
.mascot-xs { width: 34px; height: 34px; }
.mascot-md { width: 72px; height: 72px; }
.mascot-lg { width: 120px; height: 120px; }
.mascot-xl { width: 160px; height: 160px; }
.m-svg { width: 100%; height: 100%; overflow: visible; }
.m-skin { fill: var(--m-skin); stroke: var(--m-skin-edge); stroke-width: 3; }
.m-hat { fill: var(--m-hat); stroke: #e7b52c; stroke-width: 3; }
.m-cheek { fill: var(--m-cheek); opacity: .55; }
.m-ink { fill: var(--m-ink); }
.m-white { fill: #fff; }
.m-line { fill: none; stroke: var(--m-ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.m-mouth { fill: var(--m-ink); }
.m-part, .m-acc { display: none; }
.dot { fill: var(--muted); }
.bulb-glass { fill: #ffe066; stroke: #f0b400; stroke-width: 2; }
.bulb-base { fill: #b9a68a; }
.bulb-rays path { stroke: #f0b400; stroke-width: 3; stroke-linecap: round; fill: none; }
.pencil-body { fill: #ffd34d; stroke: #c99a10; stroke-width: 2; }
.pencil-tip { fill: #3a2a20; }
.sweat { fill: #7cc8ff; stroke: #4aa6e8; stroke-width: 1.5; }
.c1 { fill: #ff6b6b; } .c2 { fill: #4dabf7; } .c3 { fill: #51cf66; }

.mascot .m-body, .mascot .m-blink, .mascot .pencil, .mascot .dot, .mascot .acc-bulb, .mascot .acc-confetti, .mascot .sweat {
  transform-box: fill-box;
  transform-origin: center;
}

/* face per state */
.mascot[data-state="idle"] .eyes-normal, .mascot[data-state="idle"] .mouth-smile,
.mascot[data-state="wake"] .eyes-normal, .mascot[data-state="wake"] .mouth-o,
.mascot[data-state="thinking"] .eyes-up, .mascot[data-state="thinking"] .mouth-small, .mascot[data-state="thinking"] .acc-bubble,
.mascot[data-state="working"] .eyes-focus, .mascot[data-state="working"] .mouth-smile, .mascot[data-state="working"] .acc-pencil,
.mascot[data-state="idea"] .eyes-wide, .mascot[data-state="idea"] .mouth-o, .mascot[data-state="idea"] .acc-bulb,
.mascot[data-state="happy"] .eyes-happy, .mascot[data-state="happy"] .mouth-grin, .mascot[data-state="happy"] .acc-confetti,
.mascot[data-state="trouble"] .eyes-trouble, .mascot[data-state="trouble"] .mouth-wavy, .mascot[data-state="trouble"] .acc-sweat,
.mascot[data-slow] .acc-sweat { display: inline; }

/* motion per state */
.mascot .m-blink { animation: m-blink 4.2s infinite; }
.mascot[data-state="idle"] .m-body { animation: m-bob 3s ease-in-out infinite; }
.mascot[data-state="wake"] .m-body { animation: m-bob 1.2s ease-in-out infinite; }
.mascot[data-state="thinking"] .m-body { animation: m-ponder 2.6s ease-in-out infinite; }
.mascot[data-state="thinking"] .d1 { animation: m-dot 1.4s infinite; }
.mascot[data-state="thinking"] .d2 { animation: m-dot 1.4s .2s infinite; }
.mascot[data-state="thinking"] .d3 { animation: m-dot 1.4s .4s infinite; }
.mascot[data-state="working"] .m-body { animation: m-busy .5s ease-in-out infinite; }
.mascot[data-state="working"] .pencil { animation: m-scribble .35s ease-in-out infinite; }
.mascot[data-state="idea"] .m-body { animation: m-jump .6s ease-out; }
.mascot[data-state="idea"] .acc-bulb { animation: m-pop .4s ease-out, m-glow 1s .4s ease-in-out infinite; }
.mascot[data-state="happy"] .m-body { animation: m-jump .7s ease-out 2; }
.mascot[data-state="happy"] .acc-confetti { animation: m-confetti 1.4s ease-out forwards; }
.mascot[data-state="trouble"] .m-body { animation: m-shake .5s ease-in-out 2; }
.mascot .sweat { animation: m-drip 1.6s ease-in infinite; }

@keyframes m-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes m-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes m-ponder { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg) translateY(-2px); } }
@keyframes m-dot { 0%, 100% { opacity: .2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes m-busy { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px) rotate(-1deg); } }
@keyframes m-scribble { 0%, 100% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(-3px, 2px) rotate(-8deg); } }
@keyframes m-jump { 0% { transform: translateY(0); } 35% { transform: translateY(-10px) scale(1.03); } 70% { transform: translateY(1px) scale(.99, 1.01); } 100% { transform: none; } }
@keyframes m-pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes m-glow { 0%, 100% { opacity: 1; } 50% { opacity: .65; } }
@keyframes m-confetti { 0% { transform: translateY(-6px) scale(.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(14px) scale(1); opacity: 0; } }
@keyframes m-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes m-drip { 0% { transform: translateY(0); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(10px); opacity: 0; } }

/* ---- work panel (while Claude works) ---- */
.work-panel { display: flex; gap: 12px; align-items: center; width: 100%; min-width: 0; }
.work-info { flex: 1; min-width: 0; }
.work-line { margin: 0; font-weight: 700; }
.work-step { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 6px 0 4px; border: 2px solid var(--line); }
.work-fill {
  height: 100%; width: 3%; border-radius: 999px;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 10px, var(--accent-2) 10px 20px);
  background-size: 28px 28px;
  animation: work-stripes 1s linear infinite;
  transition: width 1s linear;
}
.work-meta { margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.work-panel.is-slow .work-fill { background: repeating-linear-gradient(-45deg, var(--accent-2) 0 10px, #ffd98a 10px 20px); }
.work-panel.is-done .work-fill { background: var(--mint); animation: none; }
.work-panel.is-failed .work-fill { background: var(--error); animation: none; }
@keyframes work-stripes { to { background-position: 28px 0; } }

/* ---- login ---- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 2px solid var(--line);
  border-radius: 28px; padding: 28px 24px 32px; text-align: center; box-shadow: var(--shadow);
}
.login-card .mascot { margin: 0 auto 4px; display: block; }
.login-card h1 { margin: 4px 0 2px; font-size: 26px; }
.login-card .btn { margin-top: 18px; }
.login-error { color: var(--error); font-size: 14px; }

/* ---- top bar ---- */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px 0 16px; border-bottom: 2px solid var(--line); background: var(--surface);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); text-decoration: none; font-size: 18px; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.usage {
  margin-left: auto; font-size: 13px; color: var(--muted); background: var(--surface-2);
  padding: 2px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.usage:empty { display: none; }
.usage-warn { color: var(--error); }
.logout { margin: 0; }

/* ---- home ---- */
.home { max-width: 760px; margin: 0 auto; padding: 20px 16px 56px; }
.hero {
  display: flex; align-items: center; gap: 20px; background: var(--surface);
  border: 2px solid var(--line); border-radius: 28px; padding: 20px 24px; box-shadow: var(--shadow);
}
.hero-hello { margin: 0; color: var(--muted); font-weight: 700; }
.hero-title { margin: 0 0 12px; font-size: 26px; line-height: 1.35; }
.section-title { font-size: 17px; margin: 32px 4px 10px; }
.examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.chip {
  display: flex; align-items: center; gap: 10px; text-align: left;
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 16px; padding: 12px 14px; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.chip span { font-size: 24px; line-height: 1; }
.chip:hover { border-color: var(--accent); transform: translateY(-2px) rotate(-.5deg); }
.project-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.project-card {
  display: flex; align-items: center; background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--radius); transition: transform .12s ease, border-color .12s ease;
}
.project-card:hover { border-color: var(--accent-2); transform: translateY(-1px); }
.project-link { flex: 1; display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: inherit; text-decoration: none; min-width: 0; }
.project-emoji {
  flex: none; width: 46px; height: 46px; display: grid; place-items: center; font-size: 26px;
  background: var(--accent-soft); border-radius: 14px;
}
.project-text { display: flex; flex-direction: column; min-width: 0; }
.project-title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-note { color: var(--muted); background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); padding: 16px; margin: 0; }
.error-box { max-width: 760px; margin: 24px auto; padding: 16px; color: var(--error); }

/* ---- workspace ---- */
body.in-project { overflow: hidden; }
.ws {
  height: calc(100dvh - 56px);
  display: grid;
  grid-template-columns: minmax(330px, 440px) 1fr;
}
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat { border-right: 2px solid var(--line); background: var(--surface); }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 2px solid var(--line); }
.title-input {
  flex: 1; min-width: 0; border: 2px solid transparent; background: transparent; color: var(--text);
  font: inherit; font-weight: 800; padding: 4px 8px; border-radius: 10px;
}
.title-input:hover, .title-input:focus { border-color: var(--line); outline: none; }
.model-select, .pv-versions {
  font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
}
.msgs { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.msg { max-width: 88%; padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; word-break: break-word; }
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin-bottom: 0; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 94%; }
.msg-row .msg { max-width: 100%; }
.avatar { flex: none; }
.msg-user { align-self: flex-end; background: var(--user-bubble); border-bottom-right-radius: 6px; }
.msg-assistant { background: var(--surface); border: 2px solid var(--line); border-bottom-left-radius: 6px; }
.msg-system { align-self: center; font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 4px 14px; }
.tools { font-size: 13px; color: var(--muted); margin: 4px 0; white-space: normal; }
.tools summary { cursor: pointer; }
.tools ul { margin: 4px 0 0; padding-left: 18px; }
.error-text { color: var(--error); }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 2px solid var(--line); background: var(--surface); }
.composer textarea {
  flex: 1; resize: none; font: inherit; padding: 10px 14px; border-radius: 18px;
  border: 2px solid var(--line); background: var(--bg); color: var(--text); min-height: 52px; max-height: 40dvh; line-height: 1.6;
}
.composer textarea:focus { outline: none; border-color: var(--accent-2); }
.composer .btn { align-self: flex-end; min-height: 48px; }

.preview { background: var(--bg); }
.pv-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 2px solid var(--line);
  background: var(--surface); flex-wrap: wrap;
}
.pv-bar .btn-small { min-width: 40px; min-height: 36px; padding: 4px 10px; }
.pv-versions { flex: 1; min-width: 120px; max-width: 360px; margin-left: auto; }
.pv-wrap { position: relative; flex: 1; min-height: 0; display: flex; justify-content: center; }
.pv-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.pv-wrap.phone { padding: 16px; }
.pv-wrap.phone .pv-frame { width: 390px; max-width: 100%; border-radius: 28px; border: 10px solid #2f2a24; box-shadow: var(--shadow); }
.pv-stage {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; background: var(--bg); text-align: center; padding: 16px;
}
.stage-line { margin: 0; font-weight: 800; font-size: 18px; }
.pv-stopped {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: var(--bg); text-align: center; padding: 16px;
}
/* The stop/play toggle is the one control people look for: make it stand apart. */
.pv-stop {
  font-weight: 800; background: var(--text); border-color: var(--text); color: var(--surface);
  padding-inline: 14px;
}
.pv-stop:hover { background: var(--text); filter: brightness(1.15); }
.pv-stop.is-stopped { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pv-sep { width: 2px; align-self: stretch; margin: 4px 2px; background: var(--line); border-radius: 2px; }
.pv-bar .lbl { font-size: 13px; }
@media (max-width: 1180px) { .pv-bar .lbl { display: none; } }
.tabs { display: none; }

/* ---- admin ---- */
.admin { max-width: 1000px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 32px; }
.admin h1 { font-size: 18px; margin: 0 0 10px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.admin-head h1 { margin: 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); }
.admin table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin th, .admin td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin th { color: var(--muted); font-weight: 700; font-size: 13px; }
.admin tr:last-child td { border-bottom: 0; }
.admin td.warn { color: var(--error); font-weight: 700; }
.row-deleted td { color: var(--muted); }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; background: var(--surface-2); color: var(--muted);
}
.link-btn {
  border: 0; background: none; padding: 0; font: inherit; color: var(--accent); font-weight: 700;
  cursor: pointer; text-align: left; white-space: normal;
}
.link-btn:hover { text-decoration: underline; }
.admin-msgs { max-height: 70vh; border: 2px solid var(--line); border-radius: var(--radius); }
.msg-time { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }

/* ---- review fixes: work panel layout, slow / failed / paused states, tap reaction ---- */
.msg-row .msg { min-width: 0; }
.msg-row:has(.has-panel) { width: 100%; max-width: 100%; }
.msg-row:has(.has-panel) .avatar { display: none; }
.msg.has-panel { flex: 1; }
.msg.has-panel > p:first-of-type { margin-top: 10px; }
.work-meta { display: flex; flex-wrap: wrap; gap: 0 8px; }
.slow-badge { flex-basis: 100%; white-space: normal; font-weight: 700; color: var(--text); }
.work-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.work-actions:empty { display: none; }
.work-actions { margin-top: 10px; }
.work-actions .btn { min-height: 48px; }

.mascot[data-slow] .acc-sweat { transform: scale(1.6); transform-origin: 100px 46px; }
.work-panel.is-slow .work-fill {
  width: 30% !important;
  animation: work-stripes 1s linear infinite, slow-sweep 2.4s ease-in-out infinite alternate;
}
@keyframes slow-sweep { from { margin-left: 0; } to { margin-left: 70%; } }
.work-panel.is-failed .work-fill { background: var(--muted); opacity: .45; animation: none; }
.work-panel.is-paused .work-fill,
.work-panel.is-paused .m-body,
.work-panel.is-paused .m-acc * { animation-play-state: paused !important; }

.mascot.is-pokeable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.mascot.m-poke { animation: m-poke .5s ease-out; }
@keyframes m-poke { 0% { transform: none; } 30% { transform: translateY(-8px) rotate(-6deg) scale(1.06); } 60% { transform: translateY(0) rotate(4deg); } 100% { transform: none; } }

.pv-wrap.pv-flash { animation: pv-flash 1s ease-out; }
@keyframes pv-flash { 0% { box-shadow: inset 0 0 0 6px var(--accent-2); } 100% { box-shadow: inset 0 0 0 0 transparent; } }

.login-tagline { text-wrap: balance; word-break: keep-all; }

/* ---- long titles: never push the layout wider than the screen ---- */
.project-card, .project-list > li { min-width: 0; }
.project-text { flex: 1; overflow: hidden; }
.project-title {
  white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.admin > section { min-width: 0; }
.admin td .link-btn { overflow-wrap: anywhere; }

/* ---- mini-game while waiting ---- */
.work-box { width: 100%; min-width: 0; }
.game-offer { border-color: var(--accent-2); background: var(--accent-soft); }
.tower-game {
  margin-top: 12px; padding: 8px; border: 2px dashed var(--accent-2); border-radius: var(--radius);
  background: var(--bg); display: flex; flex-direction: column; align-items: center;
}
.tower-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tower-score { font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.tower-canvas { display: block; touch-action: manipulation; cursor: pointer; border-radius: 12px; }
.tower-canvas:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.tower-stage { position: relative; }
.tower-over {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: color-mix(in srgb, var(--bg) 82%, transparent); border-radius: 12px;
}
.tower-over-text { margin: 0; font-weight: 800; font-size: 20px; }
.tower-over .btn { min-width: 140px; min-height: 44px; }
.tower-banner { width: 100%; margin: 8px 0 2px; font-weight: 800; text-align: center; }
.tower-banner p { margin: 0 0 8px; }
.tower-banner .btn { min-height: 48px; }
.tower-head .btn { min-height: 40px; }

/* ---- design harness (demo.html) ---- */
.demo-chat { max-width: 460px; min-height: 260px; margin-top: 12px; border: 2px solid var(--line); border-radius: var(--radius); }
.demo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.demo-card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.demo-card p { margin: 4px 0 0; }

/* ---- phones ---- */
@media (max-width: 800px) {
  .ws { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: calc(100dvh - 56px); }
  .ws[data-pane="chat"] .preview,
  .ws[data-pane="preview"] .chat { display: none; }
  .chat { border-right: 0; }
  .tabs {
    display: flex; border-top: 2px solid var(--line); background: var(--surface);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab {
    flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700;
    padding: 12px; position: relative; cursor: pointer;
  }
  .tab.active { color: var(--accent); }
  .tab.active::before {
    content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
  }
  .tab.has-update::after, .tab.is-working::after {
    content: ""; position: absolute; top: 12px; margin-left: 4px;
    width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  }
  .tab.is-working::after { background: var(--accent-2); animation: m-glow 1s ease-in-out infinite; }
  .pv-wrap.phone { padding: 0; }
  .pv-wrap.phone .pv-frame { border: 0; border-radius: 0; width: 100%; box-shadow: none; }
  .hero { flex-direction: column; text-align: center; padding: 20px 16px; gap: 8px; }
  .hero-title { font-size: 22px; }
  .mascot-lg { width: 96px; height: 96px; }
  .usage { font-size: 12px; }
  .brand span { display: none; }
  .brand { padding: 7px; margin: -7px; }
  .btn-small, .btn-icon, .pv-bar .btn-small, .model-select, .pv-versions { min-height: 44px; min-width: 44px; }

  /* admin tables become stacked cards */
  .admin .table-wrap { overflow: visible; background: none; border: 0; }
  .admin table, .admin tbody, .admin tr, .admin td { display: block; width: 100%; }
  .admin thead { display: none; }
  .admin tr {
    background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
    padding: 8px 12px; margin-bottom: 10px;
  }
  .admin td {
    display: flex; justify-content: space-between; gap: 12px; padding: 4px 0;
    border: 0; white-space: normal; text-align: right; overflow-wrap: anywhere;
  }
  .admin td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  .admin td:first-child { font-weight: 700; text-align: left; justify-content: flex-start; }
  .admin td:first-child::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* Long button labels (e.g. "待ってる間に つみきあそび") wrap instead of running off narrow screens. */
.btn-wide, .work-actions .btn, .tower-banner .btn { white-space: normal; text-align: center; line-height: 1.4; }
.work-actions { display: flex; flex-direction: column; gap: 8px; }
/* ---- sharing with the family ---- */
.pv-share { font-weight: 800; }
.pv-share.is-shared { background: var(--mint); border-color: var(--mint); color: #fff; }
.badge-shared { background: color-mix(in srgb, var(--mint) 18%, var(--surface)); color: var(--text); }
.play { height: calc(100dvh - 56px); display: flex; flex-direction: column; }
.play .pv-wrap { flex: 1; }
/* Title group takes the remaining width (at least ~14em); the buttons wrap to a second row when it doesn't fit. */
.play-bar { flex-wrap: wrap; row-gap: 6px; }
.play-info { flex: 1 1 14em; min-width: 0; display: flex; align-items: center; gap: 6px; }
.play-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.play-emoji { font-size: 22px; flex: none; }
.play-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.play-name {
  font-weight: 800; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.play-by { font-weight: 400; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- full screen preview (native Fullscreen API, or a page-filling fallback e.g. on iPhone) ---- */
.pv-wrap:fullscreen, .pv-wrap.pseudo-full { background: #000; padding: 0 !important; }
.pv-wrap.pseudo-full { position: fixed; inset: 0; z-index: 100; height: 100dvh; }
.pv-wrap:fullscreen .pv-frame, .pv-wrap.pseudo-full .pv-frame {
  width: 100% !important; height: 100% !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
}
.has-pseudo-full { overflow: hidden; }
.fs-exit {
  display: none; position: absolute; z-index: 2; left: 50%; transform: translateX(-50%);
  top: max(6px, env(safe-area-inset-top)); padding: 4px 12px; border: 0; border-radius: 999px;
  background: rgb(0 0 0 / .5); color: #fff; font: inherit; font-size: 13px; cursor: pointer; opacity: .55;
}
.fs-exit:hover, .fs-exit:focus-visible { opacity: 1; }
.pv-wrap:fullscreen .fs-exit, .pv-wrap.pseudo-full .fs-exit { display: block; }

/* ---- work summary & diff viewer ---- */
.worklog {
  margin-top: 10px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg);
  white-space: normal; font-size: 14px;
}
.worklog > summary {
  cursor: pointer; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-weight: 800;
}
.wl-head { font-weight: 400; color: var(--muted); font-size: 13px; }
.wl-sec { padding: 4px 12px 10px; border-top: 1px dashed var(--line); }
.wl-title { margin: 6px 0 4px; font-weight: 800; }
.wl-steps, .wl-files, .wl-tests { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 2px; }
.wl-tests { list-style: none; }
.wl-step { display: flex; gap: 6px; }
.wl-mark { width: 1.2em; flex: none; text-align: center; }
.wl-completed .wl-mark { color: var(--mint); }
.wl-pending { color: var(--muted); }
.wl-issues { margin: 2px 0 4px; padding-left: 18px; color: var(--muted); font-size: 13px; }
.wl-files li { display: flex; justify-content: space-between; gap: 8px; }
.wl-files code { overflow-wrap: anywhere; }
.wl-stat { flex: none; font-variant-numeric: tabular-nums; }
.wl-add { color: #1a7f37; font-weight: 700; }
.wl-del { color: #cf222e; font-weight: 700; }
.wl-bin { color: var(--muted); }
.wl-diff-btn { margin-top: 8px; }
.wl-auto { margin-left: 6px; color: var(--muted); font-size: 12px; }
code { font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace; font-size: .92em; }

.diff-overlay { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .45); display: grid; place-items: center; padding: 16px; }
.diff-dialog {
  width: min(1000px, 100%); max-height: 90dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
}
.diff-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 2px solid var(--line); }
.diff-head strong { flex: 1; min-width: 0; }
.diff-legend { font-size: 13px; }
.diff-body { overflow: auto; padding: 10px 14px 16px; display: grid; gap: 10px; }
.diff-file > summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.diff-code {
  margin: 4px 0 0; padding: 8px 0; border-radius: 10px; background: #0f1115; color: #d7dae0;
  font: 12.5px/1.55 ui-monospace, "SFMono-Regular", Consolas, monospace; overflow-x: auto; white-space: pre;
}
.dl { display: block; padding: 0 12px; }
.dl-add { background: rgb(46 160 67 / .22); color: #aff5b4; }
.dl-del { background: rgb(248 81 73 / .2); color: #ffc0bd; }
.dl-hunk { color: #79c0ff; background: rgb(56 139 253 / .12); }

/* ---- photo / drawing attachments ---- */
.composer { flex-wrap: wrap; }
.attach-tray { flex-basis: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
.attach-chip { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 2px solid var(--line); }
.attach-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-chip.is-uploading img { opacity: .5; }
.attach-wait { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; color: var(--text); }
.attach-remove {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgb(0 0 0 / .6); color: #fff; font-size: 14px; line-height: 22px; padding: 0; cursor: pointer;
}
.attach-btn { align-self: flex-end; min-height: 48px; min-width: 48px; font-size: 20px; }
.msg-photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.msg-photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 2px solid rgb(255 255 255 / .6); }

/* ---- announcements ticker (home) ---- */
.news-bar {
  display: flex; align-items: center; height: 36px; overflow: hidden;
  background: linear-gradient(90deg, var(--accent-soft), color-mix(in srgb, var(--accent-2) 30%, var(--surface)));
  border-bottom: 2px solid var(--line);
}
.news-badge {
  flex: none; margin: 0 4px 0 10px; padding: 2px 9px; border-radius: 999px;
  background: linear-gradient(135deg, #e8452f, #ff9a3c); color: #fff;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; line-height: 18px;
  box-shadow: 0 0 0 2px rgb(255 255 255 / .6), 0 2px 6px rgb(232 69 47 / .35);
  animation: news-glow 2.4s ease-in-out infinite;
}
@keyframes news-glow {
  0%, 100% { box-shadow: 0 0 0 2px rgb(255 255 255 / .6), 0 2px 6px rgb(232 69 47 / .35); }
  50% { box-shadow: 0 0 0 2px rgb(255 255 255 / .6), 0 0 14px rgb(255 120 60 / .75); }
}
.news-track {
  flex: 1; min-width: 0; height: 100%; overflow: hidden; border: 0; background: none; padding: 0;
  font: inherit; color: var(--text); cursor: pointer; text-align: left; position: relative;
  mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
}
.news-text {
  display: inline-block; white-space: nowrap; font-size: 14px; font-weight: 700; line-height: 36px;
  padding-left: 100%; animation: news-scroll 26s linear infinite;
}
.news-track:hover .news-text, .news-track:focus-visible .news-text { animation-play-state: paused; }
@keyframes news-scroll { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.news-close {
  flex: none; width: 40px; height: 36px; border: 0; background: none; color: var(--muted);
  font-size: 20px; cursor: pointer;
}
.news-close:hover { color: var(--text); }
@media (prefers-reduced-motion: reduce) {
  .news-text { padding-left: 12px; animation: none; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

.news-overlay { position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / .45); display: grid; place-items: center; padding: 16px; }
.news-dialog {
  width: min(520px, 100%); max-height: 90dvh; overflow-y: auto; background: var(--surface);
  border-radius: 24px; padding: 20px 20px 16px; box-shadow: var(--shadow);
}
.news-title { margin: 0 0 8px; font-size: 20px; }
.news-dialog p { margin: 0 0 8px; }
.news-sub { font-weight: 800; margin-top: 12px !important; }
.news-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.news-example { cursor: default; font-size: 14px; padding: 6px 12px; border-radius: 999px; }
.news-notes { margin: 0 0 14px; padding-left: 20px; color: var(--muted); font-size: 14px; }
.news-actions { display: grid; gap: 8px; }

/* ---- 📰 past announcements (top bar button + list) ---- */
.news-link { position: relative; padding-inline: 10px; }
.news-link .lbl { font-size: 13px; }
.news-dot {
  position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--surface);
}
.news-back { margin: -6px 0 6px -8px; }
.news-date { margin: 0 0 2px !important; font-size: 13px; color: var(--muted); }
.news-list { list-style: none; margin: 4px 0 14px; padding: 0; display: grid; gap: 8px; }
.news-item {
  width: 100%; display: grid; gap: 2px; text-align: left; cursor: pointer; font: inherit; color: var(--text);
  background: var(--surface-2); border: 2px solid var(--line); border-radius: 16px; padding: 10px 14px; min-height: 44px;
}
.news-item:hover { border-color: var(--accent-2); }
.news-item:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.news-item-head { display: flex; align-items: center; gap: 8px; }
.news-item-date { font-size: 13px; color: var(--muted); }
.news-item-new {
  padding: 0 8px; border-radius: 999px; background: #d93a22; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .06em;
}
.news-item-title { font-weight: 800; }
.news-item-sum {
  font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
@media (max-width: 800px) { .news-link .lbl { display: none; } }

/* ---- questions before a big build (choice buttons) ---- */
.ask-box {
  margin-top: 10px; padding: 12px; border-radius: 16px; background: var(--surface-2);
  border: 2px solid var(--accent-2); display: grid; gap: 10px;
}
.ask-box.is-answered { border-color: var(--line); opacity: .7; }
.ask-lead { margin: 0; font-size: 13px; color: var(--muted); font-weight: 700; }
.ask-q-text { margin: 0 0 6px; font-weight: 800; }
.ask-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-opt { min-height: 44px; font-size: 15px; padding: 8px 14px; border-radius: 999px; }
/* the bubble with questions uses the full width, so the choices fit side by side */
.msg-row:has(.ask-box) { width: 100%; max-width: 100%; }
.msg-row:has(.ask-box) .msg { flex: 1; }
.ask-opt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ask-opt:disabled { cursor: default; }
.ask-actions { display: grid; gap: 8px; margin-top: 2px; }
.ask-box.is-answered .ask-actions { display: none; }

/* ---- in-app name ---- */
.hero-hello-wrap { display: grid; gap: 4px; }
.name-edit { padding: 2px 6px; margin-left: 4px; min-height: 0; font-size: 14px; vertical-align: middle; }
.name-hint { margin: 0; font-size: 13px; color: var(--muted); }
.name-form { margin: 6px 0 4px; }
.name-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: inherit; }
.name-input {
  flex: 1; min-width: 0; max-width: 260px; min-height: 44px; padding: 8px 14px; font: inherit; font-size: 16px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text);
}
.name-input:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 1px; }
.name-status { margin: 4px 0 0; font-size: 13px; color: var(--error); min-height: 1em; }
@media (max-width: 800px) { .name-row { justify-content: center; } }

/* ---- ☆ favorites ---- */
.fav-btn { font-size: 22px; color: var(--muted); line-height: 1; }
.fav-btn.is-on { color: #e7a500; }
.fav-btn:hover { color: #e7a500; }
.project-card.is-fav { border-color: color-mix(in srgb, #e7a500 45%, var(--line)); }

/* ---- 📝 design notes ---- */
.notes-text {
  margin: 0 0 14px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 2px solid var(--line);
  white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.7 var(--font); max-height: 60dvh; overflow-y: auto;
}

/* ---- collapsible idea list on the home screen ---- */
.ideas > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.ideas > summary::-webkit-details-marker { display: none; }
.ideas > summary::after { content: "▸"; margin-left: 4px; color: var(--muted); transition: transform .15s ease; }
.ideas[open] > summary::after { transform: rotate(90deg); }
.ideas-hint { font-size: 13px; font-weight: 400; color: var(--muted); }
.ideas[open] .ideas-hint { display: none; }

/* ---- comments & requests ---- */
.card-share { filter: grayscale(1); opacity: .55; }
.card-share.is-shared { filter: none; opacity: 1; background: color-mix(in srgb, var(--mint) 18%, transparent); }
.badge-new { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cmt-open { position: relative; }
.cmt-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent);
  color: var(--accent-text); font-size: 12px; font-weight: 800; line-height: 20px;
}
.cmt-panel {
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
  background: var(--surface); border-bottom: 2px solid var(--line); padding: 10px 12px;
}
.cmt-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cmt-slot .cmt-panel { max-height: 55%; overflow: hidden; }
.cmt-slot { display: contents; }
.cmt-scroll { overflow-y: auto; min-height: 0; flex: 1; }
.cmt-write { overflow-y: auto; min-height: 0; flex: 1; }
.cmt-tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.cmt-tab {
  flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 800; cursor: pointer;
}
.cmt-tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgb(0 0 0 / .1); }
.cmt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cmt { background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.cmt-request { border-color: var(--accent-2); }
.cmt-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cmt-author { font-weight: 800; }
.cmt-time { color: var(--muted); }
.cmt-del { margin-left: auto; min-width: 32px; min-height: 32px; padding: 2px; }
.cmt-text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmt-use { margin-top: 6px; }
.cmt-empty { color: var(--muted); margin: 0; }
.cmt-form { display: grid; gap: 8px; }
.cmt-quick, .cmt-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.cmt-quick-btn, .cmt-kind-btn { padding: 6px 12px; font-size: 14px; border-radius: 999px; }
.cmt-kind-btn.is-on { border-color: var(--accent); background: var(--accent-soft); }
.cmt-row { display: flex; gap: 8px; }
.cmt-row textarea {
  flex: 1; resize: none; font: inherit; padding: 8px 12px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--bg); color: var(--text);
}
.cmt-row .btn { align-self: flex-end; min-height: 44px; }
.cmt-status { margin: 0; font-size: 13px; color: var(--muted); min-height: 1em; }

/* play screen: comments as a side panel (desktop) or a bottom sheet (phone) */
.play-body { position: relative; flex: 1; display: flex; min-height: 0; }
.play-body .pv-wrap { flex: 1; }
.play .cmt-panel { display: none; width: 360px; border-bottom: 0; border-left: 2px solid var(--line); overflow: hidden; }
.play.show-cmt .cmt-panel { display: flex; }
@media (max-width: 800px) {
  .play .cmt-panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 85%;
    border-left: 0; border-top: 2px solid var(--line); border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
  }
  .play-actions { margin-left: 0; width: 100%; }
}

.msg-note { font-size: 14px; background: var(--accent-soft); border-radius: 12px; padding: 8px 12px; }
