:root {
  color-scheme: light;
  --ink: #1d2430;
  --muted: #5e6878;
  --line: #d8dee8;
  --paper: #ffffff;
  --wash: #f4f7fa;
  --active-line: #e7f2ff;
  --trace-line: #fff2cc;
  --ok: #16794c;
  --ok-wash: #e5f5ed;
  --bad: #b3261e;
  --accent: #2457a6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--wash);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto;
}

.workspace {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.mode-switcher {
  display: flex;
  background: var(--wash);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
  gap: 4px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-btn:hover {
  color: var(--ink);
}

.mode-btn.active {
  background: var(--paper);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
}

.score {
  min-width: 86px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  background: #f9fbfd;
}

.guide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #f7fbff;
}

.guide-label {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.guide-text {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.guide-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.guide-highlight {
  position: relative;
  z-index: 1;
  outline: 3px solid #ffb020;
  outline-offset: 4px;
  box-shadow: 0 0 0 8px rgba(255, 176, 32, 0.18);
  transition: outline-color 160ms ease, box-shadow 160ms ease;
}

.generator {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(240px, 0.55fr) minmax(160px, 0.25fr);
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.statement-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.statement-field span,
.source-field span,
.tests-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.statement-card {
  margin: 18px 24px 0;
  padding: 16px 20px;
  background: #f0f6ff;
  border: 1px solid #d0e1fd;
  border-left: 5px solid var(--accent);
  border-radius: 6px;
}

.statement-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.statement-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.source-field,
.tests-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  padding: 10px;
  border: 1px solid #b8c0cc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.rule-options {
  display: grid;
  align-content: end;
  gap: 10px;
}

.rule-options label {
  display: grid;
  gap: 6px;
}

.rule-options span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rule-options input {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #b8c0cc;
  border-radius: 6px;
  font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.exercise-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  min-height: calc(100vh - 390px);
  border-bottom: 1px solid var(--line);
}

.problem {
  min-height: calc(100vh - 390px);
  min-width: 0;
}

.code {
  margin: 0;
  padding: 24px;
  overflow: auto;
  font: 16px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre;
}

.code-line {
  display: grid;
  grid-template-columns: 3.5ch minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  min-width: max-content;
  border-radius: 4px;
}

.code-line.active {
  background: var(--active-line);
}

.code-line.trace-line {
  background: var(--trace-line);
  box-shadow: inset 4px 0 0 #d97706;
}

.code-line.reviewed {
  background: var(--ok-wash);
}

.code-line.trace-line.reviewed {
  background: linear-gradient(90deg, var(--ok-wash), var(--trace-line));
}

.code-line.trace-highlight {
  background-color: #ffe082 !important;
  box-shadow: inset 4px 0 0 #ffb300;
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

/* コンパイルエラー行の赤文字ハイライト */
.code-line.has-error {
  background-color: #fef2f2 !important;
  box-shadow: inset 4px 0 0 #ef4444;
}

.code-line.has-error .line-number {
  color: #ef4444 !important;
  font-weight: 700;
}

.code-line.has-error .line-code {
  color: #dc2626 !important; /* 赤文字 */
  font-weight: 600 !important;
  text-decoration: underline wavy #ef4444 2px !important;
  -webkit-text-decoration: underline wavy #ef4444 2px !important;
  text-underline-offset: 4px !important;
  /* SVG波線下線：ブラウザのwavy解像度や描画バグに関係なくIDE風の赤い波線を確実に表示 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 3'%3E%3Cpath d='M0 3 Q 1.5 0, 3 3 T 6 3' fill='none' stroke='%23ef4444' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: repeat-x !important;
  background-position: bottom left !important;
  background-size: 6px 4px !important;
  padding-bottom: 3px !important;
}

.line-review {
  display: grid;
  place-items: center;
  width: 22px;
  min-width: 22px;
  min-height: 22px;
  height: 22px;
  margin: 1px 3px 0 0;
  padding: 0;
  border: 1px solid #adb7c5;
  border-radius: 4px;
  background: #fff;
  color: transparent;
  font: 14px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.line-review:hover,
.line-review:focus-visible {
  border-color: var(--ok);
  color: var(--ok);
  outline: none;
}

.code-line.reviewed .line-review {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

.line-number {
  padding-right: 12px;
  color: #7b8493;
  text-align: right;
  user-select: none;
}

.line-code {
  display: block;
  min-width: 64ch;
  min-height: 1.45em;
  padding: 0 4px;
  color: #111827;
  outline: none;
  white-space: pre;
}

.line-code:focus {
  background: rgba(255, 255, 255, 0.58);
}

.answerbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px 24px;
  background: #fbfcfe;
}

.actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  border-color: #9aa5b5;
  background: #fff;
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.result {
  min-height: 100%;
  padding: 12px;
  background: var(--paper);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.student-id-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  font-size: 13px;
  color: #334155;
}

.student-id-widget strong {
  color: #0f172a;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.change-id-btn {
  padding: 2px 8px !important;
  font-size: 11px !important;
  border-radius: 10px !important;
  background: #e2e8f0 !important;
  color: #475569 !important;
  border: 1px solid #cbd5e1 !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.change-id-btn:hover {
  background: #cbd5e1 !important;
  color: #0f172a !important;
}

.case-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: #fbfcfe;
  overflow-y: auto;
  position: sticky;
  top: 10px;
  align-self: start;
  max-height: calc(100vh - 60px);
}

.result-summary {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.test-results {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.test-result {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.test-result.failed {
  border-color: var(--bad);
  background: #fff8f7;
}

.test-result h3 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.test-result span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.test-result pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.output-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.output-comparison .output-pane:only-child {
  grid-column: 1 / -1;
}

.output-pane {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.output-pane pre {
  min-height: 3.8em;
  padding: 8px;
  border: 1px solid #e2e7ef;
  border-radius: 4px;
  background: #fbfcfe;
}

.output-line {
  display: block;
  width: 100%;
}

.output-line.has-trace {
  cursor: pointer;
}

.output-line.has-trace:hover {
  background-color: rgba(217, 119, 6, 0.15); /* 薄いオレンジ色のホバー背景 */
}

.output-line.trace-highlight-pair {
  background-color: rgba(245, 158, 11, 0.25) !important;
  border-radius: 4px;
  box-shadow: inset 3px 0 0 #f59e0b;
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.result.bad {
  border-color: var(--bad);
  color: var(--bad);
}

/* 問題選択バー */
.exercise-selector-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--wash);
  border-bottom: 1px solid var(--line);
}

.selector-label {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
}

.exercise-select {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.exercise-select:focus {
  border-color: var(--accent);
}

/* 問題保存＆ストックリスト（管理者用） */
.save-exercise-area {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.save-form {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.save-form .title-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.save-form input {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* ロック状態のエディタ */
.code.locked {
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

button.accent {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 16px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

button.accent:hover {
  opacity: 0.9;
}

button.accent:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

/* 学習開始ボタンの黄色ハイライト（未開始時） */
#startExerciseBtn:not(:disabled) {
  position: relative;
  background: #1e5fc9;
  color: #ffffff;
  border: 2px solid #f59e0b;
  outline: 3px solid #fde047;
  outline-offset: 2px;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.7);
  animation: startBtnPulse 1.8s infinite ease-in-out;
  font-weight: 800;
  cursor: pointer;
  transform: scale(1.02);
  transition: transform 0.15s ease, background-color 0.15s ease;
}

@keyframes startBtnPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.8), 0 0 8px rgba(245, 158, 11, 0.5);
    outline-color: #fde047;
  }
  50% {
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0), 0 0 18px rgba(245, 158, 11, 0.85);
    outline-color: #f59e0b;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0), 0 0 8px rgba(245, 158, 11, 0.5);
    outline-color: #fde047;
  }
}

#startExerciseBtn:not(:disabled):hover {
  background: #194ca3;
  transform: scale(1.06);
}

#startExerciseBtn:disabled {
  outline: none;
  box-shadow: none;
  border: none;
  animation: none;
  transform: none;
}

.saved-list-area {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.saved-list-area h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.saved-item-title {
  font-weight: 700;
  color: var(--ink);
}

.saved-item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-left: 8px;
}

.saved-item-delete {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--bad);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

.saved-item-delete:hover {
  background: #fdf2f2;
}

/* クイズカード */
.quiz-card {
  margin: 12px 24px 0;
  padding: 16px 20px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 5px solid #f59e0b;
  border-radius: 6px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quiz-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: #b45309;
}

.quiz-question {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 12px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink);
  transition: all 0.15s ease;
}

