/* MonkeyBrain Web Portal & MonkeyPatch Shared Design System
 * Aligned with design-system/tokens.css, mp.css & DESIGN.md
 */

/* Colors, type, radii and motion come from /tokens.css (design-system/tokens.css).
 * This file only adds portal-specific aliases. Never hardcode a hex here. */
:root {
  --mp-shadow-pop: var(--mp-shadow-menu);

  /* Legacy portal aliases */
  --bg:            var(--mp-surface-base);
  --surface:       var(--mp-surface-card);
  --surface-hover: var(--mp-surface-muted);
  --border:        var(--mp-border-default);
  --text:          var(--mp-text-primary);
  --muted:         var(--mp-text-secondary);
  --primary:       var(--mp-action-primary);
  --primary-hover: var(--mp-action-primary-hover);
  --danger:        var(--mp-status-error);
  --success:       var(--mp-status-success);
  --radius:        var(--mp-radius-group);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: var(--mp-font);
  background: var(--mp-bg);
  color: var(--mp-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--mp-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--mp-border-strong);
}

a {
  color: var(--mp-text);
  text-decoration: none;
  transition: color 120ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

a:hover {
  color: var(--mp-accent-ink);
}

:focus-visible {
  outline: 2px solid var(--mp-focus);
  outline-offset: 2px;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Icons (Lucide SVG) ---------- */
.mp-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

.mp-icon--sm {
  width: 14px;
  height: 14px;
}

.mp-tile {
  width: 36px;
  height: 36px;
  border-radius: var(--mp-radius-sm);
  flex-shrink: 0;
  background: var(--mp-surface-raised);
  color: var(--mp-text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mp-tile--accent {
  background: var(--mp-accent-tint);
  color: var(--mp-accent-ink);
}

/* ---------- Top Navigation Bar ---------- */
.topbar {
  background: color-mix(in srgb, var(--mp-surface-base) 86%, transparent);
  border-bottom: 1px solid var(--mp-border-subtle);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--mp-text) !important;
  text-decoration: none !important;
  flex-shrink: 0;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
}

.brand-title {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.015em;
  color: var(--mp-text);
}

.brand-sub {
  font-size: 12px;
  color: var(--mp-text-3);
  margin-left: 6px;
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.nav-pill-track {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
}

.nav-pill {
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--mp-text-3) !important;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none !important;
  transition: background 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.nav-pill:hover {
  color: var(--mp-text) !important;
}

/* Active navigation = amber (same rule as the extension's primary nav) */
.nav-pill.active,
.nav-pill[aria-current="page"] {
  background: var(--mp-action-primary);
  box-shadow: inset 0 0 0 1px var(--mp-action-primary-edge);
  color: var(--mp-action-on-primary) !important;
  font-weight: 600;
}

.nav-pill.active .mp-icon,
.nav-pill[aria-current="page"] .mp-icon {
  color: var(--mp-action-on-primary);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mp-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--mp-radius-sm);
  font-size: 12px;
  color: var(--mp-text-2);
}

.mp-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mp-success);
  flex-shrink: 0;
}

.mp-avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mp-surface-raised);
  border: 1px solid var(--mp-border);
  color: var(--mp-text) !important;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.mp-avatar-btn:hover,
.mp-avatar-btn.active {
  border-color: var(--mp-action-primary-edge);
  color: var(--mp-accent-ink) !important;
}

/* ---------- Main Layout & Hero ---------- */
.main-content {
  padding-top: 32px;
  padding-bottom: 64px;
  min-height: calc(100vh - 130px);
}

.hero {
  text-align: center;
  max-width: 740px;
  margin: 16px auto 40px;
}

.hero h1 {
  font-size: 32px;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 14px 0 12px;
  color: var(--mp-text);
}

.hero-lead {
  color: var(--mp-text-2);
  font-size: 16px;
  line-height: 1.55;
  margin: 0 auto 24px;
  max-width: 640px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Badges & Status ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--mp-radius-xs);
  background: var(--mp-surface-raised);
  color: var(--mp-text-2);
  border: 1px solid var(--mp-border-subtle);
  white-space: nowrap;
}

