/* ── Worksheet Creator Styles ── */
/* Extracted from worksheet-creator.html inline <style> for PWA caching */

/* ── Layout ── */
.ws-wrap {
  display: flex;
  min-height: calc(100vh - 60px);
}
.sidebar {
  max-width: 320px;
  width: 100%;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
  flex-shrink: 0;
}
.sidebar h3 {
  font-size: 14px;
  margin-bottom: 8px;
}
.sidebar-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.sidebar-section .tog-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.sidebar-section .tog-row label {
  flex: 1;
}
.sidebar-section select,
.sidebar-section input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 80px;
}
.canvas-area {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  position: relative;
}
#canvas {
  background: transparent;
  min-height: auto;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  font-family: 'Patrick Hand', sans-serif;
  font-size: 16pt;
  line-height: 1.8;
  color: #333;
  border-radius: 0;
  box-shadow: none;
}
.ws-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  position: sticky;
  top: 0;
  z-index: 50;
}
.ws-toolbar .ws-btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
}
.ws-btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
}
.ws-header {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  background: var(--bg);
  gap: 12px;
}
.ws-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ws-header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-heading);
}
.ws-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.ws-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.ws-toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Multi-page canvas ── */
.canvas-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 16px;
}
.canvas-page {
  background: #fcfcf8;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.12),
    inset 0 0 30px rgba(0, 0, 0, 0.03);
  border-radius: 2px;
  color: #333;
  position: relative;
  transform-origin: top center;
}
.activity-list {
  margin-top: 8px;
}
.activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.activity-item:hover {
  border-color: var(--primary);
}
.activity-item .ai-drag {
  cursor: grab;
  color: var(--text-dim);
  user-select: none;
}
.activity-item .ai-drag:active {
  cursor: grabbing;
}
/* Drag states */
.activity-item.dragging {
  opacity: 0.35;
}
.activity-item.drag-above {
  margin-top: 32px;
  transition: margin 0.15s ease;
}
.activity-item.drag-below {
  margin-bottom: 32px;
  transition: margin 0.15s ease;
}
.activity-item .ai-num {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 20px;
}
.activity-item .ai-name {
  flex: 1;
  font-weight: 500;
}
.activity-item .ai-btns {
  display: flex;
  gap: 4px;
}
.activity-item .ai-btns button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}
.activity-item .ai-btns button:hover {
  background: var(--bg-card);
  color: var(--text);
}
.b {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: move;
}
.b:hover {
  border-color: var(--primary);
}
.bic {
  color: var(--text-dim);
  font-size: 11px;
}
.bin {
  flex: 1;
  font-weight: 500;
}
.bia {
  display: flex;
  gap: 4px;
}
.eb {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}
.eb:hover {
  background: var(--bg);
  color: var(--text);
}
.emp {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
}
.pdf-title {
  font-family: Quicksand, sans-serif;
  font-size: 24pt;
  color: #1a1a2e;
  margin-bottom: 12px;
  text-align: center;
}
.pdf-st {
  font-size: 12pt;
  color: #555;
  margin-bottom: 4px;
}
.pdf-sec {
  margin-bottom: 8px;
  font-size: var(--sec-font-size);
  font-family: var(--sec-font-family);
  font-weight: var(--sec-font-weight);
  color: var(--sec-color);
}
.pdf-label {
  font-weight: inherit;
  color: inherit;
}
/* Shared canvas body text — use in renderCanvas for all block body copy */
.pdf-body {
  font-size: var(--text-body);
  line-height: 1.7;
}
.pdf-body-sm {
  font-size: var(--text-footnote);
  line-height: 1.6;
}
/* Block type tag — label next to section number (e.g. "TRUE / FALSE").
 * Inherits font/color from .pdf-sec; controlled via --block-tag-transform */
.pdf-block-tag {
  font-family: var(--sec-font-family);
  color: var(--sec-color);
  font-size: var(--sec-font-size);
  text-transform: var(--block-tag-transform, capitalize);
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-right: 6px;
}

