* {
  box-sizing: border-box;
}

body {
  --app-text-size: 16px;
  --app-control-size: 15px;
  --app-question-size: 16px;
  margin: 0;
  background: #f6f7fb;
  color: #222;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: var(--app-text-size);
  line-height: 1.7;
}

body[data-font-size="small"] {
  --app-text-size: 15px;
  --app-control-size: 14px;
  --app-question-size: 15px;
}

body[data-font-size="large"] {
  --app-text-size: 18px;
  --app-control-size: 16px;
  --app-question-size: 19px;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 12px calc(140px + env(safe-area-inset-bottom));
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(246, 247, 251, 0.96);
  border-bottom: 1px solid #ddd;
  padding: 12px 0;
  backdrop-filter: blur(8px);
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  flex-shrink: 0;
}

.menu-wrap,
.service-switcher-wrap {
  position: relative;
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-size: 20px;
}

.home-button {
  margin: 0;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  color: #222;
  font: inherit;
  text-align: left;
}

.home-button:not(:disabled):hover {
  color: #255ec7;
  background: transparent;
  box-shadow: none;
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

hr {
  border: none;
  border-top: 1px solid #e6e8ed;
  margin: 18px 0;
}

input,
select {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
}

button {
  border: none;
  border-radius: 8px;
  padding: 11px 14px;
  margin: 4px;
  font-weight: 700;
  cursor: pointer;
  font-size: var(--app-control-size);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 3px solid rgba(37, 94, 199, 0.24);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  box-shadow: none;
}

.card {
  background: white;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

#searchView > .card,
#practiceListView > .card {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.primary {
  background: #255ec7;
  color: white;
}

.primary:not(:disabled):hover {
  background: #1f51ad;
  box-shadow: 0 6px 14px rgba(37, 94, 199, 0.18);
}

.secondary {
  background: #edf2ff;
  color: #255ec7;
}

.secondary:not(:disabled):hover {
  background: #dfe8ff;
}

.danger {
  background: #fff0f0;
  color: #d63333;
}

.hidden {
  display: none !important;
}

.auth-status,
.message {
  color: #666;
  font-size: 13px;
}

.auth-status-purchase-link {
  color: #255ec7;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-loading-view {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-loading-view h2 {
  margin-bottom: 4px;
}

.auth-loading-view .message {
  margin: 0;
}

.auth-start-guide,
.auth-password-guide,
.auth-account-note {
  color: #555;
  font-size: 14px;
  line-height: 1.6;
}

.auth-start-guide {
  margin: 12px 0 8px;
}

.auth-password-guide,
.auth-account-note {
  margin: 8px 0;
}

.auth-agreement {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 14px 0 10px;
  color: #555;
  font-size: 14px;
  line-height: 1.6;
}

.auth-agreement input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
}

.auth-agreement a {
  color: #255ec7;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-purchase-content {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #eef0f3;
}

.auth-purchase-heading {
  margin: 0 0 10px;
  font-size: 18px;
}

.main-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
}

.main-tabs button {
  background: white;
  border: 1px solid #ddd;
  color: #333;
}

.main-tabs button.active {
  background: #255ec7;
  color: white;
  border-color: #255ec7;
}

.menu-button {
  width: 44px;
  height: 44px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0;
  background: #255ec7;
  color: white;
  border-radius: 12px;
}

.menu-button span {
  width: 21px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  display: block;
}

.service-switch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #255ec7;
  color: #ffffff;
}

.service-switch-button:not(:disabled):hover {
  background: #1f51ad;
}

.service-switch-icon {
  color: currentColor;
  font-size: 18px;
  line-height: 1;
}

.service-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(246, 247, 251, 0.76);
  backdrop-filter: blur(2px);
}

.service-loading-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  padding: 14px 16px;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  background: #ffffff;
  color: #344160;
  font-weight: 700;
  box-shadow: 0 12px 36px rgba(0,0,0,0.16);
}

