:root {
  --mw-ts-paper: #faf8f4;
  --mw-ts-ink: #1a1a1a;
  --mw-ts-muted: #5c5c5c;
  --mw-ts-accent: #0ea5e9;
  --mw-ts-danger: #ef4444;
  --mw-ts-font-hand: "Caveat", "Kalam", cursive;
  --mw-ts-font-ui: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over class-level display rules
   (.mw-ts-dock / .mw-ts-stage / .mw-ts-paywall use display:grid|flex which
   would otherwise override the UA [hidden]{display:none} rule). */
.mw-tutor-session [hidden] { display: none !important; }

body.mw-tutor-session {
  margin: 0;
  min-height: 100vh;
  background: #eceae4;
  color: var(--mw-ts-ink);
  font-family: var(--mw-ts-font-ui);
}

.mw-ts-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mw-ts-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.mw-ts-brand {
  font-weight: 700;
  color: var(--mw-ts-ink);
  text-decoration: none;
}

.mw-ts-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
}

.mw-ts-profile-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f0fdf4;
  color: #166534;
  max-width: min(420px, 45vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mw-ts-support-offer {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 6px 3px 10px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid rgba(154, 52, 18, 0.2);
  max-width: min(280px, 40vw);
}

.mw-ts-support-offer__link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mw-ts-support-offer__dismiss {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
}

.mw-ts-support-offer__dismiss:hover {
  background: rgba(154, 52, 18, 0.1);
}

.mw-ts-fallback {
  margin-left: auto;
  font-size: 14px;
  color: var(--mw-ts-muted);
}

.mw-ts-onboarding {
  max-width: 560px;
  margin: 48px auto;
  padding: 24px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.08);
}

.mw-ts-onboarding h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.mw-ts-sub {
  color: var(--mw-ts-muted);
  margin: 0 0 20px;
}

.mw-ts-demo-notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #fbbf24;
  background: #fffbeb;
  color: #78350f;
  font-size: 0.92rem;
  line-height: 1.5;
}

.mw-ts-demo-notice a {
  color: #1d4ed8;
}

.mw-ts-field {
  margin-bottom: 14px;
}

.mw-ts-field label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--mw-ts-muted);
}

.mw-ts-field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 15px;
}

.mw-ts-radio-group {
  border: none;
  margin: 0 0 18px;
  padding: 0;
}

.mw-ts-radio-group legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--mw-ts-ink);
  margin-bottom: 8px;
}

.mw-ts-radio-card {
  display: block;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.mw-ts-radio-card:has(input:checked) {
  border-color: var(--mw-ts-accent);
  background: rgba(14,165,233,.06);
}

.mw-ts-radio-card input {
  margin-right: 8px;
}

.mw-ts-radio-card__title {
  display: block;
  font-weight: 600;
  font-size: 14px;
}

.mw-ts-radio-card__hint {
  display: block;
  font-size: 12px;
  color: var(--mw-ts-muted);
  margin-top: 2px;
  margin-left: 24px;
}

.mw-ts-primary {
  background: #111;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 15px;
  cursor: pointer;
}

.mw-ts-ghost {
  background: transparent;
  border: 1px solid #ccc;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
}

.mw-ts-status {
  min-height: 1.2em;
  font-size: 13px;
  color: var(--mw-ts-muted);
  margin-top: 10px;
}

.mw-ts-stage {
  flex: 1;
  padding: 12px;
  display: flex;
}

.mw-ts-board {
  flex: 1;
  min-height: 60vh;
  background: var(--mw-ts-paper);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04), 0 12px 40px rgba(0,0,0,.06);
  position: relative;
  overflow: auto;
  min-height: 480px;
}