.quiz-option:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.quiz-option input[type="radio"] {
  cursor: pointer;
  margin: 0;
}

.quiz-option.selected {
  border-color: #f59e0b;
  background: #fef3c7;
  font-weight: 600;
}

.quiz-answer-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.quiz-answer-row input {
  padding: 8px 12px;
  width: 220px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.quiz-answer-row input:focus {
  border-color: #f59e0b;
}

.quiz-feedback {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.quiz-feedback.success {
  color: #15803d;
}

.quiz-feedback.warning {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.quiz-feedback.error {
  color: var(--bad);
}

/* Mid Quiz Builder Styles (Location + Variables) */
.mid-quiz-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.mid-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
}

.mid-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mid-location-list, .mid-var-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mid-var-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mid-item-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #1e293b;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mid-item-label:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.mid-item-label.selected {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.mid-item-label input[type="radio"],
.mid-item-label input[type="checkbox"] {
  accent-color: #2563eb;
  cursor: pointer;
}

/* Compile Error Card in Case Panel */
.compile-error-card {
  background: #fff;
  border: 1px solid #fed7d7;
  border-left: 5px solid #e53e3e;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(229, 62, 62, 0.08);
  overflow: hidden;
  margin-bottom: 16px;
}

.compile-error-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: #fff5f5;
  border-bottom: 1px solid #fee2e2;
}

.compile-error-icon {
  font-size: 20px;
  line-height: 1.2;
}

.compile-error-title-group {
  flex: 1;
}

.compile-error-title {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 700;
  color: #c53030;
}

.compile-error-subtitle {
  margin: 0;
  font-size: 13px;
  color: #742a2a;
}

.compile-error-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compile-error-action-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: #2d3748;
  background: #ebf8ff;
  border: 1px solid #bee3f8;
  border-radius: 6px;
  padding: 10px 12px;
}