.service-switcher {
  position: absolute;
  top: 48px;
  right: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
  padding: 8px;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.service-switcher button {
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #44546a;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

.service-switcher button.active {
  border-color: #255ec7;
  background: #255ec7;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(37, 94, 199, 0.16);
}

.service-switcher button:not(.active):not(:disabled):hover {
  background: #f3f6fb;
}

.header-menu {
  position: absolute;
  top: 48px;
  right: 0;
  width: 300px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 8px;
}

.header-menu button,
.header-menu-link {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  padding: 11px 14px;
  border-radius: 8px;
  text-align: left;
  margin: 0;
  background: white;
  color: #333;
  font-family: inherit;
  font-size: var(--app-control-size);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
}

.header-menu button:hover,
.header-menu-link:hover {
  background: #f3f6fb;
}

.menu-font-size {
  padding: 4px 4px 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid #eef0f3;
}

.menu-font-size-label {
  margin: 0 2px 6px;
  color: #667085;
  font-size: 12px;
  font-weight: 700;
}

.menu-font-size-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.menu-font-size-options button {
  min-height: 36px;
  padding: 8px 6px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  text-align: center;
}

.menu-font-size-options button.active {
  border-color: #255ec7;
  background: #255ec7;
  color: #ffffff;
}

.account-access-status {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #eef0f3;
}

.account-access-status h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.account-access-status-list {
  display: grid;
  gap: 6px;
  color: #333;
  font-size: 13px;
  line-height: 1.45;
}

.account-access-status-item {
  padding: 9px 10px;
  border: 1px solid #e4e8ef;
  border-radius: 8px;
  background: #fafbfe;
}

.account-access-status-service {
  font-weight: 700;
}

.account-access-status-state {
  margin-top: 2px;
  color: #255ec7;
  font-weight: 700;
}

.account-access-status-date {
  margin-top: 1px;
  color: #667085;
}

.account-access-status-purchase-link {
  display: inline-block;
  margin-top: 4px;
  color: #667085;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.account-access-status-purchase-link:hover {
  color: #255ec7;
}

.app-version-info {
  margin-top: 8px;
  padding: 8px 6px 2px;
  border-top: 1px solid #eef0f3;
  color: #667085;
  font-size: 11px;
  line-height: 1.4;
  text-align: right;
}

.section {
  margin-bottom: 10px;
}

.resume-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.history-button {
  background: #eef2f8;
  color: #1f2d3d;
  border: 1px solid #d8dee8;
}

.history-button:not(:disabled):hover {
  background: #e3e9f2;
}

.resume-button {
  background: #fff3e8;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.resume-button:not(:disabled):hover {
  background: #ffead5;
  border-color: #fdba74;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.recommend-button {
  background: #369bde;
  color: white;
}

.reset-button {
  background: #ff8787;
  color: white;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#categoryButtons .all-button,
#yearButtons .all-button {
  flex-basis: 100%;
  width: fit-content;
}

.category-group-list {
  flex-basis: 100%;
  display: grid;
  gap: 10px;
}

.category-filter-group {
  padding: 10px;
  border: 1px solid #d8dee8;
  border-radius: 10px;
  background: #fbfcff;
}

.category-group-toggle {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #44546a;
  font-size: 13px;
  text-align: left;
}

.category-group-toggle:not(:disabled):hover {
  background: #eef4ff;
  border-color: #d8e5ff;
}

.category-group-toggle-icon {
  flex: 0 0 auto;
  color: #255ec7;
  font-size: 16px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.category-group-toggle[aria-expanded="false"] {
  margin-bottom: 0;
}

.category-group-toggle[aria-expanded="false"] .category-group-toggle-icon {
  transform: rotate(180deg);
}

.category-group-panel {
  margin-top: 8px;
}

.full-width-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

#difficultyButtons,
#favoriteButtons,
#statusButtons {
  display: flex;
  flex-wrap: wrap;
}

#difficultyButtons .toggle,
#favoriteButtons .toggle,
#statusButtons .toggle {
  flex: 0 0 84px;
  width: 84px;
  min-width: 0;
  margin: 0;
  padding-inline: 8px;
}

#favoriteButtons .toggle {
  flex-basis: 128px;
  width: 128px;
}

.toggle {
  background: #f0f0f0;
  color: #333;
}

.toggle.active {
  background: #3498db;
  color: white;
}

.toggle.all-button {
  background: #eef2f7;
  color: #333;
}

.toggle.all-button.active {
  background: #255ec7;
  color: white;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.action-column {
  display: grid;
  gap: 8px;
}

.sync-description {
  margin: 0 0 14px;
  color: #44546a;
  font-size: 14px;
  line-height: 1.7;
}

.list-header,
.view-title-row,
.exercise-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.preset-section {
  margin-top: 20px;
}

.preset-section h3 {
  margin-top: 0;
}

.preset-list {
  display: grid;
  gap: 12px;
}

.preset-card {
  width: 100%;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #ffffff;
  color: #333;
  text-align: left;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.preset-card:active {
  transform: scale(0.995);
}

.preset-card.active {
  border-color: #3498db;
  box-shadow: 0 6px 18px rgba(52,152,219,0.18);
}

.preset-main {
  padding: 14px 14px 10px;
}

.preset-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: #222;
}

.preset-free-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f7ec;
  color: #1e7d3a;
  font-size: 12px;
  font-weight: 700;
}

/* ログイン前：サービスの説明 */
.auth-about {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e3e8ee;
}

.auth-about-title {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.4;
}

.auth-about-lead {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.7;
  color: #4a5561;
}

.auth-about-list {
  margin: 0 0 10px;
  padding-left: 1.2em;
  font-size: 14px;
  line-height: 1.7;
}

.auth-about-list li + li {
  margin-top: 2px;
}

.auth-about-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
}

.auth-about-link::after {
  content: " ›";
}

.auth-free-trial-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #bfe6c9;
  border-radius: 12px;
  background: #f1faf3;
}

.auth-free-trial-notice p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #245c36;
}

.auth-free-trial-badge {
  flex: none;
  margin-top: 1px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #1e7d3a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.preset-footer {
  border-top: 1px solid #eef0f3;
  background: #fbfcfe;
}

.progress-bar-list {
  width: 100%;
  height: 14px;
  display: flex;
  overflow: hidden;
  background: #e5e7eb;
}

.seg-correct {
  background: #5bbf73;
}

.seg-incorrect {
  background: #e56b6f;
}

.seg-unanswered {
  background: #b8bcc4;
}

.progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 10px 14px 12px;
  font-size: 12px;
  color: #555;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  display: inline-block;
  flex-shrink: 0;
}

.dot-correct {
  background: #5bbf73;
}

.dot-incorrect {
  background: #e56b6f;
}

.dot-unanswered {
  background: #b8bcc4;
}

.score-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.score-toolbar h3 {
  margin: 0;
}

