@font-face {
  font-family: "IRANSansX";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/IRANSansX-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "IRANSansX";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/IRANSansX-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "IRANSansX";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/IRANSansX-DemiBold.woff2") format("woff2");
}
@font-face {
  font-family: "IRANSansX";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/IRANSansX-Bold.woff2") format("woff2");
}

:root {
  --blue: #3f7cac;
  --blue-dark: #2c5c85;
  --blue-tint: #eef4fa;
  --orange: #e08a2c;
  --orange-tint: #fdf3e7;
  --red: #cf3a4a;
  --red-tint: #fbedee;
  --ink: #1c2230;
  --ink-soft: #4b5468;
  --muted: #8891a3;
  --line: #e3e7ee;
  --bg: #f6f7fb;
  --card: #ffffff;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.04), 0 8px 24px -12px rgba(20, 30, 60, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #6fa8d8; --blue-dark: #4d84b8; --blue-tint: #1c2c3a;
    --orange: #e6a457; --orange-tint: #3a2f1c;
    --red: #e5717e; --red-tint: #3a1f22;
    --ink: #e8eaf0; --ink-soft: #b7bccb; --muted: #7f8698;
    --line: #2c3140; --bg: #14161f; --card: #1b1e2a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --blue: #6fa8d8; --blue-dark: #4d84b8; --blue-tint: #1c2c3a;
  --orange: #e6a457; --orange-tint: #3a2f1c;
  --red: #e5717e; --red-tint: #3a1f22;
  --ink: #e8eaf0; --ink-soft: #b7bccb; --muted: #7f8698;
  --line: #2c3140; --bg: #14161f; --card: #1b1e2a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IRANSansX", -apple-system, "Segoe UI", "Tahoma", sans-serif;
  font-size: 15px;
  line-height: 1.75;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 700; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: -0.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; font-size: 20px; margin-bottom: 14px; }
.brand-name { font-weight: 700; font-size: 16px; }

.topbar-nav { display: flex; align-items: center; gap: 12px; }
.topbar-user { color: var(--ink-soft); font-size: 13.5px; text-decoration: none; }
.topbar-user:hover { color: var(--blue); text-decoration: underline; }
.theme-toggle {
  background: none; border: 1px solid var(--line); border-radius: 50%;
  width: 32px; height: 32px; cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--bg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); text-decoration: none; }
.btn-secondary { background: var(--blue-tint); color: var(--blue-dark); }
.btn-secondary:hover { background: #e2ecf5; text-decoration: none; }
.btn-outline { background: var(--card); color: var(--ink-soft); border-color: var(--line); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.btn-outline.btn-optional:hover { border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }

.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 14px;
  color: var(--muted); padding: 4px 6px; border-radius: 6px; line-height: 1;
}
.icon-btn:hover { background: var(--red-tint); color: var(--red); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; background: var(--card); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.8; }
input:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(63, 124, 172, 0.15);
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 4px; }
.alert-error { background: var(--red-tint); color: var(--red); border: 1px solid var(--red); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: var(--line);
  border-radius: 22px; transition: .15s;
}
.slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; right: 3px; top: 3px;
  background: var(--card); border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(-18px); }

.mode-toggle {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  cursor: pointer; user-select: none; margin-top: 6px;
}
.mode-toggle input { accent-color: var(--blue); }
textarea.advanced-active {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; direction: ltr; text-align: left;
  background: var(--bg);
}

.auth-wrap { display: flex; justify-content: center; padding: 64px 20px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 19px; margin-bottom: 4px; }
.auth-brand p { margin: 0; font-size: 13px; }
.auth-switch { text-align: center; margin: 18px 0 0; font-size: 13px; color: var(--ink-soft); }

.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 22px; margin-bottom: 4px; }
.page-head p { margin: 0; }