.compile-error-action-tip code {
  background: #bee3f8;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: bold;
  color: #2b6cb0;
}

.compile-error-details {
  margin-top: 4px;
  font-size: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}

.compile-error-details summary {
  padding: 8px 12px;
  cursor: pointer;
  color: #4a5568;
  font-weight: 500;
  user-select: none;
}

.compile-error-details summary:hover {
  color: #2d3748;
  background: #edf2f7;
}

.compile-error-raw-log {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  color: #4a5568;
  background: #2d3748;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

@media (max-width: 880px) {
  .app {
    width: 100%;
    margin: 0;
  }

  .workspace {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .topbar,
  .guide,
  .generator,
  .answerbar,
  .exercise-layout {
    display: block;
  }

  .score {
    margin-top: 12px;
  }

  .code {
    border-bottom: 1px solid var(--line);
    font-size: 14px;
  }

  .case-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .output-comparison {
    grid-template-columns: 1fr;
  }

  .tests-field,
  .guide-actions,
  .rule-options {
    margin-top: 12px;
  }

  .result {
    margin-top: 12px;
  }
}

/* 正解（AC）時の演出スタイル */
@keyframes successPop {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.score-badge-success {
  background: #16a34a !important;
  color: #ffffff !important;
  border-color: #15803d !important;
  animation: successPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.success-banner-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 1.5px solid #6ee7b7;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 14px;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.12);
  animation: successPop 0.35s ease;
}

.success-banner-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.success-banner-content {
  flex: 1;
}

.success-banner-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
  color: #065f46;
}

.success-banner-desc {
  margin: 0;
  font-size: 13px;
  color: #047857;
  font-weight: 500;
}

.test-result.passed {
  border-color: #a7f3d0;
  background-color: #f0fdf4;
}

.test-result.passed h3 {
  color: #15803d;
}

.quiz-card-success {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
  border-color: #86efac !important;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15) !important;
}

.quiz-card-success .quiz-question-title {
  color: #15803d !important;
}

/* ========================================================
   問題一覧ビュー & カードレイアウト
   ======================================================== */
.exercise-list-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 8px 4px;
  animation: fadeIn 0.25s ease;
}

.course-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.course-header-info h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.course-desc {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.course-progress-card {
  min-width: 240px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}

.progress-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.phase-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.phase-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 2px solid #e2e8f0;
}

.phase-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.exercise-card {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.exercise-card:hover {
  transform: translateY(-2px);
  border-color: #3b82f6;
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.12);
}

.exercise-card.completed {
  border-color: #86efac;
  background: #fcfdfc;
}

.exercise-card.completed:hover {
  border-color: #22c55e;
  box-shadow: 0 6px 14px rgba(34, 197, 94, 0.12);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card-title-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  line-height: 1.35;
}

.card-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.card-status-badge.completed {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.card-status-badge.unsolved {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.card-desc {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.45;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.card-phase-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}

.card-action-btn {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.card-action-btn.start {
  background: #2563eb;
  color: #ffffff;
}

.card-action-btn.start:hover {
  background: #1d4ed8;
}

.card-action-btn.retry {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
}

.card-action-btn.retry:hover {
  background: #e2e8f0;
}

/* ========================================================
   問題演習ビュー & ナビゲーションバー
   ======================================================== */
.exercise-solve-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.25s ease;
}

.solve-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.back-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.back-arrow {
  font-weight: 800;
  font-size: 14px;
}

.current-exercise-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.phase-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.current-exercise-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

/* ========================================================
   全ケース合格時のクリアバナー（次の問題への誘導）
   ======================================================== */
.completion-banner {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px solid #34d399;
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.18);
  animation: successPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.completion-banner-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.completion-banner-icon {
  font-size: 42px;
  line-height: 1;
}

.completion-banner-text h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
  color: #065f46;
}

.completion-banner-text p {
  margin: 0;
  font-size: 14px;
  color: #047857;
  font-weight: 500;
}

.completion-banner-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-start;
}

.btn-large {
  font-size: 15px !important;
  font-weight: 800 !important;
  padding: 10px 20px !important;
  border-radius: 8px !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-large:hover {
  transform: translateY(-1px);
}

#nextExerciseBtn {
  background: #059669;
  color: #ffffff;
  border: none;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.3);
}