.score-difficulty-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(40px, 1fr));
  gap: 6px;
  min-width: min(100%, 220px);
}

.score-difficulty-button {
  min-height: 40px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #d7dce5;
  background: #ffffff;
  color: #333;
}

.score-difficulty-button.active {
  border-color: #255ec7;
  background: #255ec7;
  color: #ffffff;
}

.score-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0 14px;
  color: #667085;
  font-size: 12px;
}

.score-summary-strip span {
  display: inline-flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid #e1e5ec;
  border-radius: 8px;
  background: #fbfcfe;
  white-space: nowrap;
}

.score-summary-strip b {
  color: #1f2937;
  font-size: 14px;
  line-height: 1;
}

.score-section {
  margin-top: 20px;
}

.score-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.score-section-heading h3 {
  margin: 0;
}

.score-section-heading .message {
  margin: 0;
}

.score-table-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.score-table-tools .message {
  margin: 0;
}

.score-table-view-buttons {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border: 1px solid #d7dce5;
  border-radius: 8px;
  background: #f6f8fb;
  flex-shrink: 0;
}

.score-table-view-button {
  min-height: 32px;
  margin: 0;
  padding: 6px 9px;
  border-radius: 6px;
  background: transparent;
  color: #44546a;
  font-size: 12px;
}

.score-table-view-button.active {
  background: #255ec7;
  color: #ffffff;
}

.score-chart-list {
  display: grid;
  gap: 14px;
}

.score-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.score-chart-category {
  font-weight: 700;
}

.score-chart-rate {
  color: #667085;
  font-size: 13px;
}

.score-stacked-bar {
  display: flex;
  width: 100%;
  height: 18px;
  overflow: hidden;
  border: 1px solid #dfe3ea;
  border-radius: 6px;
  background: #e5e7eb;
}

.score-bar-correct {
  background: #5bbf73;
}

.score-bar-incorrect {
  background: #e56b6f;
}

.score-bar-unanswered {
  background: #b8bcc4;
}

.score-chart-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 6px;
  color: #555;
  font-size: 12px;
}

.score-chart-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.score-table-wrap {
  overflow-x: auto;
  border: 1px solid #e1e5ec;
  border-radius: 8px;
}

.score-table-wrap.wide .score-heat-table {
  min-width: 560px;
}

.score-heat-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.score-heat-table th,
.score-heat-table td {
  border: 1px solid #e1e5ec;
  padding: 9px 8px;
  text-align: center;
}

.score-heat-table th {
  background: #f6f8fb;
  color: #384252;
}

.score-heat-table th:first-child {
  width: 92px;
}

.score-heat-empty {
  color: #98a2b3;
  background: #fafafa;
}

.score-heat-rate {
  color: #222;
  font-weight: 800;
  line-height: 1.2;
}

.sticky-action {
  position: fixed;
  right: max(16px, calc((100vw - 960px) / 2 + 16px));
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 16px));
  justify-content: flex-end;
  align-items: center;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  pointer-events: none;
  z-index: 30;
}

.sticky-action .primary {
  min-width: auto;
  min-height: 52px;
  margin: 0;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: #f97316;
  color: #ffffff;
  font-size: 17px;
  pointer-events: auto;
  box-shadow: 0 14px 28px rgba(194, 65, 12, 0.36);
}

.sticky-action .primary:not(:disabled):hover {
  background: #ea580c;
  box-shadow: 0 16px 32px rgba(194, 65, 12, 0.42);
}

.sticky-action .primary:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 8px 16px rgba(194, 65, 12, 0.34);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 27, 38, 0.42);
}

.modal-panel {
  width: min(100%, 440px);
  padding: 16px;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(0,0,0,0.22);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #dde3ed;
  border-radius: 999px;
  background: #ffffff;
  color: #44546a;
  font-size: 22px;
  line-height: 1;
}

.icon-button:not(:disabled):hover {
  background: #f3f6fb;
}

.modal-message {
  margin: 0 0 14px;
  color: #44546a;
  font-weight: 700;
}

.notice-panel {
  width: min(100%, 360px);
}

.site-notice-backdrop {
  z-index: 60;
}

.site-notice-panel {
  width: min(100%, 420px);
}

.site-notice-content {
  margin: 0 0 14px;
  color: #26364d;
  font-size: var(--app-text-size);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.site-notice-content > :first-child {
  margin-top: 0;
}

.site-notice-content > :last-child {
  margin-bottom: 0;
}

.site-notice-content img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 8px;
}

.site-notice-content a {
  color: #255ec7;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.exercise-result-panel {
  width: min(100%, 380px);
}

.exercise-result-summary {
  display: grid;
  gap: 14px;
  margin: 6px 0 16px;
}

.exercise-result-score {
  display: grid;
  place-items: center;
  min-height: 104px;
  border: 1px solid #c9d7f0;
  border-radius: 12px;
  background: #f6f8ff;
  color: #1f51ad;
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
}

.exercise-result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.exercise-result-stats div {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
}

.exercise-result-stats dt {
  margin: 0 0 4px;
  color: #66758a;
  font-size: 12px;
  font-weight: 700;
}

.exercise-result-stats dd {
  margin: 0;
  color: #26364d;
  font-size: 16px;
  font-weight: 800;
}

.notice-actions {
  justify-content: flex-end;
}

.count-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.count-option {
  min-height: 48px;
  margin: 0;
  border: 1px solid #d8dee8;
  background: #ffffff;
  color: #26364d;
}