/* ── Edit overlay ── */
.edit-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}
.edit-overlay.show {
  display: flex;
}
.edit-box {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.edit-box h3 {
  font-size: 18px;
  margin-bottom: 16px;
}
.ed-row {
  margin-bottom: 14px;
}
.ed-row label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.ed-preview {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  color: #333;
  min-height: 100px;
}
.ed-live-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.edit-2col {
  display: flex;
  gap: 20px;
}
.edit-2col .edit-settings {
  flex: 1;
  min-width: 0;
}
.edit-2col .edit-preview {
  flex: 0 0 200px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.edit-preview-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.edit-preview-content {
  background: white;
  border-radius: 6px;
  padding: 10px;
  color: #333;
  min-height: 60px;
  font-size: 13px;
}

/* ── MC Block: Question cards ── */
.mc-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.mc-q-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}
.mc-q input[type='text'] {
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  color: var(--text);
  outline: none;
}
.mc-opt .mcot {
  flex: 1;
  min-width: 80px;
  font-size: 12px;
  min-height: 32px;
  height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.mc-opt .mcoi {
  width: 60px;
  font-size: 10px;
}

/* ── MC Block: Mode dropdown ── */
.mc-mode-sel {
  background: var(--bg-input)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6' fill='%2394A3B8'/%3E%3C/svg%3E")
    no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 22px 4px 6px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  min-height: 32px;
  width: auto;
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
}
.mc-mode-sel:focus {
  border-color: var(--primary);
}

/* ── MC Block: Image picker button ── */
.mc-img-btn {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--primary);
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary-light);
  border-radius: 6px;
  cursor: pointer;
  min-height: 32px;
  line-height: 1;
  transition: all 0.15s;
}
.mc-img-btn:hover {
  border-color: var(--primary);
  filter: brightness(1.2);
  background: rgba(79, 70, 229, 0.2);
}

/* ── MC Block: Disabled / greyed controls ── */
.disabled-control,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  background: var(--bg-disabled, #0a0f1a) !important;
  color: var(--text-disabled, #475569) !important;
  border-color: var(--border) !important;
}
:root {
  --bg-disabled: #0a0f1a;
  --text-disabled: #475569;
  --z-picker: 400;
}

/* ── MC Block: Image picker overlay ── */
.mc-img-picker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mc-img-picker-box {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

/* ── MC Block: Edit modal form controls (consistent 32px height baseline) ── */
.mc-edit-select,
.mc-edit-input,
.mcqimg,
.mcexp,
.mcOptCount,
.mcq-img-btn {
  min-height: 32px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.mc-edit-select:focus,
.mc-edit-input:focus,
.mcqimg:focus,
.mcexp:focus,
.mcOptCount:focus {
  border-color: var(--primary);
}
.mc-edit-select {
  padding: 4px 8px;
  cursor: pointer;
}
.mc-edit-input {
  padding: 4px 8px;
}
.mcqimg,
.mcexp {
  padding: 4px 8px;
}
.mcOptCount {
  padding: 4px 8px;
  cursor: pointer;
  width: auto;
  min-width: 48px;
}
.mcq-img-btn {
  padding: 4px 10px;
  cursor: pointer;
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  height: 32px;
}
.mcq-img-btn:hover {
  border-color: var(--primary);
}

/* ── MC Block: Per-option image picker buttons (32x32 square) ── */
.mc-opt .mc-opt-picker {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  min-height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.mc-opt .mc-opt-picker:hover {
  border-color: var(--primary);
}
.mc-opt {
  padding: 0 8px !important;
  align-items: center !important;
}

/* ── MC Block: Option image URL row inputs ── */
.mc-opt-img-row input[type='text'] {
  flex: 1;
  min-width: 60px;
  font-size: 12px;
  padding: 4px 8px;
  min-height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.mc-opt-img-row input[type='text']:focus {
  border-color: var(--primary);
}

/* ── Shuffle sub-menu ── */
.shuffle-sub {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 55;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-top: 4px;
  min-width: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.shuffle-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}
.shuffle-sub-row:last-child {
  margin-bottom: 0;
}
#emShuffleBtn {
  min-height: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  width: 100%;
}

/* ── Canvas: Responsive MC grid ── */
@media (max-width: 600px) {
  .canvas-page .mc-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}
@media (max-width: 400px) {
  .canvas-page .mc-grid {
    grid-template-columns: 1fr !important;
  }
}
@media (max-width: 480px) {
  .mc-opt .mcoi {
    width: 100%;
    margin-top: 2px;
    order: 5;
  }
  .mc-mode-tog {
    order: 6;
    width: 100%;
    justify-content: flex-end;
    margin-top: 2px;
  }
}

/* ── Add Activity Modal ── */
#addPanel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#addPanel > div {
  background: var(--bg-card);
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.modal-header h2,
.modal-header h3 {
  margin: 0;
  font-size: 18px;
}
.modal-header .modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.modal-header .modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

/* ── Block Cards (compact, fully clickable) ── */
.at-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}
.at-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
}
.at-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.at-card-name {
  padding: 10px 10px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-heading);
  text-align: center;
}
.at-card-preview {
  padding: 8px 10px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}
.at-card-preview svg {
  display: block;
  max-width: 100%;
  height: auto;
}
.at-card-desc {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  text-align: left;
}
.at-card-btn {
  width: 100%;
  margin-top: auto;
  padding: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-heading);
  transition: all 0.15s;
  min-height: 34px;
}
.at-card-btn:hover {
  background: var(--primary-dark);
  filter: brightness(1.1);
}

