/* Mewse: Errand Run. Scoped to .mw so it cannot leak into the host page. Tokens from 07-agent-identity.md (Mewse). */
.mw {
  --mw-ink: #14130F;
  --mw-cocoa: #5A4732;
  --mw-surface: #F8F2E9;
  --mw-stage: #F2E7D3;
  --mw-stage-line: #E3D2B4;
  --mw-well: #FBF7F0;
  --mw-lane-alt: #F4ECDD;
  --mw-cell: #E3D2B4;
  --mw-live: #E2D4F7;
  --mw-accent: #8A5BB0;
  --mw-accent-ink: #FFFFFF;
  --mw-fx: #F49AB8;
  --mw-band-1: #F9D3E0;
  --mw-band-2: #FBDCC4;
  --mw-band-3: #CFE6FB;
  --mw-white: #FFFFFF;
  box-sizing: border-box;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  color: var(--mw-ink);
  background: var(--mw-surface);
  border: 2px solid var(--mw-ink);
  border-radius: 12px;
  font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
}
.mw *, .mw *::before, .mw *::after { box-sizing: border-box; }
.mw [hidden] { display: none !important; }
.mw h2, .mw h3, .mw p { margin: 0; }
.mw-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.mw-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.mw-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.mw-tagline { color: var(--mw-cocoa); font-size: 0.95rem; }