#nextExerciseBtn:hover {
  background: #047857;
  box-shadow: 0 5px 14px rgba(5, 150, 105, 0.4);
}

#backToListFromSuccessBtn {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

#backToListFromSuccessBtn:hover {
  background: #f8fafc;
  color: #0f172a;
}

/* ========================================================
   エディタ上部ヘッダー & リセットボタン
   ======================================================== */
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.editor-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.editor-reset-btn {
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.editor-reset-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
  border-color: #94a3b8;
}

/* 思考ガイド内の修正後テストボタン */
.quiz-test-btn {
  background: #059669 !important;
  color: #ffffff !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  padding: 8px 20px !important;
  border-radius: 6px !important;
  border: none !important;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.3) !important;
  transition: all 0.15s ease !important;
}

.quiz-test-btn:hover:not(:disabled) {
  background: #047857 !important;
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(5, 150, 105, 0.4) !important;
}

/* ========================================================
   マーカー（蛍光ペン）風のチカチカ・パルスハイライト
   ======================================================== */
@keyframes markerPulse {
  0% {
    background-color: rgba(254, 240, 138, 0.45);
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.4);
  }
  50% {
    background-color: rgba(254, 240, 138, 0.95);
    box-shadow: 0 0 8px 2px rgba(250, 204, 21, 0.55);
  }
  100% {
    background-color: rgba(254, 240, 138, 0.45);
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.4);
  }
}