/* ── Tabs ── */
.ap-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.ap-tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 44px;
}
.ap-tab:hover {
  color: var(--text);
  background: rgba(79, 70, 229, 0.05);
}
.ap-tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

/* ── Category sections ── */
.at-cat-section {
  margin-bottom: 14px;
}
.at-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-height: 36px;
}
.at-cat-header:hover {
  border-color: var(--primary);
}
.at-cat-header .at-cat-arrow {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-dim);
}
.at-cat-header.open .at-cat-arrow {
  transform: rotate(180deg);
}
.at-cat-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin: 4px 0 6px 4px;
}
.at-cat-body {
  overflow: hidden;
}
.at-recent-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.at-recent-btn {
  padding: 6px 12px;
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(79, 70, 229, 0.3);
  border-radius: 20px;
  color: #818cf8;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.at-recent-btn:hover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.2);
}

/* ── Templates ── */
.at-tmpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.at-tmpl-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
}
.at-tmpl-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.at-tmpl-icon {
  font-size: 22px;
  margin-bottom: 4px;
}
.at-tmpl-name {
  font-size: 13px;
  font-weight: 700;
}
.at-tmpl-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
}
.at-tmpl-btn {
  width: 100%;
  padding: 8px;
  background: var(--bg-card);
  color: var(--primary);
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-heading);
  transition: all 0.15s;
  margin-top: auto;
  min-height: 34px;
}
.at-tmpl-btn:hover {
  background: rgba(79, 70, 229, 0.1);
}

/* ── Compact number spinner for style panel ── */
.mc-spinner {
  width: 44px;
  min-height: 28px;
  padding: 4px 4px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  text-align: center;
}
.mc-spinner:focus {
  border-color: var(--primary);
}