.count-option:not(:disabled):hover {
  border-color: #255ec7;
  background: #f6f8ff;
}

.count-option.primary {
  border-color: #255ec7;
  background: #255ec7;
  color: #ffffff;
}

.count-option.primary:not(:disabled):hover {
  background: #1f51ad;
}

.star {
  background: transparent;
  color: #f08c00;
  font-size: 28px;
  padding: 4px 8px;
}

.progress {
  height: 10px;
  background: #e9ecef;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

#progressBar {
  height: 100%;
  width: 0%;
  background: #255ec7;
}

.question-html {
  /* 外側のカード（.card）の中に白い箱をもう1つ重ねると、スマホで本文の幅が狭くなる。
     枠線・余白・角丸・背景は付けず、問題文と解説をタイトルやボタンと同じ左端にそろえる */
  min-height: 180px;
  font-size: var(--app-question-size);
  overflow-wrap: anywhere;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.question-html.loading {
  /* 枠を付けないので、読み込み中も色や背景は変えない（中央にそろえるだけ） */
  display: grid;
  align-items: center;
}

.question-loading {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 14px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #d9e2f2;
  border-top-color: #255ec7;
  border-radius: 999px;
  animation: spin 0.85s linear infinite;
}

.loading-copy {
  display: grid;
  gap: 9px;
}

.loading-title {
  color: #344160;
  font-weight: 700;
  font-size: 14px;
}

.loading-line {
  height: 10px;
  width: 72%;
  border-radius: 999px;
  background: linear-gradient(90deg, #e8edf5, #f8fafc, #e8edf5);
  background-size: 180% 100%;
  animation: shimmer 1.15s ease-in-out infinite;
}

.loading-line-wide {
  width: 94%;
}

.loading-line-short {
  width: 46%;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 6px;
}

.choices.choice-count-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choices.choice-count-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.choices.choice-count-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.choices button {
  display: grid;
  place-items: center;
  background: white;
  border: 2px solid #d0d7de;
  min-height: 76px;
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.choices button:not(:disabled):hover {
  border-color: #8ca3c7;
  background: #fbfdff;
}

.choices button.selected {
  border-color: #255ec7;
  background: #e7f0ff;
  color: #173b7a;
  box-shadow: inset 0 0 0 2px #255ec7, 0 0 0 4px rgba(37, 94, 199, 0.18), 0 8px 18px rgba(37, 94, 199, 0.18);
  transform: translateY(-1px);
}

.choices button.correct {
  border-color: #2f9e44;
  background: #ebfbee;
  color: #1f7a35;
  box-shadow: 0 0 0 3px rgba(47, 158, 68, 0.14);
}

.choices button.incorrect {
  border-color: #e03131;
  background: #fff5f5;
  color: #c92a2a;
  box-shadow: 0 0 0 3px rgba(224, 49, 49, 0.12);
}

.choices button:disabled {
  opacity: 1;
}

.result {
  font-weight: 700;
  min-height: 0;
  margin: 4px 0 0;
  padding: 0;
  color: #666;
}

.result:not(:empty) {
  display: inline-flex;
  align-items: center;
  min-height: 0;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
}

.result.is-correct {
  background: #eaf7ee;
  color: #1f7a35;
  border: 1px solid #b8e2c3;
}

.result.is-incorrect {
  background: #fff0f0;
  color: #c92a2a;
  border: 1px solid #ffc9c9;
}

.result.is-muted {
  background: #f1f4f8;
  color: #44546a;
  border: 1px solid #d8dee8;
}

.answer-inline-result {
  display: inline-flex;
  align-items: center;
  scroll-margin-top: 96px;
  margin: 10px 0 14px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

.answer-inline-result.is-correct {
  background: #eaf7ee;
  color: #1f7a35;
  border: 1px solid #b8e2c3;
}

.answer-inline-result.is-incorrect {
  background: #fff0f0;
  color: #c92a2a;
  border: 1px solid #ffc9c9;
}

.action-row {
  display: grid;
  gap: 10px;
}

.action-row button,
.exercise-utility-panel button {
  width: 100%;
  min-height: 50px;
  margin: 0;
}

.primary-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}

.primary-actions button {
  position: relative;
  border: 1px solid transparent;
}

#answerButton:not(:disabled),
#nextButton:not(:disabled) {
  background: #255ec7;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 94, 199, 0.2);
}

#answerButton:disabled,
#nextButton:disabled {
  background: #eef1f5;
  color: #8a96a8;
  border-color: #d8dee8;
  opacity: 1;
}

.exercise-utility-panel {
  display: grid;
  gap: 10px;
  margin: 10px 0 12px;
  padding: 12px;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  background: #f8fafd;
}

.exercise-utility-panel button {
  background: #ffffff;
  border: 1px solid #d8dee8;
  color: #44546a;
}

.exercise-utility-panel button:not(:disabled):hover {
  background: #f1f5fb;
  border-color: #b9c5d8;
}

.permission-error {
  border: 2px solid #ffb3b3;
  background: #fff5f5;
  border-radius: 12px;
  padding: 18px;
  color: #c92a2a;
}

.permission-error h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.permission-error p {
  line-height: 1.7;
}

.permission-error ul {
  margin: 10px 0;
  padding-left: 20px;
  color: #7a2323;
  line-height: 1.7;
}

.permission-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.permission-error-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #255ec7;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.permission-error-actions a:last-child {
  border: 1px solid #255ec7;
  background: #ffffff;
  color: #255ec7;
}