.badge-new {
  background: var(--mp-accent-tint);
  color: var(--mp-accent-ink);
  border-color: var(--mp-accent-line);
}

.badge-danger {
  background: var(--mp-error-tint);
  color: var(--mp-error);
  border-color: var(--mp-error-line);
}

.badge-success {
  background: var(--mp-success-tint);
  color: var(--mp-success);
  border-color: var(--mp-success-line);
}

/* ---------- Grids & Cards ---------- */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  gap: 16px;
}

.grid-3 > *,
.grid-2 > * {
  min-width: 0;
}

.card {
  background: var(--mp-surface);
  border: 1px solid var(--mp-border-subtle);
  border-radius: var(--mp-radius-group);
  padding: 22px 24px;
  min-width: 0;
  max-width: 100%;
}

.card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--mp-text);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--mp-text);
}

.auth-card {
  max-width: 440px;
  margin: 24px auto;
}

.muted {
  color: var(--mp-text-2);
  font-size: 13.5px;
}

.auth-switch {
  margin-top: 16px;
  margin-bottom: 0;
  font-size: 13px;
  color: var(--mp-text-2);
  text-align: center;
}

.auth-switch a {
  color: var(--mp-text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Form Controls ---------- */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--mp-text-2);
}

.form-group input,
.form-group select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--mp-radius-control);
  border: 1px solid var(--mp-border);
  background: var(--mp-surface-input);
  color: var(--mp-text);
  font-family: var(--mp-font);
  font-size: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.form-group input::placeholder,
.code-textarea::placeholder {
  color: var(--mp-text-placeholder);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--mp-focus);
  box-shadow: 0 0 0 3px var(--mp-action-subtle);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  font-family: var(--mp-font);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--mp-radius-control);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: var(--mp-radius-sm);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--mp-action-primary);
  border-color: var(--mp-action-primary-edge);
  color: var(--mp-action-on-primary) !important;
  box-shadow: var(--mp-shadow-sm);
}

.btn-primary:hover {
  background: var(--mp-action-primary-hover);
  color: var(--mp-action-on-primary) !important;
}

.btn-primary:active {
  background: var(--mp-action-primary-pressed);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--mp-focus-ring);
}

.btn-outline {
  background: var(--mp-surface-card);
  border-color: var(--mp-border);
  color: var(--mp-text) !important;
}

.btn-outline:hover {
  background: var(--mp-action-subtle-hover);
  border-color: var(--mp-action-subtle-edge);
  color: var(--mp-text) !important;
}

.btn-tertiary {
  background: transparent;
  border-color: transparent;
  color: var(--mp-text-2) !important;
  padding: 0 10px;
}

.btn-tertiary:hover {
  background: var(--mp-surface-raised);
  color: var(--mp-text) !important;
}

.btn-danger {
  background: transparent;
  border-color: var(--mp-error-line);
  color: var(--mp-error) !important;
}

.btn-danger:hover {
  background: var(--mp-error-tint);
  color: var(--mp-error) !important;
}

.btn.disabled,
.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.mt-4 {
  margin-top: 20px;
}

/* ---------- Key-Value & List Groups ---------- */
.kv-list {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
  border-radius: var(--mp-radius-card);
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  overflow: hidden;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--mp-divider);
  font-size: 13.5px;
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv-label {
  color: var(--mp-text-2);
}

.kv-val {
  color: var(--mp-text);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--mp-radius-card);
  border: 1px solid var(--mp-border-subtle);
  background: var(--mp-surface-sunken);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--mp-divider);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--mp-surface-muted);
}

.table th {
  color: var(--mp-text-3);
  font-weight: 600;
  font-size: 12px;
  background: var(--mp-surface-sunken);
}

/* ---------- Code, Pre & Token Boxes ---------- */
code {
  font-family: var(--mp-mono);
  font-size: 12px;
  background: var(--mp-surface-code);
  color: var(--mp-text-2);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--mp-border-subtle);
  overflow-wrap: anywhere;
}

pre {
  font-family: var(--mp-mono);
  max-width: 100%;
  overflow-x: auto;
}