/* ── Print styles ── */
@media print {
  .sop-nav,
  .sop-footer,
  #nav-placeholder,
  .ws-toolbar,
  .toolbar-wrap,
  .ws-header,
  .sidebar,
  .style-panel,
  #stylePanel,
  #addPanel,
  .edit-overlay,
  #sr-announce,
  .toast,
  .onboard-tip,
  .activity-list-header {
    display: none !important;
  }
  #canvas,
  .canvas-page {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    min-height: auto !important;
    background: white !important;
    font-size: 16pt !important;
    line-height: 1.5 !important;
    color: #000 !important;
  }
  .canvas-pages {
    gap: 0 !important;
    padding: 0 !important;
  }
  @page {
    margin: 15mm;
  }
  .pdf-sec,
  .pdf-label {
    break-inside: avoid;
  }
  .pdf-ak {
    display: block !important;
  }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* ── Mobile styles ── */
@media (max-width: 768px) {
  .ws-wrap {
    flex-direction: column;
    min-height: 0;
  }
  .sidebar {
    display: none;
  }
  .canvas-area {
    position: relative;
    top: 0;
    width: 100%;
    flex: 1;
    min-height: 0;
  }
  #canvas {
    min-height: 60vh;
    padding: 16px;
    max-width: 100%;
    transform: none;
  }
  .canvas-page {
    width: 100% !important;
    padding: 20px !important;
  }
  .ws-toolbar {
    gap: 4px;
    overflow: visible;
    flex-wrap: nowrap;
    justify-content: center;
    padding: 8px 8px;
    min-height: 48px;
  }
  .ws-toolbar button {
    font-size: 12px;
    padding: 4px 10px;
    min-height: 36px;
  }
  .ws-toolbar .ws-btn-sm {
    min-width: 36px;
  }
  .ws-toolbar .ws-tb-hide-mob {
    display: none;
  }
  .ws-toolbar-divider {
    margin: 0 2px;
  }
  .ws-header {
    padding: 6px 12px;
  }
  .ws-header-title {
    font-size: 13px;
  }
  .ws-header-right input {
    max-width: 120px;
    font-size: 11px;
  }
  .mob-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    min-height: 56px;
    background: rgba(15, 23, 42, 0.92);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  @supports (backdrop-filter: blur(12px)) {
    .mob-tab-bar {
      background: rgba(15, 23, 42, 0.7);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
    }
  }
  .mob-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 10px;
    padding: 6px 4px;
    cursor: pointer;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
  }
  .mob-tab[aria-selected='true'] {
    color: var(--primary);
  }
  .mob-tab .mob-tab-icon {
    font-size: 20px;
    line-height: 1;
  }
  .mob-sheet {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    z-index: 99;
    max-height: 70vh;
    min-height: 200px;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  }
  .mob-sheet.open {
    transform: translateY(0);
  }
  .mob-sheet .mob-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 6px;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
  }
  .mob-sheet .mob-sheet-handle::after {
    content: '';
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
  }
  .mob-sheet .mob-sheet-content {
    padding: 0 16px 16px;
  }
  .mob-sheet h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text);
    text-align: center;
  }
  @media (prefers-reduced-motion: reduce) {
    .mob-sheet {
      transition: none;
    }
  }
  @media (orientation: landscape) {
    .mob-tab-bar {
      min-height: 44px;
    }
    .mob-tab {
      font-size: 9px;
      min-height: 40px;
    }
    .mob-tab .mob-tab-icon {
      font-size: 16px;
    }
  }
  .modal-overlay .modal-body {
    width: 95vw;
    max-height: 80vh;
    padding: 16px;
  }
  .edit-modal-2col {
    flex-direction: column;
  }
  .edit-modal-2col > div:last-child {
    flex: none;
    width: 100%;
    min-height: 120px;
  }
  .edit-box {
    max-width: 100vw;
    width: 100%;
    border-radius: 0;
    max-height: 100vh;
    padding: 20px;
  }
  .edit-2col {
    flex-direction: column;
  }
  .edit-2col .edit-preview {
    flex: 0 0 auto;
    min-height: 120px;
  }
  .ed-row input,
  .ed-row textarea,
  .ed-row select {
    font-size: 16px;
  }
  .edit-box .modal-close {
    padding: 8px 12px;
    min-height: 44px;
  }
  #addPanel {
    padding: 0;
  }
  #addPanel > div {
    max-width: 100vw;
    width: 100%;
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
  }
  .canvas-page .mc-col {
    flex: 1 1 100%;
  }
  .canvas-page .mc-row {
    flex-direction: column;
  }
  .at-cat-header {
    padding: 12px 14px;
    min-height: 44px;
  }
  .at-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
  }
  .at-btn {
    padding: 14px 12px;
  }
  .modal-header .modal-close {
    padding: 8px 12px;
    min-height: 44px;
  }
  #addPanelSearch {
    max-width: 140px;
    font-size: 12px;
  }
  body {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0));
  }
}

/* ── Accordion sidebar sections ── */
.accordion-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
}
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-heading);
  background: var(--bg);
  transition: background 0.15s;
}
.accordion-header:hover {
  background: rgba(79, 70, 229, 0.08);
}
.accordion-header .acc-arrow {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-dim);
}
.accordion-header.open .acc-arrow {
  transform: rotate(180deg);
}
.accordion-body {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.accordion-body .tog-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.accordion-body .tog-row label {
  flex: 1;
}
.accordion-body select,
.accordion-body input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 80px;
}

/* ── Scroll lock — iOS-safe ── */
body.scroll-lock {
  overflow: hidden;
  position: fixed;
  width: 100%;
  padding-right: var(--scrollbar-width, 0px);
}
#addPanel {
  overscroll-behavior: contain;
}

