:root {
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: #eef2ff;
  color: #111827;
}

.container { max-width: 860px; margin: 0 auto; padding: 20px; }
header { margin-bottom: 20px; }
.header-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 2rem; margin: 0 0 12px; color: #1f2937; }
h2 { color: #1f2937; }
.card { background: #ffffff; border-radius: 20px; box-shadow: 0 14px 36px rgba(15,23,42,0.12); padding: 24px; }
.lead { margin: 0 0 18px; color: #4b5563; font-size: 1.05rem; }

.progress { background: #e5e7eb; border-radius: 999px; overflow: hidden; height: 14px; margin: 16px 0 20px; }
.progress-fill { background: #4338ca; width: 0%; height: 100%; transition: width .4s ease; }

.choice { margin: 14px 0; }
.choice label { display: inline-flex; align-items: flex-start; gap: .75rem; width: 100%; cursor: pointer; }
.choice input { margin-top: 4px; accent-color: #4338ca; }

pre { background: #111827; color: #f8fafc; border-radius: 14px; padding: 18px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }

button, .button {
  border: none; border-radius: 12px; padding: 12px 20px; font-size: 1rem; cursor: pointer;
  transition: transform .15s ease, background-color .15s ease; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; font-family: inherit;
}
button:hover, .button:hover { transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.primary { background: #4338ca; color: #ffffff; }
.secondary { background: #eef2ff; color: #1f2937; }
.danger { background: #ef4444; color: #ffffff; }
.ghost { background: transparent; color: #4338ca; padding: 8px 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
a { color: #4338ca; }

.problem-list { list-style: none; padding: 0; margin: 16px 0; }
.problem-item { margin: 12px 0; border-radius: 12px; overflow: hidden; border-left: 4px solid #ccc; }
.problem-item.correct { border-left-color: #10b981; background: #ecfdf5; }
.problem-item.incorrect { border-left-color: #ef4444; background: #fef2f2; }
.problem-link { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; text-decoration: none; cursor: pointer; color: inherit; background: none; border: none; width: 100%; font-size: 1rem; text-align: left; }
.problem-link:hover { background: rgba(67,56,202,0.05); }
.problem-num { font-weight: bold; color: #4338ca; min-width: 50px; flex-shrink: 0; }
.problem-question { flex: 1; margin: 0 12px; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.problem-status { font-weight: bold; white-space: nowrap; flex-shrink: 0; }
.status-correct { color: #10b981; }
.status-incorrect { color: #ef4444; }

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-content { background-color: #ffffff; border-radius: 20px; padding: 30px; max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto; position: relative; box-shadow: 0 25px 50px rgba(0,0,0,0.15); }
.modal-close { position: absolute; top: 12px; right: 12px; background: none; border: none; font-size: 28px; cursor: pointer; color: #6b7280; }
.modal-close:hover { color: #111827; }
.problem-detail h3 { margin-top: 0; }
.answer-section { background: #f3f4f6; padding: 16px; border-radius: 12px; margin: 16px 0; }
.answer-section p { margin: 8px 0; }
.user-answer { padding: 4px 8px; background: #fef3c7; border-radius: 6px; }
.correct-answer { padding: 4px 8px; background: #dcfce7; border-radius: 6px; font-weight: bold; }
.result-message { font-size: 1.1rem; font-weight: bold; padding: 12px; border-radius: 8px; text-align: center; }
.correct-message { background: #dcfce7; color: #15803d; }
.incorrect-message { background: #fee2e2; color: #991b1b; }
.modal-footer { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.explanation-box { background: #eff6ff; border-left: 4px solid #4338ca; border-radius: 8px; padding: 14px 16px; margin: 16px 0; color: #1e3a8a; font-size: .97rem; line-height: 1.6; }
footer { text-align: center; margin: 28px 0 0; color: #6b7280; font-size: .95rem; }

.set-list { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 16px; }
.set-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #f8faff; border-radius: 16px; border: 1px solid #e0e7ff; padding: 20px 24px; }
.set-info { flex: 1; min-width: 0; }
.set-title { margin: 6px 0 4px; font-size: 1.2rem; color: #1f2937; }
.set-desc { margin: 0 0 6px; color: #6b7280; font-size: .95rem; }
.set-count { margin: 0; font-size: .9rem; color: #9ca3af; }
.set-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: bold; margin-bottom: 4px; }
.difficulty-初級 { background: #dcfce7; color: #166534; }
.difficulty-中級 { background: #fef9c3; color: #854d0e; }
.difficulty-上級 { background: #fee2e2; color: #991b1b; }
.difficulty-カスタム { background: #ede9fe; color: #5b21b6; }
.set-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

.section { margin-top: 32px; padding-top: 24px; border-top: 1px solid #e5e7eb; }
.dropzone {
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed #c7d2fe; border-radius: 16px; padding: 24px; text-align: center;
  color: #6b7280; background: #f8faff; cursor: pointer; transition: border-color .15s ease, background .15s ease;
  width: 100%;
}
.dropzone.drag { border-color: #4338ca; background: #eef2ff; }
.dropzone input[type="file"] { display: none; }

.import-form { margin-top: 16px; background: #f8faff; border-radius: 14px; padding: 18px; border: 1px solid #e0e7ff; }
.import-form label { display: block; font-size: .9rem; color: #374151; margin: 10px 0 4px; }
.import-form input[type="text"], .import-form select {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #d1d5db; font-size: .95rem; font-family: inherit;
}

.import-textarea {
  width: 100%; min-height: 180px; padding: 12px; border-radius: 12px; border: 1px solid #d1d5db;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; resize: vertical;
}

.hamburger-btn {
  background: none; border: none; font-size: 1.6rem; line-height: 1; cursor: pointer;
  color: #1f2937; padding: 6px 10px; border-radius: 10px; margin-bottom: 12px;
}
.hamburger-btn:hover { background: #eef2ff; }

.menu-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.35); z-index: 1400;
}
.menu-overlay.open { display: block; }

.side-menu {
  position: fixed; top: 0; right: -280px; width: 260px; max-width: 80vw; height: 100%;
  background: #ffffff; box-shadow: -12px 0 30px rgba(15,23,42,0.18);
  padding: 24px 20px; display: flex; flex-direction: column; gap: 10px;
  transition: right .25s ease; z-index: 1500;
}
.side-menu.open { right: 0; }
.menu-close {
  align-self: flex-end; background: none; border: none; font-size: 26px; cursor: pointer;
  color: #6b7280; margin-bottom: 8px;
}
.menu-close:hover { color: #111827; }
.menu-link {
  display: block; padding: 12px 14px; border-radius: 10px; background: #f8faff;
  color: #1f2937; text-decoration: none; font-size: 1rem; text-align: left;
  border: none; cursor: pointer; font-family: inherit;
}
.menu-link:hover { background: #eef2ff; transform: none; }

.history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f8faff; border: 1px solid #e0e7ff; border-radius: 12px; padding: 14px 18px; margin: 10px 0; }
.history-info { min-width: 0; }
.history-title { font-weight: bold; color: #1f2937; }
.history-meta { color: #6b7280; font-size: .88rem; margin-top: 2px; }
.history-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.small { padding: 8px 14px; font-size: .88rem; }

.empty-note { color: #6b7280; font-size: .95rem; }

.timer-toggle { display: flex; align-items: center; gap: 8px; margin: 4px 0 20px; font-size: .95rem; color: #374151; cursor: pointer; }
.timer-toggle input { accent-color: #4338ca; }

.quiz-timer { margin: 4px 0 18px; }
.quiz-timer-bar { background: #e5e7eb; border-radius: 999px; overflow: hidden; height: 8px; }
.quiz-timer-bar-fill { background: #f59e0b; width: 100%; height: 100%; transition: width 1s linear; }
.quiz-timer-text { margin: 6px 0 0; font-size: .85rem; color: #6b7280; }

.stats-card { background: #f8faff; border: 1px solid #e0e7ff; border-radius: 16px; padding: 20px 24px; margin: 16px 0; }
.stats-title { margin: 0 0 4px; font-size: 1.1rem; color: #1f2937; }
.stats-meta { margin: 0 0 12px; font-size: .9rem; color: #6b7280; }
.stats-chart { width: 100%; height: 90px; display: block; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .25s ease;
  z-index: 2000;
}
.toast.show { opacity: 1; }

@media (max-width: 560px) {
  .set-card { flex-direction: column; align-items: stretch; }
  .set-actions { flex-direction: row; }
  .history-item { flex-direction: column; align-items: stretch; }
}

/* 画面が広い時は左の余白にナビメニューを常時展開し、ハンバーガーは隠す */
@media (min-width: 1100px) {
  body { display: flex; align-items: flex-start; }

  .hamburger-btn, .menu-close, .menu-overlay { display: none !important; }

  .side-menu {
    position: static;
    order: -1;
    flex: 0 0 240px;
    width: 240px;
    height: auto;
    min-height: 100vh;
    right: auto;
    box-shadow: none;
    border-right: 1px solid #e5e7eb;
    padding: 32px 20px;
    transition: none;
  }

  .container { flex: 1 1 auto; }
}