.new-doc-row { display: flex; gap: 12px; margin-bottom: 32px; flex-wrap: wrap; }
.new-doc-btn {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px;
  border: 1.5px dashed var(--line); border-radius: var(--radius-md); background: var(--card);
  cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--ink-soft);
  transition: border-color .15s, color .15s, background .15s;
}
.new-doc-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-tint); }
.new-doc-icon {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blue-tint); color: var(--blue);
  display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700;
}

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.doc-card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 18px; color: var(--ink); transition: box-shadow .15s, border-color .15s, transform .1s;
}
.doc-card:hover { box-shadow: var(--shadow); border-color: #d3dae6; text-decoration: none; transform: translateY(-1px); }
.doc-card-top { margin-bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.doc-card-title { font-size: 15px; margin-bottom: 4px; }
.doc-card-meta { margin: 0; color: var(--muted); font-size: 13px; min-height: 1.2em; }
.doc-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.doc-card-actions { display: flex; align-items: center; gap: 2px; }
.inline-form { margin: 0; }

.badge {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; background: var(--blue-tint); color: var(--blue-dark);
}
.badge-exam { background: var(--red-tint); color: var(--red); }
.badge-quiz { background: var(--orange-tint); color: #a8631a; }
.badge-shared { background: #eef2e8; color: #4a6b3a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-shared { background: #223326; color: #a8d1a8; }
}
:root[data-theme="dark"] .badge-shared { background: #223326; color: #a8d1a8; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

.editor-shell { max-width: 1280px; margin: 0 auto; padding: 0 24px 60px; }
.editor-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; flex-wrap: wrap;
    position: sticky; top: 76px; z-index: 15;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.editor-title-row { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 240px; }
.title-input {
  font-size: 19px; font-weight: 700; border: none; background: transparent; padding: 4px 6px;
  border-radius: 6px; flex: 1; min-width: 160px;
}
.title-input:focus { outline: none; background: var(--card); box-shadow: 0 0 0 2px var(--blue); }
.editor-actions { display: flex; align-items: center; gap: 10px; }
.save-status { font-size: 12px; color: var(--muted); min-width: 70px; text-align: center; }

.editor-body { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
@media (max-width: 980px) { .editor-body { grid-template-columns: 1fr; } }

.editor-form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.card-title { font-size: 14.5px; margin-bottom: 14px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-title-row .card-title { margin-bottom: 0; }

.field-with-mode { display: flex; flex-direction: column; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat-box {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 16px; text-align: center;
}
.stat-num { font-size: 26px; font-weight: 800; color: var(--blue-dark); }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.admin-table th { color: var(--muted); font-weight: 600; font-size: 12px; }

.hero { text-align: center; padding: 48px 0 32px; }
.hero h1 { font-size: 28px; max-width: 720px; margin: 0 auto 14px; line-height: 1.5; }
.hero-sub { max-width: 560px; margin: 0 auto 24px; font-size: 15px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; }
.homepage-shots {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px; margin: 32px 0;
}
.shot-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 10px; text-align: center; box-shadow: var(--shadow);
}
.shot-card img { width: 100%; border-radius: var(--radius-md); display: block; }
.shot-card .hint { text-align: center; }
.homepage-orgs { text-align: center; margin: 40px 0 60px; }
.homepage-orgs h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 16px; }
.org-row { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.org-chip {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px;
}
.org-chip img { height: 28px; width: auto; }

.collab-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.collab-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 12px; color: var(--ink-soft);
}
.collab-chip.collab-owner { background: var(--blue-tint); color: var(--blue-dark); border-color: transparent; }
.collab-chip small { color: var(--muted); font-size: 11px; }
.collab-remove {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 11px; padding: 0; line-height: 1;
}
.collab-remove:hover { color: var(--red); }
.collab-invite-row { display: flex; gap: 8px; align-items: flex-start; }
.collab-search-wrap { position: relative; flex: 1; }
.collab-search-wrap input { width: 100%; }
.collab-search-results {
  position: absolute; top: calc(100% + 4px); right: 0; left: 0; z-index: 10;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow); overflow: hidden; max-height: 220px; overflow-y: auto;
}
.collab-search-item {
  display: block; width: 100%; text-align: right; background: none; border: none;
  padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--ink);
}
.collab-search-item:hover { background: var(--blue-tint); }
.collab-search-empty { padding: 10px 12px; font-size: 13px; color: var(--muted); text-align: center; }
.collab-error { color: var(--red); }

.mcq-options-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.mcq-option-row {
  display: flex; align-items: flex-start; gap: 8px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px;
}
.mcq-option-number {
  width: 22px; height: 22px; border-radius: 6px; background: var(--orange-tint); color: #a8631a;
  display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700;
  flex-shrink: 0; margin-top: 2px;
}
.mcq-option-row .block-editor-mount { flex: 1; min-width: 0; }
.mcq-option-row textarea { font-size: 13.5px; }

.bg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 150px)); gap: 12px; }
.bg-option {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; padding: 8px; border: 1.5px solid var(--line); border-radius: var(--radius-md);
  font-size: 12px; color: var(--ink-soft); transition: border-color .15s, background .15s;
}
.bg-option-cat { font-size: 10.5px; color: var(--muted); margin-bottom: -4px; }
.bg-option:hover { border-color: var(--blue); }
.bg-option input { position: absolute; opacity: 0; }
.bg-option img { width: 100%; aspect-ratio: 210/297; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); }
.bg-option:has(input:checked) { border-color: var(--blue); background: var(--blue-tint); color: var(--blue-dark); font-weight: 600; }
.bg-upload-preview {
  width: 100%; aspect-ratio: 210/297; border-radius: 6px; border: 1.5px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); background: var(--bg); overflow: hidden;
}
.bg-upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-plus { font-size: 20px; }