.box28 {
  position: relative;
  margin: 0;
  padding: 1.5em 0.5em 0.5em;
  border: solid 2px #ffa500;
  background: #ffffff;
}

.box28 .box-title {
  position: absolute;
  top: -2px;
  left: -2px;
  padding: 0 9px;
  background: #ffa500;
  color: #ffffff;
  font-weight: bold;
}

.box26 {
  position: relative;
  margin: 0.75em 0;
  padding: 0.5em;
  border: solid 3px #0059ff;
  border-radius: 8px;
}

.box26 .box-title {
  position: absolute;
  display: inline-block;
  top: -0.7em;
  left: 1em;
  padding: 1px;
  line-height: 1;
  background: #ffffff;
  color: #0059ff;
  font-weight: bold;
}

.box8 {
  padding: 0.5em;
  margin: 0.5em 0;
  background: #f5f5f5;
  border-left: solid 15px #a9a9a9;
}

.question-html h2#h2 {
  font-size: 1em;
  padding: 0.4em;
  color: #282828;
  background: #eff3fa;
  border-left: solid 20px #3078ff;
}

.question-html h2#h2q {
  font-size: 1em;
  padding: 0.4em;
  color: #ffffff;
  background: #255ec7;
}

.question-html h3#h3 {
  font-size: 1em;
  padding: 0.3em;
  color: #282828;
  background: #f6f8fc;
  border-left: solid 8px #7aa8ff;
}

.question-html h4#h4 {
  font-size: 1em;
  padding: 0.1em;
  color: #282828;
  background: #ffffff;
}

.question-html .box2 {
  font-size: 0.8em;
  padding: 0.3em 0.8em;
  margin: 0;
  font-weight: bold;
  color: #0059ff;
  background: #ffffff;
  border: solid 2px #0059ff;
  border-radius: 8px;
}

.question-html .box2 p {
  margin: 0;
  padding: 0;
}

.question-html .box6 {
  position: relative;
  margin: 0;
  padding: 25px 10px 7px;
  background: #f5f5f5;
  border: dashed 2px #5f5f5f;
}

.question-html .box6 .box-title {
  position: absolute;
  display: inline-block;
  top: -2px;
  left: -2px;
  padding: 0 9px;
  height: 25px;
  line-height: 25px;
  font-size: 17px;
  background: #5f5f5f;
  color: #ffffff;
  font-weight: bold;
}

.question-html .box6 p {
  margin: 0;
  padding: 0;
}

table,
th,
td {
  border: 1px solid #ccc;
  border-collapse: collapse;
}

table {
  width: 100%;
}

th,
td {
  padding: 6px;
}

@media (max-width: 640px) {
  .app {
    padding: 8px;
  }

  .header-main {
    align-items: center;
  }

  h1 {
    font-size: 17px;
  }

  .header-main {
    gap: 8px;
  }

  .service-switcher button {
    min-height: 38px;
    font-size: 12px;
  }

  .service-switch-button {
    width: 44px;
    height: 44px;
    font-size: 12px;
  }

  .choices,
  .primary-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choices.choice-count-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .choices.choice-count-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .choices.choice-count-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .choices button {
    min-height: 70px;
    font-size: 28px;
  }

  .choices.choice-count-5 button {
    min-height: 58px;
    font-size: 22px;
  }

  .full-width-group {
    grid-template-columns: repeat(2, 1fr);
  }

  .list-header,
  .view-title-row,
  .exercise-head {
    align-items: flex-start;
  }

  .score-toolbar,
  .score-section-heading,
  .score-chart-head,
  .score-table-tools {
    display: grid;
  }

  .score-table-wrap {
    overflow-x: visible;
  }

  .score-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-table-wrap.wide {
    overflow-x: auto;
  }

  .score-table-wrap.wide .score-heat-table {
    min-width: 560px;
  }

  .score-heat-table {
    min-width: 0;
    font-size: 12px;
  }

  .score-heat-table th,
  .score-heat-table td {
    padding: 6px 3px;
  }

  .score-heat-table th:first-child {
    width: 58px;
  }

  .score-heat-rate {
    font-size: 12px;
  }

}

.latest-exercise-box {
  margin: 16px 0 8px;
  padding: 10px 12px;
  border: 1px solid #cfd8ea;
  background: #f6f8ff;
  border-radius: 10px;
  font-size: 13px;
}

.latest-exercise-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: #1f2d5c;
}

.latest-exercise-row {
  line-height: 1.5;
  margin: 2px 0;
  color: #1f2d5c;
}

.report-link-box {
  text-align: center;
  margin: 12px 0 18px;
  font-size: 12px;
}

.exercise-finish-box {
  border: 1px solid #d8e2ef;
  background: #f8fbff;
  border-radius: 12px;
  padding: 16px;
}

.exercise-finish-box h3 {
  margin-top: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .question-html {
    transition: none;
  }

  .button-spinner,
  .loading-spinner,
  .loading-line {
    animation: none;
  }
}

.secondary-link {
  display: inline-block;
  background: #edf2ff;
  color: #255ec7;
  text-decoration: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 700;
}

.secondary-link {
  display: inline-block;
  background: #edf2ff;
  color: #255ec7;
  text-decoration: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 700;
  text-align: center;
}