.mw-btn {
  min-height: 48px; min-width: 48px; padding: 8px 16px;
  font: inherit; font-weight: 600; color: var(--mw-ink); background: var(--mw-white);
  border: 2px solid var(--mw-ink); border-radius: 14px; cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mw-btn:hover { background: var(--mw-live); }
.mw-btn:focus-visible { outline: 3px solid var(--mw-accent); outline-offset: 2px; }
.mw-btn:active { transform: translateY(1px); }
.mw-btn[disabled], .mw-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.mw-btn--accent { background: var(--mw-accent); color: var(--mw-accent-ink); }
.mw-btn--accent:hover { background: #7A4DA0; }
.mw-btn--toggle[aria-pressed="true"] { background: var(--mw-live); }
.mw-btn--toggle[aria-pressed="true"]::before { content: "\2713\00a0"; }

/* start + over panels */
.mw-panel { display: grid; grid-template-columns: 1fr; gap: 16px; }
.mw-card { background: var(--mw-white); border: 2px solid var(--mw-cocoa); border-radius: 18px; padding: 16px; }
.mw-card h3 { font-size: 1.15rem; margin-bottom: 8px; }
.mw-goal { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.mw-steps { margin: 0 0 12px; padding-left: 1.25rem; }
.mw-steps li { margin: 2px 0; }
.mw-facts { display: grid; gap: 6px; margin: 0 0 12px; font-size: 0.95rem; }
.mw-facts p { padding: 8px 12px; background: var(--mw-stage); border-radius: 12px; }
.mw-keys { font-size: 0.9rem; color: var(--mw-cocoa); margin-bottom: 12px; }
.mw-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mw-over-title { font-size: 1.4rem; font-weight: 700; }
.mw-over-score { font-size: 1.05rem; margin: 6px 0; }
.mw-share-field { width: 100%; min-height: 48px; margin-top: 8px; padding: 8px; font: inherit; font-size: 0.9rem; border: 2px solid var(--mw-cocoa); border-radius: 12px; background: var(--mw-well); color: var(--mw-ink); }

/* agent side */
.mw-stage-wrap { display: grid; grid-template-columns: 1fr; gap: 12px; }
.mw-agent { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--mw-stage); border: 2px solid var(--mw-stage-line); border-radius: 18px; min-width: 0; }
.mw-mascot { flex: 0 0 56px; width: 56px; height: 56px; }
.mw-mascot svg, .mw-mascot img { display: block; width: 100%; height: 100%; }
.mw-name { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; color: var(--mw-cocoa); }
.mw-bubble {
  position: relative; flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 8px 12px; font-size: 0.9rem;
  background: var(--mw-white); border: 2px solid var(--mw-cocoa); border-radius: 18px; overflow-wrap: anywhere;
}
.mw-bubble::before { content: ""; position: absolute; left: -9px; top: 14px; width: 12px; height: 12px; background: var(--mw-white); border-left: 2px solid var(--mw-cocoa); border-bottom: 2px solid var(--mw-cocoa); transform: rotate(45deg); }
.mw-bubble:empty { visibility: hidden; }
.mw:not(.mw-reduced) .mw-mascot { animation: mw-bob 2.4s steps(2, end) infinite; }
.mw:not(.mw-reduced) .mw-mascot.is-happy { animation: mw-hop 0.5s steps(4, end) 2; }
.mw:not(.mw-reduced) .mw-mascot.is-hit { animation: mw-shake 0.3s steps(3, end) 2; }
.mw-mascot .mw-happy-eyes { display: none; }
.mw-mascot.is-happy .f-eyes { display: none; }
.mw-mascot.is-happy .mw-happy-eyes { display: inline; }
@keyframes mw-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes mw-hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes mw-shake { 0%, 100% { transform: translateX(0); } 33% { transform: translateX(-4px); } 66% { transform: translateX(4px); } }

/* play */
.mw-play { min-width: 0; }
.mw-hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.mw-chip { padding: 4px 8px; background: var(--mw-white); border: 2px solid var(--mw-cocoa); border-radius: 12px; min-width: 0; }
.mw-chip span { display: block; font-size: 0.65rem; color: var(--mw-cocoa); text-transform: uppercase; letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-chip strong { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mw-errand { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; padding: 6px 10px; background: var(--mw-stage); border-radius: 12px; font-size: 0.95rem; }
.mw-tag { padding: 1px 8px; font-size: 0.8rem; font-weight: 700; color: var(--mw-accent-ink); background: var(--mw-accent); border-radius: 999px; }
.mw-tag--big::before { content: "\2605\00a0"; }

.mw-board { position: relative; margin: 0 auto; width: 100%; max-width: 100%; }
.mw-board:focus { outline: none; }
.mw-canvas { display: block; margin: 0 auto; border: 2px solid var(--mw-cocoa); border-radius: 12px; background: var(--mw-well); touch-action: none; }
.mw-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 8px; }
.mw-overlay .mw-card { max-width: 100%; width: 300px; text-align: center; box-shadow: 0 0 0 6px rgba(248, 242, 233, 0.8); }
.mw-dots { display: flex; justify-content: center; gap: 8px; margin: 8px 0; }
.mw-dots i { width: 12px; height: 12px; border: 2px solid var(--mw-cocoa); border-radius: 50%; background: var(--mw-white); }
.mw-dots i.on { background: var(--mw-accent); }
.mw-gate-actions { display: flex; gap: 8px; justify-content: center; }
.mw-gate-actions .mw-btn { flex: 1 1 0; padding-inline: 8px; }

.mw-status { margin-top: 8px; font-size: 0.9rem; color: var(--mw-cocoa); min-height: 1.4em; }
.mw-controls { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 8px; margin-top: 8px; }
.mw-pad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 4px; }
.mw-pad .mw-btn { width: 56px; height: 56px; padding: 0; font-size: 1.4rem; line-height: 1; }
.mw-pad [data-dir="up"] { grid-column: 2; grid-row: 1; }
.mw-pad [data-dir="left"] { grid-column: 1; grid-row: 2; }
.mw-pad [data-dir="down"] { grid-column: 2; grid-row: 2; }
.mw-pad [data-dir="right"] { grid-column: 3; grid-row: 2; }
.mw-side { display: grid; gap: 6px; flex: 1 1 120px; min-width: 0; }
.mw-side .mw-btn { width: 100%; min-height: 52px; }
.mw-note { margin-top: 12px; font-size: 0.8rem; color: var(--mw-cocoa); }

@media (max-width: 759px) { .mw[data-screen="play"] .mw-tagline { display: none; } .mw[data-screen="play"] .mw-head { margin-bottom: 8px; } }
@media (min-width: 760px) {
  .mw { padding: 24px; }
  .mw-stage-wrap { grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
  .mw-agent { flex-direction: column; align-items: stretch; padding: 12px; }
  .mw-mascot { flex-basis: auto; width: 180px; height: 180px; align-self: center; }
  .mw-name { text-align: center; }
  .mw-bubble { order: -1; }
  .mw-bubble::before { left: 50%; top: auto; bottom: -9px; margin-left: -6px; border-left: 0; border-bottom: 2px solid var(--mw-cocoa); border-right: 2px solid var(--mw-cocoa); }
  .mw-panel { grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (max-height: 520px) and (max-width: 759px) { .mw-mascot { flex-basis: 40px; width: 40px; height: 40px; } }

@media (forced-colors: active) {
  .mw-btn, .mw-card, .mw-chip, .mw-canvas { border-color: CanvasText; }
  .mw-btn:focus-visible { outline-color: Highlight; }
}
.mw-reduced *, .mw-reduced *::before, .mw-reduced *::after { animation: none !important; transition: none !important; }
