/* ===================================================================
   SPARK your Study – CSS v1.3
   =================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #f0f8fc; color: #1e293b; line-height: 1.6;
  min-height: 100vh; overflow-x: hidden;
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px; min-height: 100vh;
  background: linear-gradient(180deg, #004a6e 0%, #00354d 100%);
  color: #fff; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 24px 20px 20px; }
.brand-icon { width: 40px; height: 40px; flex-shrink: 0; }
.brand-text-group { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text {
  font-size: 1.3rem; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(135deg, #fff 0%, #a0ecff 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.brand-subtext { font-size: 0.72rem; font-weight: 500; opacity: 0.7; letter-spacing: .04em; }

.nav-list { list-style: none; padding: 8px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 10px; cursor: pointer; transition: background .2s, transform .15s;
  margin-bottom: 4px; font-size: .938rem; user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.1); }
.nav-item.active { background: rgba(0,188,235,.2); box-shadow: inset 3px 0 0 #00BCEB; font-weight: 600; }
.nav-item:active { transform: scale(.98); }
.nav-icon { width: 22px; height: 22px; flex-shrink: 0; }
.nav-label { white-space: nowrap; }
.sidebar-footer { padding: 16px 20px; opacity: .5; font-size: .75rem; }

.mobile-header {
  display: none; position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: #004a6e; color: #fff; align-items: center; padding: 0 16px; gap: 12px; z-index: 90;
}
.hamburger { background: none; border: none; color: #fff; cursor: pointer; width: 32px; height: 32px; }
.hamburger svg { width: 24px; height: 24px; }
.mobile-brand-group { display: flex; align-items: baseline; gap: 6px; }
.mobile-brand { font-weight: 800; font-size: 1.1rem; letter-spacing: .04em; }
.mobile-brand-sub { font-size: 0.75rem; opacity: 0.7; font-weight: 500; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 95; }

.main-content {
  margin-left: 260px; flex: 1; padding: 40px 48px 60px;
  max-width: 960px; width: 100%; animation: fadeInUp .4s ease;
}
@keyframes fadeInUp { from { opacity:0; transform:translateY(18px); } to { opacity:1; transform:translateY(0); } }

.tab-panel { display: none; animation: fadeInUp .35s ease; }
.tab-panel.active { display: block; }

.panel-header { margin-bottom: 28px; }
.panel-title { font-size: 1.75rem; font-weight: 800; color: #00354d; }
.panel-subtitle { color: #64748b; margin-top: 4px; font-size: .95rem; }

.card {
  background: #fff; border-radius: 16px; padding: 28px 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06); }
.card-title { font-size: 1.15rem; font-weight: 700; color: #00354d; margin-bottom: 12px; display: flex; align-items: center; }
.card-desc { color: #64748b; font-size: .9rem; margin-bottom: 18px; }

.form-group { margin-bottom: 20px; }
.form-label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: 6px; color: #334155; }
.required { color: #e11d48; }
.optional { color: #94a3b8; font-weight: 400; font-size: .8rem; }

.form-input, .form-textarea, .form-select {
  width: 100%; padding: 10px 14px; border: 1.5px solid #cbd5e1; border-radius: 10px;
  font-size: .938rem; color: #1e293b; background: #fff;
  transition: border-color .2s, box-shadow .2s; font-family: inherit;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { outline: none; border-color: #00BCEB; box-shadow: 0 0 0 3px rgba(0,188,235,.15); }
.form-textarea { resize: vertical; }

.select-wrapper { position: relative; }
.select-wrapper .form-select { appearance: none; padding-right: 36px; cursor: pointer; }
.select-arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; pointer-events: none; color: #94a3b8; }
.select-wrapper-sm { display: inline-block; min-width: 160px; }
.form-select-sm { padding: 7px 32px 7px 12px; font-size: .85rem; }

.category-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.category-row .select-wrapper { flex: 1; min-width: 180px; }
.category-row .form-input { flex: 1; min-width: 180px; }
.or-divider { color: #94a3b8; font-size: .8rem; font-weight: 600; }

.image-upload-area { border: 2px dashed #cbd5e1; border-radius: 12px; cursor: pointer; transition: border-color .2s, background .2s; position: relative; overflow: hidden; }
.image-upload-area:hover { border-color: #00BCEB; background: #f8fdff; }
.image-upload-area.dragover { border-color: #00BCEB; background: #e0f7fd; }
.image-upload-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 20px; text-align: center; color: #94a3b8; }
.image-upload-placeholder p { font-size: .88rem; margin: 0; }
.image-upload-hint { font-size: .75rem !important; margin-top: 4px !important; opacity: .7; }
.image-preview-wrapper { position: relative; padding: 12px; }
.image-preview { display: block; max-width: 100%; max-height: 240px; border-radius: 8px; margin: 0 auto; object-fit: contain; }
.image-remove-btn { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); border: none; cursor: pointer; color: #fff; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.image-remove-btn:hover { background: #e11d48; }

.choice-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; animation: fadeInUp .2s ease; }
.choice-row .form-input { flex: 1; }
.choice-input, .edit-choice-input { resize: vertical; min-height: 40px; line-height: 1.5; font-family: inherit; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.remove-choice-btn { background: none; border: none; cursor: pointer; color: #e11d48; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: background .15s; }
.remove-choice-btn:hover { background: #fee2e2; }

.correct-answers-hint { color: #94a3b8; font-size: .85rem; }
.correct-checkbox-group { display: flex; flex-direction: column; gap: 6px; }
.correct-checkbox-label { display: flex; align-items: flex-start; gap: 8px; font-size: .9rem; cursor: pointer; padding: 6px 10px; border-radius: 8px; transition: background .15s; white-space: pre-wrap; word-break: break-word; }
.correct-checkbox-label:hover { background: #f0f9ff; }
.correct-checkbox-label input[type="checkbox"] { accent-color: #00BCEB; width: 18px; height: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; padding-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 22px; border-radius: 10px; font-size: .938rem; font-weight: 600; border: none; cursor: pointer; transition: background .2s, transform .12s, box-shadow .2s; font-family: inherit; user-select: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, #00BCEB 0%, #009cc4 100%); color: #fff; box-shadow: 0 2px 8px rgba(0,188,235,.3); }
.btn-primary:hover { box-shadow: 0 4px 16px rgba(0,188,235,.35); background: linear-gradient(135deg, #00cffe 0%, #00BCEB 100%); }
.btn-outline { background: #fff; border: 1.5px solid #00BCEB; color: #00BCEB; }
.btn-outline:hover { background: #e8fafe; }
.btn-ghost { background: transparent; color: #64748b; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 7px 14px; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-danger { background: #e11d48; color: #fff; }
.btn-danger:hover { background: #be123c; }
.btn-warning { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: #fff; box-shadow: 0 2px 8px rgba(245,158,11,.3); }
.btn-warning:hover { box-shadow: 0 4px 16px rgba(245,158,11,.35); }

.registered-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.q-list-item { padding: 16px 0; border-bottom: 1px solid #f1f5f9; animation: fadeInUp .2s ease; }
.q-list-item:last-child { border-bottom: none; }
.q-list-item-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.q-list-category { display: inline-block; background: #e0f7fd; color: #006b8f; font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 6px; margin-bottom: 6px; }
.q-list-text { font-weight: 600; margin-bottom: 4px; }
.q-list-meta { color: #94a3b8; font-size: .82rem; }
.q-list-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; margin-right: 10px; vertical-align: middle; }
.q-list-actions { display: flex; gap: 6px; flex-shrink: 0; }
.q-list-actions .btn { padding: 6px 10px; }
.bookmark-q-btn { min-width: 34px; font-size: 1rem; line-height: 1; color: #94a3b8; }
.bookmark-q-btn.bookmarked { border-color: #f59e0b; color: #f59e0b; background: #fffbeb; }
.bookmark-q-btn.bookmarked:hover { background: #fef3c7; }
.q-list-bookmark-badge { display: inline-block; background: #fffbeb; color: #b45309; font-size: .7rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; margin-right: 6px; }

.cat-list-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid #f1f5f9; gap: 12px; animation: fadeInUp .2s ease; }
.cat-list-item:last-child { border-bottom: none; }
.cat-list-info { flex: 1; }
.cat-list-name { font-weight: 600; font-size: 1rem; color: #00354d; }
.cat-list-count { font-size: .82rem; color: #94a3b8; margin-top: 2px; }
.cat-list-actions { display: flex; gap: 6px; flex-shrink: 0; }
.cat-list-actions .btn { padding: 6px 12px; }

.empty-state { text-align: center; padding: 48px 20px; color: #94a3b8; }
.empty-state svg { width: 56px; height: 56px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: .95rem; }

.study-quiz-card { position: relative; overflow: hidden; }
.quiz-progress { height: 4px; background: #e2e8f0; border-radius: 2px; margin-bottom: 20px; }
.quiz-progress-bar { height: 100%; background: linear-gradient(90deg, #00BCEB, #00e5ff); border-radius: 2px; transition: width .4s ease; width: 0%; }
.quiz-counter { font-size: .85rem; color: #64748b; margin-bottom: 8px; text-align: right; }
.quiz-image-container { text-align: center; margin-bottom: 20px; }
.quiz-image { max-width: 100%; max-height: 320px; border-radius: 10px; object-fit: contain; box-shadow: 0 2px 12px rgba(0,0,0,.08); animation: fadeInUp .3s ease; }
.quiz-question { font-size: 1.15rem; font-weight: 700; margin-bottom: 24px; color: #00354d; line-height: 1.6; white-space: pre-wrap; }
.quiz-choices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.quiz-choice { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border: 1.5px solid #e2e8f0; border-radius: 12px; cursor: pointer; transition: border-color .2s, background .2s, transform .12s; font-size: .95rem; }
.quiz-choice:hover { border-color: #00BCEB; background: #f0fbff; }
.quiz-choice.selected { border-color: #00BCEB; background: #e0f7fd; }
.quiz-choice.answer-correct { border-color: #22c55e; background: #dcfce7; }
.quiz-choice.answer-correct:hover { border-color: #22c55e; background: #dcfce7; }
.quiz-choice.answer-wrong { border-color: #ef4444; background: #fee2e2; }
.quiz-choice.answer-wrong:hover { border-color: #ef4444; background: #fee2e2; }
.quiz-choice:active { transform: scale(.99); }
.quiz-choice input { accent-color: #00BCEB; width: 18px; height: 18px; pointer-events: none; flex-shrink: 0; margin-top: 2px; }
.quiz-choice span { white-space: pre-wrap; word-break: break-word; flex: 1; line-height: 1.5; }
.quiz-answer-tools { display: flex; justify-content: flex-start; margin: 0 0 12px; }
.quiz-answer-panel { border: 1px solid #dbe5ee; background: #f8fbfd; border-radius: 10px; padding: 14px 16px; margin: 0 0 20px; animation: fadeInUp .2s ease; }
.quiz-answer-section + .quiz-answer-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid #e2e8f0; }
.quiz-answer-section h3 { font-size: .95rem; color: #00354d; margin-bottom: 8px; }
.quiz-answer-empty,
.quiz-answer-note { color: #64748b; font-size: .9rem; line-height: 1.6; }
.quiz-answer-muted { color: #94a3b8; }
.quiz-answer-choice-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.quiz-answer-choice-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; }
.quiz-answer-choice-list li.is-correct { border-color: #86efac; background: #f0fdf4; }
.quiz-answer-choice-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.quiz-answer-choice-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.quiz-answer-label { min-width: 1.5rem; font-weight: 700; color: #00354d; }
.quiz-answer-correct { color: #15803d; font-weight: 700; font-size: .82rem; white-space: nowrap; }
.quiz-nav { display: flex; justify-content: flex-end; }
.study-option-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; color: #334155; cursor: pointer; user-select: none; }
.study-option-label input { accent-color: #00BCEB; width: 18px; height: 18px; }

.result-title { font-size: 1.4rem; font-weight: 800; color: #00354d; margin-bottom: 20px; text-align: center; }
.result-summary { display: flex; justify-content: center; gap: 32px; margin-bottom: 28px; flex-wrap: wrap; }
.result-stat { text-align: center; }
.result-stat-value { font-size: 2rem; font-weight: 800; color: #00BCEB; }
.result-stat-label { font-size: .82rem; color: #64748b; }
.result-wrong-item { padding: 14px 0; border-bottom: 1px solid #f1f5f9; }
.result-wrong-item:last-child { border-bottom: none; }
.result-wrong-q { font-weight: 600; margin-bottom: 4px; white-space: pre-wrap; word-break: break-word; }
.result-wrong-img { max-width: 100%; max-height: 180px; border-radius: 8px; margin-bottom: 8px; object-fit: contain; }
.result-wrong-a { color: #22c55e; font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.result-wrong-explanation { color: #64748b; font-size: .85rem; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.result-wrong-your { color: #e11d48; font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.result-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; }

.history-item { padding: 18px 0; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background .15s; border-radius: 8px; }
.history-item:hover { background: #f8fbfd; }
.history-item:last-child { border-bottom: none; }
.history-item-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.history-date { font-size: .82rem; color: #94a3b8; }
.history-category { font-weight: 600; }
.history-score { font-size: 1.1rem; font-weight: 700; color: #00BCEB; }
.history-bar-bg { height: 6px; background: #e2e8f0; border-radius: 3px; }
.history-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #00BCEB, #00e5ff); transition: width .5s ease; }

.export-import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.file-label { cursor: pointer; }
.import-status { margin-top: 12px; font-size: .85rem; }
.import-status.success { color: #22c55e; }
.import-status.error { color: #e11d48; }

.toast-container { position: fixed; top: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #fff; border-left: 4px solid #00BCEB; padding: 14px 20px; border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,.1); font-size: .9rem; animation: toastIn .35s ease forwards; max-width: 360px; }
.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #e11d48; }
.toast.removing { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(40px); } }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .25s; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal { background: #fff; border-radius: 16px; padding: 32px; max-width: 640px; width: 92%; max-height: 85vh; overflow-y: auto; position: relative; transform: translateY(20px) scale(.97); transition: transform .3s cubic-bezier(.4,0,.2,1); }
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-close { position: absolute; top: 12px; right: 12px; background: none; border: none; cursor: pointer; color: #94a3b8; width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.modal-close:hover { background: #f1f5f9; }
.modal-close svg { width: 20px; height: 20px; }
.modal-body h3 { margin-bottom: 12px; color: #00354d; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-label { font-weight: 600; font-size: .85rem; margin-bottom: 4px; display: block; color: #334155; }
.modal-body .form-input, .modal-body .form-textarea, .modal-body .form-select { width: 100%; padding: 9px 12px; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: .9rem; font-family: inherit; }
.modal-body .form-input:focus, .modal-body .form-textarea:focus { outline: none; border-color: #00BCEB; box-shadow: 0 0 0 3px rgba(0,188,235,.15); }
.modal-body .choice-row { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 6px; }
.modal-body .choice-row .form-input { flex: 1; }
.modal-body .correct-checkbox-group { display: flex; flex-direction: column; gap: 4px; }
.modal-body .correct-checkbox-label { display: flex; align-items: flex-start; gap: 6px; font-size: .85rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; white-space: pre-wrap; word-break: break-word; }
.modal-body .correct-checkbox-label:hover { background: #f0f9ff; }
.modal-body .correct-checkbox-label input[type="checkbox"] { accent-color: #00BCEB; width: 16px; height: 16px; }
.modal-body .image-preview { max-width: 100%; max-height: 200px; border-radius: 8px; margin: 8px 0; object-fit: contain; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal-body .image-upload-area { border: 2px dashed #cbd5e1; border-radius: 10px; cursor: pointer; transition: border-color .2s, background .2s; overflow: hidden; }
.modal-body .image-upload-area:hover { border-color: #00BCEB; background: #f8fdff; }
.modal-body .image-upload-placeholder { display: flex; flex-direction: column; align-items: center; padding: 16px; text-align: center; color: #94a3b8; font-size: .85rem; }
.modal-body .image-preview-wrapper { position: relative; padding: 8px; }
.modal-body .image-remove-btn { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); border: none; cursor: pointer; color: #fff; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.modal-body .image-remove-btn:hover { background: #e11d48; }

.hidden { display: none !important; }
.text-center { text-align: center; }

/* === 組み合わせ問題 (drag & drop) === */
.qtype-radio { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; cursor: pointer; }
.qtype-radio input { accent-color: #00BCEB; width: 16px; height: 16px; }

.pair-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; animation: fadeInUp .2s ease; }
.pair-row .form-input { flex: 1; min-height: 40px; resize: vertical; line-height: 1.5; font-family: inherit; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.pair-arrow { padding-top: 10px; color: #64748b; font-weight: 700; user-select: none; }
.remove-pair-btn { background: none; border: none; cursor: pointer; color: #e11d48; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: background .15s; }
.remove-pair-btn:hover { background: #fee2e2; }

.match-quiz { display: grid; grid-template-columns: 1fr 28px 1fr; gap: 12px; align-items: stretch; margin-bottom: 24px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-arrow-col { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.match-arrow-col span { display: flex; align-items: center; justify-content: center; min-height: 48px; color: #94a3b8; font-weight: 600; }
.match-item { padding: 12px 14px; border: 1.5px solid #e2e8f0; border-radius: 10px; background: #fff; white-space: pre-wrap; word-break: break-word; min-height: 48px; display: flex; align-items: center; font-size: .95rem; line-height: 1.5; }
.match-item.left { background: #f8fbfd; color: #00354d; font-weight: 600; }
.match-item.right { cursor: grab; user-select: none; transition: border-color .15s, background .15s, transform .12s, box-shadow .15s; }
.match-item.right:hover { border-color: #00BCEB; background: #f0fbff; }
.match-item.right.dragging { opacity: 0.4; cursor: grabbing; }
.match-item.right.drag-over { border-color: #00BCEB; background: #e0f7fd; box-shadow: 0 0 0 3px rgba(0,188,235,.15); }
.match-item.right .drag-handle { color: #cbd5e1; margin-right: 8px; flex-shrink: 0; }

.match-result-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .9rem; }
.match-result-table th, .match-result-table td { border: 1px solid #e2e8f0; padding: 8px 10px; text-align: left; vertical-align: top; white-space: pre-wrap; word-break: break-word; }
.match-result-table th { background: #f8fbfd; font-weight: 600; color: #00354d; }
.match-result-table td.ok { color: #22c55e; font-weight: 600; }
.match-result-table td.ng { color: #e11d48; font-weight: 600; }

/* === 選択肢の画像 === */
.choice-row { flex-direction: column; align-items: stretch; gap: 4px; }
.choice-row-main { display: flex; align-items: flex-start; gap: 8px; }
.choice-row-main .form-input { flex: 1; }
.choice-image-btn { padding: 6px 10px; flex-shrink: 0; }
.choice-image-preview { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0 4px 4px; }
.choice-image-preview img { max-width: 180px; max-height: 120px; object-fit: contain; border-radius: 6px; border: 1px solid #e2e8f0; background: #fff; }
.choice-image-rm-btn { background: #fff; border: 1px solid #e2e8f0; cursor: pointer; color: #e11d48; padding: 4px 10px; border-radius: 6px; font-size: .8rem; transition: background .15s; }
.choice-image-rm-btn:hover { background: #fee2e2; }

.choice-mini-img { width: 56px; height: 56px; object-fit: contain; border-radius: 6px; vertical-align: middle; margin-right: 8px; background: #f8fbfd; border: 1px solid #e2e8f0; flex-shrink: 0; }
.correct-checkbox-label { align-items: center; }
.choice-mini-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }

.quiz-choice { align-items: flex-start; }
.quiz-choice-content { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.quiz-choice-content span { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.quiz-choice-image { max-width: 100%; max-height: 240px; object-fit: contain; border-radius: 8px; border: 1px solid #e2e8f0; background: #fff; align-self: flex-start; }
.result-choice-img { max-width: 100%; max-height: 160px; object-fit: contain; border-radius: 6px; border: 1px solid #e2e8f0; background: #fff; margin-top: 4px; display: block; }

/* === 組み合わせ問題（プール + ドロップ枠 UI） === */
.match-pool-label { font-size: .82rem; color: #64748b; margin-bottom: 6px; font-weight: 600; }
.match-pool { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border: 1.5px dashed #cbd5e1; border-radius: 12px; background: #f8fbfd; min-height: 64px; margin-bottom: 16px; transition: border-color .15s, background .15s; }
.match-pool.drag-over { border-color: #00BCEB; background: #e0f7fd; }
.match-pool .match-item.right { margin: 0; }

.match-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.match-row { display: grid; grid-template-columns: 1fr 28px 1fr; gap: 12px; align-items: stretch; }
.match-row .match-arrow { display: flex; align-items: center; justify-content: center; color: #94a3b8; font-weight: 600; }
.match-slot { min-height: 48px; padding: 6px; border: 1.5px dashed #cbd5e1; border-radius: 10px; background: #fff; display: flex; align-items: stretch; transition: border-color .15s, background .15s; }
.match-slot.drag-over { border-color: #00BCEB; background: #e0f7fd; }
.match-slot:empty::before { content: "ここにドラッグ"; color: #cbd5e1; font-size: .82rem; align-self: center; padding: 0 10px; }
.match-slot .match-item.right { flex: 1; margin: 0; }

/* ── Markdown rendering ── */
.md-content { word-break: break-word; }
.md-content .md-p { margin: 0 0 8px; line-height: 1.6; }
.md-content .md-p:last-child { margin-bottom: 0; }
.md-content .md-h1,
.md-content .md-h2,
.md-content .md-h3,
.md-content .md-h4,
.md-content .md-h5,
.md-content .md-h6 { margin: 12px 0 6px; line-height: 1.3; font-weight: 700; }
.md-content .md-h1 { font-size: 1.4em; }
.md-content .md-h2 { font-size: 1.25em; }
.md-content .md-h3 { font-size: 1.1em; }
.md-content .md-h4,
.md-content .md-h5,
.md-content .md-h6 { font-size: 1em; }
.md-content .md-ul,
.md-content .md-ol { margin: 4px 0 8px; padding-left: 1.6em; }
.md-content .md-ol { padding-left: 2.4em; }
.md-content .md-ul li,
.md-content .md-ol li { margin: 2px 0; line-height: 1.55; }
.md-content .md-bq { margin: 6px 0; padding: 6px 12px; border-left: 3px solid #cbd5e1; color: #475569; background: #f8fafc; border-radius: 4px; }
.md-content .md-hr { border: none; border-top: 1px solid #e2e8f0; margin: 10px 0; }
.md-content .md-code { background: #f1f5f9; color: #0f172a; padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.md-content .md-pre { background: #0f172a; color: #e2e8f0; padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0; font-size: .85rem; line-height: 1.5; }
.md-content .md-pre code { background: transparent; color: inherit; padding: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.md-content a { color: #00BCEB; text-decoration: underline; }
.md-content strong { font-weight: 700; }
.md-content em { font-style: italic; }
.md-content .md-img { max-width: 100%; height: auto; border-radius: 6px; margin: 4px 0; }
.md-content .md-table-wrap { overflow-x: auto; margin: 8px 0 12px; }
.md-content .md-table { width: 100%; border-collapse: collapse; font-size: .92em; background: #fff; }
.md-content .md-table th,
.md-content .md-table td { border: 1px solid #dbe5ee; padding: 8px 10px; text-align: left; vertical-align: top; line-height: 1.55; }
.md-content .md-table th { background: #f8fbfd; color: #00354d; font-weight: 700; }
.md-content .md-table tr:nth-child(even) td { background: #fbfdff; }

/* 登録一覧の問題文セルでは長文をクリップ */
.q-list-text.md-content { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.q-list-text.md-content .md-p { margin-bottom: 4px; }
/* overflow:hidden により ol マーカー(例:「10.」)が左端で切れるのを防ぐ */
.q-list-text.md-content .md-ol,
.q-list-text.md-content .md-ul { list-style-position: inside; padding-left: 0; }

@media (max-width: 900px) { .export-import-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; } .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding: 72px 18px 40px; } .card { padding: 20px 18px; }
  .category-row { flex-direction: column; } .or-divider { display: none; } .result-summary { gap: 18px; }
}
@media (max-width: 480px) { .panel-title { font-size: 1.35rem; } .main-content { padding: 66px 12px 32px; } }