.purchase-box {
  margin-top: 16px;
}

.purchase-guide {
  margin: 14px 0 18px;
  padding: 14px;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: #fbfcff;
}

.purchase-guide h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.purchase-guide ol {
  margin: 0;
  padding-left: 20px;
  color: #344160;
  line-height: 1.7;
}

.purchase-guide p {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid #e4e8ef;
  color: #665f1f;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.7;
}

.purchase-link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.purchase-link-card {
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 14px;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: #fbfcff;
  color: #1f2d5c;
  text-decoration: none;
}

.purchase-link-card:first-child {
  grid-column: 1 / -1;
}

.purchase-link-card:hover {
  border-color: #255ec7;
  box-shadow: 0 6px 14px rgba(37, 94, 199, 0.12);
}

.purchase-link-card span {
  font-weight: 700;
}

.purchase-link-card strong {
  color: #255ec7;
  font-size: 14px;
}

.purchase-confirm-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: spin 0.85s linear infinite;
}

.purchase-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 12px 4px 0;
  color: #344160;
  font-size: 14px;
  font-weight: 700;
}

.purchase-loading .loading-spinner {
  width: 20px;
  height: 20px;
  border-width: 2px;
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  .purchase-link-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------- まとめ解説 ---------------- */

.summary-links {
  /* 目立たせるためオレンジ系にする。解説の中の引用（基準・留意事項）は青、問題文の引用はオレンジだが解説を挟んで離れている */
  /* 枠の外と中の余白は、解説の「基準・留意」の枠（.box26: margin 0.75em 0 / padding 0.5em / 角 8px）とそろえる */
  margin: 0.75em 0;
  padding: 0 0 0.5em;
  overflow: hidden;
  border: 2px solid #f97316;
  border-radius: 8px;
  background: #fff7ed;
}

.summary-links-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.4em 0.5em;
  background: #ea580c;
}

.summary-links-title {
  margin: 0;
  font-size: 16px;
  color: #ffffff;
}

.summary-links-count {
  padding: 1px 8px;
  border-radius: 999px;
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
  color: #9a3412;
}

.summary-links-lead {
  margin: 0.4em 0.5em 0.5em;
  font-size: 12px;
  line-height: 1.5;
  color: #7a5236;
}

.summary-link-list {
  display: grid;
  gap: 8px;
  padding: 0 0.5em;
}

.summary-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  background: #ffffff;
  color: #1c2533;
  font-size: var(--app-control-size);
  text-align: left;
}

.summary-link:not(:disabled):hover {
  border-color: #ea580c;
  background: #fffaf5;
}

.summary-link-main {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
}

/* 過去問で、どの肢に対応するまとめかの印（iOS と同じ色） */
.summary-link-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 2px;
}

.summary-choice {
  padding: 0 0.5em;
  border-radius: 4px;
  background: #9a3412;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}

/* まとめ画面の本文の上：この問題のどの肢に対応するまとめか */
.summary-choices {
  margin: 0 0 10px;
  padding: 6px 10px;
  border-left: 3px solid #f97316;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.85em;
  line-height: 1.6;
}

.summary-link-title {
  font-weight: 700;
  line-height: 1.45;
}

.summary-link-meta {
  font-size: 12px;
  line-height: 1.5;
  color: #66758a;
}

.summary-link-locked {
  opacity: 0.72;
}

.summary-link-locked .summary-link-title {
  color: #5a6472;
}

.summary-locked-note {
  margin: 8px 10px 4px;
  font-size: 13px;
  line-height: 1.7;
  color: #8a5a00;
}

.summary-link-arrow {
  flex: 0 0 auto;
  font-size: 22px;
  line-height: 1;
  color: #ea580c;
}

.summary-rank {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 6px;
  background: #e6ebf2;
  color: #44546a;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.summary-rank-S {
  /* オレンジの枠の中で埋もれないよう、濃い赤にする */
  background: #b91c1c;
  color: #ffffff;
}

.summary-rank-A {
  background: #255ec7;
  color: #ffffff;
}

.summary-rank-B {
  background: #dbe7fb;
  color: #1f3f7a;
}

/* 背面の固定。iOS Safari は overflow: hidden だけでは背面がスクロールするため、位置ごと固定する（summary.js） */
body.summary-modal-open {
  overflow: hidden;
}

.summary-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  background: rgba(20, 27, 38, 0.5);
}

.summary-modal-panel {
  display: flex;
  flex-direction: column;
  width: min(100%, 960px);
  height: 100%;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
}

.summary-modal-head {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 3px solid #f97316;
}

.summary-modal-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.summary-modal-head h2 {
  margin: 0;
  font-size: 15px;
  color: #9a3412;
}

/* 長い法律名・章名でも×ボタンを押し出さない */
.summary-modal-head .icon-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: 0;
}

.summary-modal-meta {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.5;
  color: #53627a;
}

.summary-modal-meta .summary-rank {
  min-width: 22px;
  height: 22px;
  font-size: 12px;
}

/* カテゴリ ＞ 章は 2 行まで（全文は title で見られる） */
.summary-modal-place {
  display: -webkit-box;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  padding-top: 2px;
}

.summary-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  outline: none;
}

.summary-modal-foot {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #e1e6ee;
  background: #fbfcfe;
}

.summary-modal-foot button {
  margin: 0;
  white-space: nowrap;
}