.token-reveal {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--mp-radius-card);
  background: var(--mp-success-tint);
  border: 1px solid var(--mp-success-line);
  font-size: 13px;
}

.token-copy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.token-copy-row code {
  flex: 1;
  padding: 8px 12px;
  background: var(--mp-surface-code);
  border-radius: var(--mp-radius-sm);
  border: 1px solid var(--mp-border);
  word-break: break-all;
  color: var(--mp-success);
}

.download-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  border-radius: var(--mp-radius-card);
  margin: 14px 0;
  flex-wrap: wrap;
}

.divider {
  border: 0;
  border-top: 1px solid var(--mp-divider);
  margin: 22px 0;
}

.steps-list {
  padding-left: 20px;
  color: var(--mp-text-2);
}

.steps-list li {
  margin-bottom: 10px;
}

.steps-list li strong {
  color: var(--mp-text);
}

.version-pill {
  font-family: var(--mp-mono);
  font-size: 12px;
  padding: 5px 10px;
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  border-radius: var(--mp-radius-pill);
  color: var(--mp-text-3);
}

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--mp-radius-card);
  margin-bottom: 18px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-error {
  background: var(--mp-error-tint);
  border: 1px solid var(--mp-error-line);
  color: var(--mp-error);
}

.alert-success {
  background: var(--mp-success-tint);
  border: 1px solid var(--mp-success-line);
  color: var(--mp-success);
}

/* ---------- Footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px;
  border-top: 1px solid var(--mp-border-subtle);
  color: var(--mp-text-3);
  font-size: 12.5px;
}

.footer a {
  color: var(--mp-text-2);
}

.footer a:hover {
  color: var(--mp-text);
}

/* ---------- Patch Studio Styles ---------- */
.studio-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.studio-layout > * {
  min-width: 0;
}

@media (max-width: 920px) {
  .studio-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.studio-sidebar {
  padding: 16px;
}

.studio-patch-list {
  display: flex;
  flex-direction: column;
  border-radius: var(--mp-radius-card);
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  overflow: hidden;
}

.studio-patch-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--mp-divider);
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.studio-patch-item:last-child {
  border-bottom: 0;
}

.studio-patch-item:hover {
  background: var(--mp-surface-muted);
}

.studio-patch-item.active {
  background: var(--mp-surface-raised);
}

.studio-patch-item.active .mp-tile {
  background: var(--mp-accent-tint);
  color: var(--mp-accent-ink);
}

.studio-patch-item-body {
  flex: 1;
  min-width: 0;
}

.studio-patch-item-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--mp-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.studio-patch-item-meta {
  font-size: 12px;
  color: var(--mp-text-3);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-textarea {
  width: 100%;
  padding: 12px;
  border-radius: var(--mp-radius-control);
  border: 1px solid var(--mp-border);
  background: var(--mp-surface-code);
  color: var(--mp-text);
  font-family: var(--mp-mono);
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
  transition: border-color 120ms ease;
}

.code-textarea:focus {
  outline: none;
  border-color: var(--mp-action-primary-edge);
}

.studio-import-box {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--mp-radius-card);
  border: 1px solid var(--mp-border);
  background: var(--mp-surface-sunken);
}

.studio-toggles-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 12px 16px;
  border-radius: var(--mp-radius-card);
  border: 1px solid var(--mp-border-subtle);
  background: var(--mp-surface-sunken);
}

.studio-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--mp-text);
  cursor: pointer;
}

.studio-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--mp-border);
  position: relative;
  cursor: pointer;
  transition: background 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
  flex-shrink: 0;
}

.studio-checkbox input[type="checkbox"]::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--mp-text-2);
  transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1), background 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.studio-checkbox input[type="checkbox"]:checked {
  background: var(--mp-accent);
}

.studio-checkbox input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: var(--mp-on-accent);
}

/* ---------- Bookmarks & Notes Hub ---------- */
.bookmark-add-box {
  margin: 14px 0 18px;
  padding: 16px;
  border-radius: var(--mp-radius-card);
  border: 1px solid var(--mp-border);
  background: var(--mp-surface-sunken);
}