.question-card {
  border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px;
  margin-bottom: 14px; background: var(--bg);
}
.question-card[data-kind="optional"] { border-color: var(--red); background: var(--red-tint); }
.question-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.question-num {
  width: 26px; height: 26px; border-radius: 8px; background: var(--blue-tint); color: var(--blue-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}
.question-card[data-kind="optional"] .question-num { background: var(--red-tint); color: var(--red); }
.question-kind-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); flex: 1; }
.score-field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.score-field input { width: 58px; padding: 5px 8px; font-size: 13px; }

.subparts-list { margin: 10px 0 6px; display: flex; flex-direction: column; gap: 8px; }
.subpart-row { display: flex; align-items: flex-start; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.subpart-letter {
  width: 22px; height: 22px; border-radius: 6px; background: var(--orange-tint); color: #a8631a;
  display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}
.subpart-row .block-editor-mount { flex: 1; min-width: 0; }
.subpart-row textarea { font-size: 13.5px; }

.add-question-row { display: flex; gap: 10px; margin-top: 4px; }

.answer-section { margin-top: 10px; }
.answer-wrap {
  background: var(--card); border: 1px solid var(--blue); border-radius: var(--radius-sm);
  padding: 10px; margin-top: 4px;
}
.answer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.answer-badge {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 700;
  color: var(--blue-dark); background: var(--blue-tint); border-radius: 6px; padding: 3px 10px;
}

.block-type-badge {
  display: inline-flex; align-items: center; align-self: flex-start; font-size: 11px; font-weight: 700;
  color: var(--blue-dark); background: var(--blue-tint); border-radius: 6px; padding: 2px 8px;
  margin-bottom: 4px;
}
.block-type-badge-note { color: #a8631a; background: var(--orange-tint); }

.blocks-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.block-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.block-row {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.block-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.block-row-controls { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.block-row-controls .icon-btn { font-size: 10px; padding: 3px 5px; }

.block-row-text textarea { font-size: 13.5px; }

.block-image-preview {
  display: flex; align-items: center; justify-content: center;
  min-height: 70px; max-height: 160px; overflow: hidden;
  border: 1px dashed var(--line); border-radius: 6px; background: var(--bg);
}
.block-image-preview.empty { padding: 14px; }
.block-image-preview img { max-width: 100%; max-height: 160px; object-fit: contain; }
.block-image-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.block-inline-field { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); }
.block-inline-field select {
  font-family: inherit; font-size: 12.5px; border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 6px; background: var(--card); width: auto;
}
.block-image-caption { font-size: 13px; }

.block-eq-latex { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; }
.block-eq-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.block-eq-hint { margin: 0; }

.editor-preview { position: sticky; top: 76px; }
.preview-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 110px);
}
.preview-head {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--ink-soft);
}
.preview-body { flex: 1; overflow: auto; background: var(--bg); display: flex; }
.preview-body iframe { width: 100%; height: 100%; border: none; color-scheme: light; }
.preview-placeholder { margin: auto; padding: 30px; text-align: center; font-size: 13px; }
.preview-log {
  margin: 16px; padding: 12px; background: var(--red-tint); border: 1px solid var(--red); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; white-space: pre-wrap; color: var(--red);
  overflow: auto; max-height: 100%;
}