.summary-modal-nav {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.summary-modal-nav.hidden {
  display: none;
}

.summary-modal-nav button {
  min-width: 84px;
}

.summary-modal-position {
  min-width: 44px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  color: #44546a;
}

.summary-modal-close {
  flex: 0 0 auto;
  min-width: 120px;
  margin-left: auto;
}

/* まとめが 1 件だけのときは「閉じる」を広く */
.summary-modal-nav.hidden + .summary-modal-close {
  flex: 1 1 auto;
}

.summary-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 4px;
  color: #53627a;
  font-weight: 700;
}

.summary-unavailable {
  padding: 16px;
  border: 1px solid #e4d7c3;
  border-radius: 10px;
  background: #fffaf2;
  color: #6b4e16;
}

.summary-unavailable p {
  margin: 0 0 10px;
}

.summary-source {
  margin: 12px 0 0;
  font-size: 12px;
  color: #66758a;
}

/* 本文（box-matome のマークアップ: mtm-code / mtm-ttl / mtm-h / mtm-lb / mtm-tbl） */
.summary-body {
  /* 箱（背景・左線・中の余白）は付けない。まとめ専用の画面なので区別が要らず、左右の幅を本文と表に回す */
  padding: 0;
  background: transparent;
  color: #111a22;
  font-size: var(--app-question-size);
  line-height: 1.9;
  overflow-wrap: anywhere;
}

/* 「まとめ〔ID〕」は管理用の番号なので出さない（アプリと同じ）。データは変えない */
.summary-body .mtm-code {
  display: none;
}

.summary-body .mtm-ttl {
  display: block;
  margin: 6px 0 10px;
  font-size: 1.1em;
  font-weight: 700;
  line-height: 1.55;
}

.summary-body .mtm-h {
  display: inline-block;
  margin: 14px 0 2px;
  font-weight: 700;
}

.summary-body .mtm-ttl + .mtm-h,
.summary-body .mtm-ttl + br + .mtm-h {
  margin-top: 2px;
}

.summary-body .mtm-lb {
  margin-right: 0.45em;
  font-weight: 700;
}

.summary-body table.mtm-tbl {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
  table-layout: fixed;
  background: #ffffff;
  font-size: 0.88em;
}

.summary-body table.mtm-tbl th,
.summary-body table.mtm-tbl td {
  padding: 6px 8px;
  border: 1px solid #c9d3db;
  text-align: left;
  vertical-align: top;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.summary-body table.mtm-tbl th {
  background: #e4edf6;
  font-weight: 700;
}

@media (max-width: 640px) {
  .summary-modal-head,
  .summary-modal-body,
  .summary-modal-foot {
    padding-left: 12px;
    padding-right: 12px;
  }

  .summary-body {
    padding: 0;   /* 箱を付けないので、スマホ幅でも中の余白は要らない */
  }

  .summary-body table.mtm-tbl th,
  .summary-body table.mtm-tbl td {
    padding: 5px 5px;
  }

  .summary-modal-nav {
    gap: 4px;
  }

  .summary-modal-nav button {
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
  }

  .summary-modal-close {
    min-width: 0;
  }
}

/* 横向き・ツールバー表示中など、高さが低い画面ではヘッダーとフッターを詰める */
@media (max-height: 480px) {
  .summary-modal-head {
    align-items: center;
    padding-top: calc(4px + env(safe-area-inset-top));
    padding-bottom: 4px;
  }

  .summary-modal-heading {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .summary-modal-head h2 {
    flex: 0 0 auto;
    font-size: 14px;
  }

  .summary-modal-meta {
    align-items: center;
    min-width: 0;
    margin-top: 0;
  }

  .summary-modal-place {
    -webkit-line-clamp: 1;
    line-clamp: 1;
    padding-top: 0;
  }

  .summary-modal-head .icon-button {
    width: 36px;
    height: 36px;
  }

  .summary-modal-body {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .summary-modal-foot {
    padding-top: 4px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
  }

  .summary-modal-foot button {
    padding-top: 7px;
    padding-bottom: 7px;
  }
}

/* 報告フォーム（問題・解説／まとめ解説の共通。まとめのモーダルの上にも出せるよう z-index を上にする） */
.report-form-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(20, 27, 38, 0.5);
}

.report-form-panel {
  width: min(100%, 520px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
}

.report-form-panel .modal-head h2 {
  font-size: 17px;
}

.report-form-panel .icon-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: 0;
}

.report-form-target {
  padding: 8px 10px;
  border-left: 3px solid #1f5183;
  background: #eef3f8;
  color: #1f3f7a;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.report-form-label {
  display: block;
  margin: 14px 0 4px;
  font-size: 14px;
  font-weight: 700;
}

.report-form-panel textarea,
.report-form-panel input[type="text"] {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid #cfd6e0;
  border-radius: 8px;
  /* 16px 未満だと iOS Safari が入力時に拡大する */
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
}

.report-form-panel textarea {
  resize: vertical;
}

.report-form-panel input[readonly],
.report-form-panel textarea[readonly] {
  background: #f1f3f6;
  color: #53627a;
}

.report-form-note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: #53627a;
}

.report-form-message {
  min-height: 1.5em;
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: #44546a;
}

.report-form-message.is-ok {
  color: #2e7d32;
}

.report-form-message.is-error {
  color: #c0392b;
}

.report-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.report-form-actions button {
  flex: 1 1 0;
  margin: 0;
}

/* 演習結果：前回との比較と全問の一覧（アプリと同じ形） */
.exercise-result-panel {
  max-height: min(88vh, 900px);
  overflow-y: auto;
}

.exercise-result-section {
  margin: 0;
}

.exercise-result-section h3 {
  margin: 0 0 6px;
  color: #66758a;
  font-size: 13px;
  font-weight: 700;
}

.exercise-compare,
.exercise-result-list {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
}

.exercise-compare-row,
.exercise-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid #edf1f6;
}