.bookmark-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
}

.bookmarks-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.bookmarks-search-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--mp-radius-control);
  border: 1px solid var(--mp-border);
  background: var(--mp-surface-sunken);
  color: var(--mp-text);
  font-family: var(--mp-font);
  font-size: 14px;
}

.bookmarks-search-wrap input::placeholder {
  color: var(--mp-text-placeholder);
}

.bookmarks-search-wrap input:focus {
  outline: none;
  border-color: var(--mp-action-primary-edge);
}

.bm-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.bm-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--mp-radius-pill);
  border: 1px solid var(--mp-border-subtle);
  background: var(--mp-surface-sunken);
  color: var(--mp-text-2);
  font-family: var(--mp-font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.bm-pill:hover {
  background: var(--mp-surface);
  color: var(--mp-text);
}

.bm-pill.active {
  background: var(--mp-surface-raised);
  border-color: var(--mp-border);
  color: var(--mp-text);
}

.bm-tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--mp-radius-xs);
  background: var(--mp-surface-raised);
  border: 1px solid var(--mp-border);
  color: var(--mp-text-2);
  font-family: var(--mp-mono);
  font-size: 11px;
  font-weight: 500;
}

.bm-tag-remove {
  background: none;
  border: none;
  color: var(--mp-text-3);
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
}

.bm-tag-remove:hover {
  color: var(--mp-error);
}

.bm-tag-add-form {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.bm-tag-input {
  width: 92px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--mp-radius-xs);
  border: 1px dashed var(--mp-border);
  background: var(--mp-surface-code);
  color: var(--mp-text);
  font-family: var(--mp-mono);
  font-size: 11px;
}

.bm-tag-input:focus {
  outline: none;
  border-style: solid;
  border-color: var(--mp-action-primary-edge);
  width: 116px;
}

.bm-link-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--mp-text);
  display: inline-block;
  margin-bottom: 2px;
  word-break: break-word;
}

.bm-link-title:hover {
  color: var(--mp-accent-ink);
}

.bm-link-url {
  font-family: var(--mp-mono);
  font-size: 12px;
  color: var(--mp-text-3);
  word-break: break-all;
}

.bm-note-body {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: var(--mp-radius-sm);
  background: var(--mp-surface-code);
  border: 1px solid var(--mp-border-subtle);
  font-size: 13px;
  color: var(--mp-text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Mobile Responsive Topbar & Bookmarks ---------- */
@media (max-width: 760px) {
  .topbar-inner {
    height: auto;
    padding: 10px 0;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .nav-links {
    width: 100%;
    overflow-x: auto;
    justify-content: space-between;
    gap: 8px;
  }

  .nav-pill-track {
    overflow-x: auto;
    max-width: 100%;
  }

  .main-content {
    padding-top: 20px;
  }

  .card {
    padding: 16px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero h1 {
    font-size: 26px;
  }

  .badge {
    max-width: 100%;
    height: auto;
    min-height: 22px;
    padding: 3px 8px;
    white-space: normal;
  }

  .bm-table thead {
    display: none;
  }

  .bm-table,
  .bm-table tbody,
  .bm-table tr,
  .bm-table td {
    display: block;
    width: 100%;
  }

  .table-wrap {
    border: 0;
    background: transparent;
  }

  .bm-table tr {
    padding: 14px;
    border: 1px solid var(--mp-border-subtle);
    border-radius: var(--mp-radius-card);
    background: var(--mp-surface-sunken);
    margin-bottom: 10px;
  }

  .bm-table td {
    padding: 5px 0;
    border-bottom: none;
  }
}

/* ---------- Developer & Monkey Portal Showcase Sections ---------- */
.feature-highlight-card {
  border-color: var(--mp-border);
  background: linear-gradient(180deg, var(--mp-action-subtle-hover) 0%, var(--mp-surface-card) 100%);
}

.portal-showcase-card {
  border-color: var(--mp-border);
}

.workflow-step-card {
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  border-radius: var(--mp-radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.workflow-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--mp-accent);
  color: var(--mp-on-accent);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.portal-code-block {
  background: var(--mp-surface-code);
  border: 1px solid var(--mp-border-subtle);
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--mp-text);
  overflow-x: auto;
  margin: 0;
}

.portal-code-block code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.prompt-bubbles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.prompt-bubble {
  padding: 10px 12px;
  border-radius: var(--mp-radius-sm);
  background: var(--mp-surface-input);
  border: 1px solid var(--mp-accent-line);
  border-left: 3px solid var(--mp-accent);
  font-size: 12.5px;
  color: var(--mp-text);
  line-height: 1.45;
}

/* Warm half-step yellow container for example concepts & sample code */
.example-concept-box {
  background: linear-gradient(180deg, var(--mp-action-subtle) 0%, var(--mp-action-subtle-hover) 100%);
  border: 1px solid var(--mp-action-subtle-edge);
  border-radius: var(--mp-radius-group);
  padding: 16px;
}

.example-concept-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.example-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--mp-radius-pill);
  background: var(--mp-accent);
  color: var(--mp-on-accent);
  white-space: nowrap;
}

.example-caption {
  font-size: 12px;
  color: var(--mp-action-ink-strong);
  font-weight: 500;
}

.studio-overview-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
  align-items: start;
}

.studio-overview-split > * {
  min-width: 0;
}

@media (max-width: 920px) {
  .studio-overview-split {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ui-primitives-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}

.primitive-item {
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  border-radius: var(--mp-radius-card);
  padding: 14px;
}

.primitive-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 13.5px;
  color: var(--mp-text);
}

.primitive-item p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
}