.modal-overlay:not([hidden]) {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 24px; max-width: 380px; width: 90%; text-align: center;
}
.modal-box p { margin: 0 0 18px; font-size: 14.5px; color: var(--ink); }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }

.form-success {
  color: #1d7a4c; background: rgba(29, 122, 76, 0.1); border: 1px solid rgba(29, 122, 76, 0.3);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 14px; margin: 0;
}
.field-inline-check { flex-direction: row; align-items: center; gap: 8px; align-self: end; }
.field-inline-check input { width: auto; }
.admin-row-actions { display: flex; align-items: center; gap: 8px; }

.doc-card-sheet { margin: 10px 0 0; }
.doc-sheet-btn { width: 100%; justify-content: center; }

.mcq-multi-toggle { margin-bottom: 6px; }
.mcq-multi-active .mcq-option-number {
  border-radius: 4px; border-style: dashed;
}
.tf-preview {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 13px; color: var(--ink-soft);
}
.tf-preview span + .tf-box { margin-right: 10px; }
.tf-box {
  width: 15px; height: 15px; border: 1.5px solid var(--orange);
  border-radius: 3px; display: inline-block;
}

/* ---- math input --------------------------------------------------- */
math-field.block-eq-field {
  display: block; width: 100%; min-height: 52px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); font-size: 19px;
  --caret-color: var(--blue);
  --selection-background-color: var(--blue-tint);
  --placeholder-color: var(--muted);
  --smart-fence-color: var(--muted);
}
math-field.block-eq-field:focus,
math-field.block-eq-field:focus-within {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(63, 124, 172, 0.15);
}
math-field.block-eq-field::part(virtual-keyboard-toggle),
math-field.block-eq-field::part(menu-toggle) { display: none; }

.eq-latex-row { margin-top: 6px; }
.eq-latex-row input {
  width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
}
.eq-keyboard-toggle.active, .eq-latex-toggle.active {
  background: var(--blue-tint); border-color: var(--blue); color: var(--blue-dark);
}

.mk-panel {
  /* Formulas are left-to-right everywhere, so the keyboard is too: keys
     read in the same direction as the math they build, independent of the
     surrounding RTL page. */
  direction: ltr;
  margin-top: 8px; padding: 8px; border: 1px solid var(--line);
  border-radius: var(--radius-md); background: var(--bg);
  display: flex; flex-direction: column; gap: 8px;
}
.mk-toolbar { display: flex; align-items: center; gap: 6px; }
.mk-tool {
  min-width: 40px; height: 34px; cursor: pointer; font-size: 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
}
.mk-tool:hover { border-color: var(--blue); color: var(--blue-dark); }
.mk-tool.active { background: var(--ink); border-color: var(--ink); color: var(--card); }
.mk-tool[data-tool="del"] { margin-left: auto; }

.mk-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.mk-tab {
  flex: 0 0 auto; padding: 6px 12px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink-soft); line-height: 1.1;
}
.mk-tab:hover { border-color: var(--blue); }
.mk-tab.active { background: var(--ink); border-color: var(--ink); color: var(--card); }
.mk-tab.active .ML__latex { color: var(--card); }

.mk-body { display: flex; gap: 8px; align-items: flex-start; }
.mk-tab-keys {
  flex: 1 1 auto; display: grid; gap: 5px;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
}
.mk-tab-keys.mk-alpha { grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
.mk-numpad {
  flex: 0 0 auto; display: grid; gap: 5px;
  grid-template-columns: repeat(4, 46px);
}
.mk-key {
  min-height: 40px; padding: 4px 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
}
.mk-key:hover { border-color: var(--blue); background: var(--blue-tint); }
.mk-key:active { transform: translateY(1px); }
.mk-num { background: var(--bg); font-weight: 600; }
.mk-key .ML__latex { font-size: 0.95em; }

@media (max-width: 900px) {
  .mk-body { flex-direction: column; }
  .mk-numpad { width: 100%; grid-template-columns: repeat(4, 1fr); }
}