/* クイズ文内のマーカーハイライト */
.marker-pulse {
  background-color: rgba(254, 240, 138, 0.95);
  color: #854d0e;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  display: inline;
  animation: markerPulse 1.5s infinite ease-in-out;
}

/* 出力行（期待される出力＆実際の出力）のマーカーハイライト */
.output-line.attention-pulse {
  animation: markerPulse 1.5s infinite ease-in-out !important;
  background-color: rgba(254, 240, 138, 0.95) !important;
  color: #854d0e !important;
  font-weight: 800 !important;
  border-radius: 4px;
  border-left: 3px solid #eab308 !important;
}

/* ========================================================
   入力例とPython入力コードのカラー対応ハイライト
   ======================================================== */
.input-guide-line {
  display: inline-block;
  padding: 2px 8px;
  margin: 1px 0;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
}

.input-guide-line-1 {
  background-color: #e0f2fe;
  border-left: 4px solid #38bdf8;
  color: #0c4a6e;
}

.input-guide-line-2 {
  background-color: #f3e8ff;
  border-left: 4px solid #a855f7;
  color: #581c87;
}

.code-line.input-guide-code-1 {
  position: relative;
  background-color: #e0f2fe;
  border-left: 4px solid #38bdf8;
  border-radius: 4px;
  padding-right: 78px;
}

.code-line.input-guide-code-2 {
  position: relative;
  background-color: #f3e8ff;
  border-left: 4px solid #a855f7;
  border-radius: 4px;
  padding-right: 78px;
}

.code-line.input-guide-code-1::after,
.code-line.input-guide-code-2::after {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.code-line.input-guide-code-1::after {
  content: "入力 1行目";
  background: rgba(56, 189, 248, 0.18);
  color: #0369a1;
}

.code-line.input-guide-code-2::after {
  content: "入力 2行目";
  background: rgba(168, 85, 247, 0.16);
  color: #7e22ce;
}

/* ========================================================
   終盤用 print文の書き方ヒントボタン＆パネル
   ======================================================== */
.editor-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.editor-check-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.print-hint-btn {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #facc15;
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.print-hint-btn:hover {
  background: #fef08a;
}

.print-hint-panel {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: #451a03;
}

.print-hint-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: #92400e;
}

.print-hint-close {
  background: transparent;
  border: none;
  color: #92400e;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.print-hint-close:hover {
  background: rgba(146, 64, 14, 0.12);
}

.print-hint-desc {
  margin: 0 0 8px;
}

.print-hint-examples {
  margin: 0 0 8px;
  padding-left: 20px;
}

.print-hint-examples li {
  margin-bottom: 3px;
}

.print-hint-panel code {
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: #78350f;
}

.print-hint-note {
  margin: 0;
  font-size: 12px;
  color: #78350f;
}

/* ========================================================
   開発・検証用クイックジャンプバー
   ======================================================== */
.admin-jump-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin-bottom: 12px;
  background: #f1f5f9;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
}

.admin-jump-label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  margin-right: 4px;
}

.admin-jump-btn {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.admin-jump-btn:hover {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0369a1;
}

/* ========================================================
   時間経過で出現するスキップ救済ボタン（4分経過後）
   ======================================================== */
.skip-exercise-btn {
  margin-left: auto;
  background: #475569;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
  animation: fadeIn 0.35s ease;
}

.skip-exercise-btn:hover {
  background: #334155;
}

/* 4分経過アナウンストースト */
.skip-notice-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  max-width: 390px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-left: 5px solid #2563eb;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.16);
  animation: fadeIn 0.3s ease;
}

.skip-notice-title {
  font-size: 14px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 4px;
}

.skip-notice-desc {
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #475569;
}

.skip-notice-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.skip-notice-go-btn {
  background: #475569;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.skip-notice-go-btn:hover {
  background: #334155;
}

.skip-notice-close-btn {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.skip-notice-close-btn:hover {
  background: #e2e8f0;
}