.mock-panel-preview {
  background: var(--mp-bg);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-group);
  overflow: hidden;
  box-shadow: var(--mp-shadow-pop);
}

.mock-panel-chrome-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--mp-surface-raised);
  border-bottom: 1px solid var(--mp-border);
}

.mock-panel-body {
  padding: 14px;
}

.mock-stat-box {
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
}

.code-walkthrough-box {
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  border-radius: var(--mp-radius-card);
  padding: 16px;
}

.sdk-ref-card {
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  border-radius: var(--mp-radius-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sdk-ref-card code {
  align-self: flex-start;
  color: var(--mp-accent-ink);
  border-color: var(--mp-accent-line);
  background: var(--mp-accent-tint);
}

.sdk-ref-card strong {
  font-size: 13.5px;
  color: var(--mp-text);
}

.sdk-ref-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
}

/* ---------- Multi-Board Patch Sandbox & Cross-Site Canvas ---------- */
.mp-sandbox-toolbar-card {
  padding: 18px 20px;
}

.mp-sandbox-board-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--mp-divider);
}

.mp-sandbox-board-tabs-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.mp-sandbox-board-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--mp-text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.mp-sandbox-board-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mp-sandbox-board-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--mp-radius-pill);
  border: 1px solid var(--mp-border);
  background: var(--mp-surface-sunken);
  color: var(--mp-text-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
}

.mp-sandbox-board-pill:hover {
  border-color: var(--mp-accent-line);
  color: var(--mp-text);
  background: var(--mp-surface-raised);
}

.mp-sandbox-board-pill.active {
  background: var(--mp-accent);
  color: var(--mp-on-accent);
  border-color: var(--mp-action-primary-edge);
  font-weight: 600;
}

.mp-sandbox-board-pill-slug {
  font-family: var(--mp-mono);
  font-size: 10.5px;
  opacity: 0.78;
}

.mp-sandbox-view-toggles {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.mp-sandbox-new-board-form {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-card);
}