.mw-ts-board-object {
  position: absolute;
  font-family: var(--mw-ts-font-hand);
  font-size: 1.35rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.mw-ts-board-object--bold { font-weight: 700; font-size: 1.5rem; }
.mw-ts-board-object--highlight {
  background: rgba(250, 204, 21, .35);
  padding: 2px 8px;
  border-radius: 4px;
}

.mw-ts-board-object.mw-ts-focused {
  outline: 3px solid var(--mw-ts-danger);
  outline-offset: 4px;
  animation: mwTsPulse 900ms ease 2;
}

.mw-ts-annotation {
  position: absolute;
  pointer-events: none;
  border: 3px solid var(--mw-ts-accent);
  border-radius: 50%;
  opacity: 0;
  animation: mwTsFadeIn 400ms ease forwards;
}

.mw-ts-annotation--red { border-color: var(--mw-ts-danger); }

.mw-ts-chart {
  position: absolute;
  opacity: 0;
  animation: mwTsFadeIn 500ms ease forwards;
}

.mw-ts-chart-title {
  margin-top: 6px;
  text-align: center;
  font-family: var(--mw-ts-font-hand);
  font-size: 1rem;
}

.mw-ts-rough-annotation {
  opacity: 0;
  animation: mwTsFadeIn 520ms ease forwards;
}

.mw-ts-diagram-wrap {
  position: absolute;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}

.mw-ts-mic.is-muted {
  opacity: 0.45;
  box-shadow: none;
  animation: none;
}

.mw-ts-complete {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 24px;
}

.mw-ts-complete-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  width: min(420px, 100%);
  box-shadow: 0 16px 48px rgba(0,0,0,.15);
  text-align: center;
}

.mw-ts-complete-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.mw-ts-dock {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 16px;
  background: rgba(255,255,255,.92);
  border-top: 1px solid rgba(0,0,0,.06);
}

.mw-ts-dock-left, .mw-ts-dock-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mw-ts-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #eee;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.mw-ts-caption {
  margin: 0;
  text-align: center;
  font-size: 15px;
  min-height: 1.4em;
}

.mw-ts-mic {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #fce7f3;
  font-size: 20px;
  cursor: pointer;
}

.mw-ts-mic.is-listening {
  box-shadow: 0 0 0 4px rgba(236,72,153,.35);
  animation: mwTsPulse 1s ease infinite;
}

.mw-ts-mic--off {
  opacity: 0.55;
  background: #e5e7eb;
}

.mw-ts-answer-panel {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 24px));
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.15);
  z-index: 20;
}

.mw-ts-question {
  margin: 0 0 10px;
  font-weight: 600;
}

#mwTsAnswerInput {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #ddd;
  padding: 10px;
  font-family: inherit;
  resize: vertical;
}

.mw-ts-answer-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.mw-ts-check-feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.mw-ts-check-feedback.is-ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.mw-ts-check-feedback.is-miss {
  background: #fff7ed;
  border-color: #fed7aa;
}

.mw-ts-check-feedback.is-skip {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.mw-ts-check-feedback__label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  margin-bottom: 4px;
}

.mw-ts-check-feedback__msg {
  margin: 0;
  font-size: 14px;
  color: #0f172a;
}

.mw-ts-paywall {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: grid;
  place-items: center;
  z-index: 50;
}

.mw-ts-paywall-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  text-align: center;
}

.mw-ts-link-btn {
  display: inline-block;
  text-decoration: none;
  margin: 12px 0;
}

@keyframes mwTsFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mwTsPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* S01 orchestrator debug panel */
.mw-ts-debug {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 80;
  width: min(280px, calc(100vw - 24px));
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.mw-ts-debug__toggle {
  width: 100%;
  border: 0;
  background: #0f172a;
  color: #94a3b8;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 10px 10px 0 0;
  font: inherit;
}
.mw-ts-debug.is-collapsed .mw-ts-debug__body { display: none; }
.mw-ts-debug.is-collapsed .mw-ts-debug__toggle { border-radius: 10px; }
.mw-ts-debug__body { padding: 10px 12px 12px; }
.mw-ts-debug__state { margin: 0 0 8px; }
.mw-ts-debug__state strong { color: #38bdf8; }
.mw-ts-debug__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mw-ts-debug__actions button {
  border: 1px solid #334155;
  background: #334155;
  color: #f8fafc;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font: inherit;
}
.mw-ts-debug__actions button:hover { background: #475569; }
.mw-ts-debug__actions a.mw-ts-debug__link {
  border: 1px solid #0ea5e9;
  background: #0369a1;
  color: #f8fafc;
  border-radius: 6px;
  padding: 4px 8px;
  text-decoration: none;
  font: inherit;
}
.mw-ts-debug__error {
  margin: 8px 0 0;
  color: #fca5a5;
  white-space: pre-wrap;
}