.exercise-compare-row:first-child,
.exercise-result-row:first-child {
  border-top: 0;
}

.exercise-compare-caption {
  flex: 0 0 auto;
  min-width: 74px;
  font-size: 14px;
  font-weight: 700;
}

.exercise-compare-detail {
  flex: 1 1 auto;
  min-width: 0;
  color: #66758a;
  font-size: 12px;
}

.exercise-compare-value {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 700;
}

.exercise-compare-caption.up,
.exercise-compare-value.up { color: #1f8a4c; }
.exercise-compare-caption.down,
.exercise-compare-value.down { color: #c0392b; }
.exercise-compare-caption.same,
.exercise-compare-caption.first,
.exercise-compare-value.same,
.exercise-compare-value.first { color: #1f2d3d; }
.exercise-compare-value.zero { color: #a3adba; }

.exercise-result-mark {
  flex: 0 0 auto;
  width: 20px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.exercise-result-mark.correct { color: #1f8a4c; }
.exercise-result-mark.incorrect { color: #c0392b; }

.exercise-result-body {
  display: grid;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

.exercise-result-code {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 700;
}

.exercise-result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #66758a;
  font-size: 12px;
}

.exercise-result-rank {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #eef1f6;
  color: #66758a;
  font-size: 11px;
  font-weight: 800;
}

.exercise-result-badge {
  padding: 1px 6px;
  border: 1px solid;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.exercise-result-badge.up { border-color: #9fd7b6; color: #1f8a4c; }
.exercise-result-badge.down { border-color: #f0b8b0; color: #c0392b; }
.exercise-result-badge.same,
.exercise-result-badge.first { border-color: #d8dee8; color: #66758a; }

.exercise-result-star {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1f2d3d;
  font-size: 18px;
  cursor: pointer;
}

.exercise-result-star:hover { background: #f2f5f9; }

.exercise-result-actions {
  display: grid;
  gap: 8px;
}

/* 演習履歴（この端末の中の記録） */
.history-panel {
  width: min(100%, 520px);
  max-height: min(88vh, 900px);
  overflow-y: auto;
}

.history-lead {
  margin: 0 0 10px;
  color: #66758a;
  font-size: 12px;
  line-height: 1.6;
}

.history-empty {
  margin: 24px 0;
  color: #66758a;
  font-size: 13px;
  text-align: center;
}

.history-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid #edf1f6;
}

.history-row:first-child { border-top: 0; }

.history-main {
  display: grid;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.history-main:hover { background: #f5f8fc; }

.history-source { font-size: 14px; font-weight: 700; color: #1f2d3d; }
.history-date,
.history-condition { color: #66758a; font-size: 12px; }
.history-condition {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-status { font-size: 12px; color: #1f2d3d; }

.history-bar {
  display: flex;
  height: 6px;
  margin: 4px 0 2px;
  border-radius: 3px;
  background: #e7ecf3;
  overflow: hidden;
}

.history-bar-correct { background: #1f8a4c; }
.history-bar-incorrect { background: #c0392b; }
.history-bar-progress { background: #2f6fd0; }

.history-side {
  display: grid;
  gap: 6px;
  align-content: center;
  flex: 0 0 auto;
}

.history-resume {
  width: 64px;
  height: 64px;
  border: 1px solid #fdba74;
  border-radius: 10px;
  background: #f97316;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.history-resume:disabled {
  background: #f1f3f6;
  border-color: #e0e5ec;
  color: #a3adba;
  cursor: default;
}

.history-delete {
  width: 64px;
  padding: 4px 0;
  border: 1px solid #e0e5ec;
  border-radius: 8px;
  background: #ffffff;
  color: #c0392b;
  font-size: 12px;
  cursor: pointer;
}

.history-detail {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
}

.history-detail-row {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid #edf1f6;
  font-size: 13px;
}

.history-detail-row:first-child { border-top: 0; }
.history-detail-label { flex: 0 0 auto; min-width: 116px; color: #66758a; }
.history-detail-value { flex: 1 1 auto; min-width: 0; color: #1f2d3d; word-break: break-word; }

.history-section-title {
  margin: 16px 0 6px;
  color: #66758a;
  font-size: 13px;
  font-weight: 700;
}

.history-actions { display: grid; gap: 6px; }

.history-action {
  padding: 10px 12px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
  color: #255ec7;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.history-action:hover { background: #f5f8fc; }

.history-questions {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
}

.history-question {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid #edf1f6;
}

.history-question:first-child { border-top: 0; }

.history-question-mark {
  flex: 0 0 auto;
  width: 20px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.history-question-mark.correct { color: #1f8a4c; }
.history-question-mark.incorrect { color: #c0392b; }
.history-question-mark.pending { color: #a3adba; }

.history-question-body { display: grid; gap: 2px; min-width: 0; }
.history-question-code { font-size: 14px; font-weight: 700; }
.history-question-meta { color: #66758a; font-size: 12px; }