.mp-sandbox-url-bar {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--mp-surface-sunken);
  border: 1px solid var(--mp-border-subtle);
  border-radius: var(--mp-radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.mp-sandbox-root {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.mp-sandbox-split {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(280px, 1fr);
  gap: 14px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .mp-sandbox-split {
    grid-template-columns: minmax(0, 1fr);
  }
}

.mp-sandbox-widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 14px;
}

.mp-sandbox-slot {
  position: relative;
  min-height: 120px;
  transition: border-color 140ms ease, background 140ms ease;
}

.mp-sandbox-slot--header {
  min-height: 76px;
}

.mp-sandbox-slot--main,
.mp-sandbox-slot--sidebar {
  min-height: 200px;
}

.mp-sandbox-slot--widget {
  min-height: 150px;
}

.mp-sandbox-slot--console {
  min-height: 110px;
}

/* Empty Slot Placeholder State */
.mp-sandbox-slot:empty {
  background: var(--mp-surface-sunken);
  border: 1px dashed var(--mp-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  gap: 6px;
}

.mp-sandbox-slot:empty::before {
  content: attr(data-mp-slot-id);
  font-family: var(--mp-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--mp-accent-ink);
  background: var(--mp-accent-tint);
  border: 1px solid var(--mp-accent-line);
  padding: 2px 9px;
  border-radius: var(--mp-radius-pill);
}

.mp-sandbox-slot:empty::after {
  content: attr(data-mp-slot-desc);
  font-size: 12px;
  color: var(--mp-text-3);
  max-width: 460px;
}

/* Populated Slot Corner ID Badge when "Show Slot IDs" is checked */
.mp-sandbox-root.mp-show-slot-badges .mp-sandbox-slot:not(:empty)::after {
  content: attr(data-mp-slot-id);
  position: absolute;
  top: 8px;
  right: 10px;
  font-family: var(--mp-mono);
  font-size: 10.5px;
  color: var(--mp-text-3);
  background: color-mix(in srgb, var(--mp-surface-base) 80%, transparent);
  border: 1px solid var(--mp-border-subtle);
  padding: 1px 6px;
  border-radius: 5px;
  pointer-events: none;
  z-index: 2;
}

/* Hide Empty Slots toggle when "Show Slot IDs" is unchecked */
.mp-sandbox-root:not(.mp-show-slot-badges) .mp-sandbox-slot:empty::before {
  color: var(--mp-text-2);
  background: var(--mp-surface-raised);
  border-color: var(--mp-border);
}

.mp-sandbox-root.mp-hide-empty-slots .mp-sandbox-slot:empty {
  display: none !important;
}

/* ---------- Cloud Patch Studio Monaco IDE & Zen Mode ---------- */
.studio-layout.studio-zen-active {
  grid-template-columns: minmax(0, 1fr) !important;
}

.studio-layout.studio-zen-active .studio-sidebar {
  display: none !important;
}

.studio-monaco-host {
  width: 100%;
  background: var(--mp-surface-input);
  transition: height 160ms ease, border-color 120ms ease;
}

.studio-monaco-host:focus-within {
  border-color: var(--mp-action-primary-edge) !important;
}





/* =====================================================================
 * Design refresh additions (DESIGN.md §9 Stash)
 * ===================================================================== */

/* Warm atmosphere at the top of every page — large surface only */
body {
  background-image: var(--mp-warm-gradient);
  background-repeat: no-repeat;
  background-size: 100% 560px;
}

/* Theme toggle (System → Light → Dark), driven by /theme.js */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--mp-border-subtle);
  background: var(--mp-surface-card);
  color: var(--mp-text-2);
}
.theme-toggle:hover { color: var(--mp-text); border-color: var(--mp-border); }
.theme-toggle .ti { display: none; }
.theme-toggle[data-theme-state="system"] .ti-system,
.theme-toggle:not([data-theme-state]) .ti-system,
.theme-toggle[data-theme-state="light"] .ti-light,
.theme-toggle[data-theme-state="dark"] .ti-dark { display: block; }

/* Crimson callout in the portal: the AI-creation / announcement moment */
.card.mp-callout { padding: 22px 24px; gap: 12px; background: var(--mp-callout-gradient); border-color: var(--mp-callout-border); color: var(--mp-callout-text); }
.card.mp-callout h2, .card.mp-callout h3 { color: var(--mp-callout-text); }
.card.mp-callout .muted, .card.mp-callout p { color: var(--mp-callout-text-2); }
.card.mp-callout code { background: color-mix(in srgb, var(--color-crisp-amber-300) 14%, transparent); color: var(--color-crisp-amber-200); }