/* ── Style controls ── */
.lh-btn {
  padding: 2px 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  font-family: monospace;
  line-height: 1.4;
}
.lh-btn.active {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.15);
  color: var(--primary-light);
  font-weight: 600;
}
.bg-btn.active {
  border-color: var(--primary) !important;
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ── Sticker picker ── */
.ssrc-btn {
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  min-height: 28px;
  transition: all 0.15s;
}
.ssrc-btn.ssrc-active {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.12);
  color: var(--primary-light);
  font-weight: 600;
}
.stab-btn {
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  min-height: 36px;
}
.stab-btn.stab-active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}
/* ── MC Quill editors ── */
.mcqq-editor-wrap {
  margin-bottom: 8px;
}
.mcqq-editor {
  min-height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 0;
}
.mcqq-editor .ql-toolbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
}
.mcqq-editor .ql-container {
  min-height: 32px;
  font-size: 14px;
  border: none;
}
/* ── Quill toolbar: clean dark-theme B/I/U ── */
.mcqq-editor .ql-toolbar,
.edit-box .ql-toolbar {
  padding: 2px 4px !important;
  min-height: auto !important;
  border: none !important;
  background: transparent !important;
  margin-bottom: 0 !important;
}
.mcqq-editor .ql-toolbar .ql-formats,
.edit-box .ql-toolbar .ql-formats {
  margin-right: 4px !important;
}
.mcqq-editor .ql-toolbar .ql-formats:last-child,
.edit-box .ql-toolbar .ql-formats:last-child {
  margin-right: 0 !important;
}
.mcqq-editor .ql-toolbar button,
.edit-box .ql-toolbar button {
  width: 24px !important;
  height: 24px !important;
  padding: 3px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 4px !important;
  border: none !important;
  transition: all 0.12s ease !important;
  background: transparent !important;
}
.mcqq-editor .ql-toolbar button svg,
.edit-box .ql-toolbar button svg {
  width: 14px !important;
  height: 14px !important;
}
.mcqq-editor .ql-toolbar button svg *,
.edit-box .ql-toolbar button svg * {
  stroke: var(--text-dim) !important;
  fill: var(--text-dim) !important;
}
.mcqq-editor .ql-toolbar button:hover,
.edit-box .ql-toolbar button:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}
.mcqq-editor .ql-toolbar button.ql-active,
.edit-box .ql-toolbar button.ql-active {
  background: rgba(79, 70, 229, 0.2) !important;
}
.mcqq-editor .ql-toolbar button.ql-active svg *,
.edit-box .ql-toolbar button.ql-active svg * {
  stroke: var(--primary-light) !important;
  fill: var(--primary-light) !important;
}
/* ── Hide Quill clipboard (offscreen) ── */
.ql-clipboard {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  pointer-events: none !important;
}
/* ── Hide extraneous Quill link tool input ── */
.ql-toolbar input[type='text'] {
  display: none !important;
}
/* ── Hide Quill link/video tooltip ── */
.ql-tooltip.ql-hidden,
.ql-tooltip {
  display: none !important;
}
.mcqq-editor .ql-container,
.edit-box .ql-container {
  font-size: 13px !important;
  min-height: 32px !important;
  border: none !important;
}
.mcexp-editor-wrap {
  margin-bottom: 4px;
}
.mcexp-editor {
  min-height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 0;
}
.mcexp-editor .ql-toolbar {
  padding: 2px 4px !important;
  min-height: auto !important;
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
}
.mcexp-editor .ql-container {
  font-size: 12px !important;
  min-height: 32px !important;
  border: none;
}
/* ── Quill editor text color fix (dark bg + black text) ── */
#emqEditor .ql-editor,
.mcexp-editor .ql-editor,
.mcqq-editor .ql-editor,
.edit-box .ql-editor {
  color: var(--text) !important;
  padding: 4px 8px !important;
}

/* ═══════════════════════════════════════════════
   SHARED EDIT MODAL FORM CONTROLS
   Apply to ALL block edit modals for consistency
   ═══════════════════════════════════════════════ */

/* Base control */
.edit-input,
.edit-textarea,
.edit-select {
  min-height: 32px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  padding: 4px 8px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.edit-input:focus,
.edit-textarea:focus,
.edit-select:focus {
  border-color: var(--primary);
}

/* Select with custom arrow */
.edit-select {
  cursor: pointer;
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6' fill='%2394A3B8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}

/* Textarea */
.edit-textarea {
  width: 100%;
  resize: vertical;
  min-height: 50px;
}

/* Label in settings rows */
.edit-label {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Settings row — evenly spaced controls */
.edit-settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin-bottom: 8px;
}
.edit-settings-row > * {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}

/* Card container */
.edit-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-card);
}

/* Card header */
.edit-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.edit-card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

/* Small number input for points */
.edit-pts {
  width: 48px;
  min-height: 32px;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  text-align: center;
  outline: none;
  box-sizing: border-box;
}
.edit-pts:focus {
  border-color: var(--primary);
}

/* Row within a card (label + control on same line) */
.edit-field-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

/* Section heading within edit modal */
.edit-section-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  margin: 8px 0 4px;
  display: block;
}

/* Checkbox label row (inline checkbox + text) */
.edit-check-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-dim);
}

/* Inline prefix number (e.g. "1.") */
.edit-num {
  min-width: 16px;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}
