:root {
  --page: #f4efe4;
  --card: #fbf8f0;
  --ink: #254a60;
  --muted: #6b7b7e;
  --line: #d3d9d0;
  --soft: #e7e9df;
  --hover: #eaece3;
  --green: #254a60;
  --accent: #b25c40;
  --serif: "Songti SC", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font:
    14px/1.6 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
  font-synthesis: none;
  color: var(--ink);
  background: var(--page);
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
select {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  padding: 10px 16px;
}
button:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--muted);
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
:is(button, a, select, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.primary {
  background: var(--ink);
  color: var(--card);
  border-color: var(--ink);
}
.primary:hover:not(:disabled) {
  background: var(--ink);
  color: var(--card);
  opacity: 0.9;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 max(28px, calc((100vw - 1160px) / 2));
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 2px;
}
.brand img {
  width: 32px;
  height: 32px;
}
.brand span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 12px;
}
.topbar-actions a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.topbar-actions a:hover {
  text-decoration: underline;
  text-underline-offset: 5px;
}
.theme-toggle {
  border: 0;
  background: transparent;
  padding: 8px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}
.theme-toggle svg {
  display: block;
}
main {
  max-width: 1160px;
  margin: auto;
  padding: 0 28px 60px;
}
.grammar-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 52px 0 40px;
}
.eyebrow {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 2px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
.grammar-intro h1 {
  margin: 13px 0 16px;
  font: 500 clamp(30px, 3.5vw, 42px)/1.35 var(--serif);
  letter-spacing: 1px;
}
.grammar-intro h1 span {
  display: block;
}
.grammar-intro p {
  color: var(--muted);
  font-size: 13px;
}
.intro-types {
  display: grid;
  gap: 13px;
  padding-left: 32px;
  border-left: 1px solid var(--line);
  min-width: 170px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 1px;
}
.intro-types b {
  margin-left: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 2px;
}
.level-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.level-tabs button {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px 24px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.level-tabs button + button {
  border-left: 1px solid var(--line);
}
.level-tabs strong {
  font:
    400 27px/1 Georgia,
    serif;
}
.level-tabs span {
  font-size: 13px;
  color: var(--muted);
}
.level-tabs small {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}
.level-tabs button[aria-pressed="true"] {
  background: var(--card);
  border-bottom-color: var(--accent);
}
.level-tabs button[aria-pressed="true"] strong {
  color: var(--accent);
}
.library-layout {
  padding-top: 24px;
}
.library-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 22px;
}
.library-progress progress {
  width: 100px;
  height: 3px;
}
.paper-library {
  scroll-margin-top: 20px;
}
.paper-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 12px 0;
}
.paper-pagination span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.paper-pagination button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 14px;
  font-size: 12px;
}
.paper-pagination button:disabled {
  opacity: 0.35;
  cursor: default;
}
.library-heading {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.library-heading h2 {
  font-size: 17px;
  font-weight: 600;
}
.library-heading h2 small {
  margin-left: 10px;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}
.library-heading p {
  color: var(--muted);
  font-size: 11px;
  margin-top: 5px;
}
.filters {
  display: flex;
  gap: 8px;
}
select {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 8px;
  font-size: 12px;
  max-width: 100%;
}
.paper-year {
  margin-bottom: 14px;
}
.paper-year h3 {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 3px;
  padding-bottom: 9px;
  font:
    400 19px/1.5 Georgia,
    serif;
  border-bottom: 1px solid var(--line);
}
.paper-year h3 span {
  color: var(--muted);
  font:
    10px/1.5 system-ui,
    sans-serif;
}
.paper {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 115px;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 0;
  padding: 10px;
  background: transparent;
}
.paper-date {
  font-size: 15px;
  font-weight: 600;
}
.paper-date small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  margin-top: 2px;
}
.paper-detail {
  color: var(--muted);
  font-size: 11px;
}
.paper-action {
  text-align: right;
}
.paper-action b {
  display: block;
  font-size: 12px;
  font-weight: 550;
}
.paper-progress {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 4px;
}
.paper-progress.has-progress {
  color: var(--accent);
}
.footnote {
  color: var(--muted);
  font-size: 11px;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
progress {
  appearance: none;
  display: block;
  width: 100%;
  height: 3px;
  border: 0;
  border-radius: 3px;
  background: var(--soft);
}
progress::-webkit-progress-bar {
  background: var(--soft);
  border-radius: 3px;
}
progress::-webkit-progress-value {
  background: var(--ink);
  border-radius: 3px;
}
progress::-moz-progress-bar {
  background: var(--ink);
}
.practice-view,
.results-view {
  padding-top: 28px;
}
.exercise-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  font-size: 12px;
  color: var(--muted);
}
.text-button {
  border: 0;
  background: transparent;
  padding-left: 0;
}
.workbench {
  display: grid;
  grid-template-columns: 182px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}
.workbench > aside {
  position: sticky;
  top: 24px;
  padding: 8px 0;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}
h2 {
  font-size: 16px;
}
.section-title > span {
  color: var(--muted);
  font-size: 12px;
}
.question-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin: 20px 0;
}
.question-grid button {
  padding: 7px 0;
  font-size: 11px;
  border-radius: 4px;
  background: transparent;
}
.question-grid .correct {
  background: #dcebdc;
  color: #356448;
}
.question-grid .wrong {
  background: #f3ddd5;
  color: #9e4637;
}
.question-grid .draft {
  background: #eee3c7;
}
.question-grid .current {
  box-shadow: inset 0 0 0 1px var(--ink);
  border-color: var(--ink);
}
.legend {
  color: var(--muted);
  font-size: 10px;
  line-height: 2;
}
aside .text-button {
  font-size: 11px;
  margin-top: 12px;
}
.question-card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px 40px;
}
.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}
.instruction {
  margin: 28px 0 18px;
  font-size: 12px;
  color: var(--muted);
}
.stem {
  margin-bottom: 26px;
  font:
    21px/2.1 "Hiragino Mincho ProN",
    "Yu Mincho",
    serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.option-row {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}
.option {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-align: left;
  padding: 13px 14px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.option-number {
  font:
    11px/1.8 system-ui,
    sans-serif;
  color: var(--muted);
}
.option.selected {
  background: var(--hover);
  border-color: var(--ink);
}
.option.right {
  background: #e7f0e3;
  border-color: #96b293;
}
.option.incorrect {
  background: #f7e5dc;
  border-color: #c59482;
}
.option:disabled {
  opacity: 1;
}
.hint {
  color: var(--muted);
  font-size: 11px;
  margin-top: 18px;
}
.feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 12px 16px;
  margin-top: 24px;
  font-size: 12px;
  border-radius: 5px;
}
.good {
  background: #e7f0e3;
  color: #356448;
}
.bad {
  background: #f7e5dc;
  color: #9e4637;
}
.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.question-actions {
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.explanation {
  margin-top: 26px;
}
.explanation h3 {
  font-size: 14px;
  margin-bottom: 12px;
}
.explanation div {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 2;
  overflow-wrap: anywhere;
}
.revision {
  color: #86692b;
  background: #f1e8cd;
  font-size: 11px;
  padding: 10px 12px;
  border-radius: 5px;
  margin: 16px 0;
}
.revision summary {
  cursor: pointer;
}
.revision p {
  margin-top: 10px;
}
rt {
  font-size: 0.55em;
}
.passage {
  margin: 20px 0;
  padding: 22px;
  border-left: 2px solid var(--line);
  background: var(--page);
}
.passage h3 {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 14px;
}
.passage [lang="ja"] {
  white-space: pre-wrap;
  line-height: 2.2;
  font-size: 16px;
  overflow-wrap: anywhere;
}
.current-blank {
  white-space: nowrap;
  background: #efd58e;
  color: #38433c;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-weight: 600;
}
.passage-blank {
  white-space: nowrap;
  border-bottom: 1px solid var(--muted);
  font-weight: 600;
}
.cloze-question {
  padding: 24px 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 24px;
}
.cloze-question h3 {
  font-size: 13px;
  margin-bottom: 14px;
}
.cloze-question .stem {
  font-size: 16px;
  margin-bottom: 14px;
}
.summary {
  padding: 42px 24px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.summary h1 {
  font: 30px/1.5 var(--serif);
}
.summary p {
  margin: 12px 0;
}
.score {
  color: var(--ink);
  font:
    64px/1.5 Georgia,
    serif;
  margin: 18px 0;
}
.score span {
  color: var(--muted);
  font-size: 25px;
}
.review {
  margin-top: 32px;
}
.review-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  text-align: left;
}
.review-row small {
  color: var(--muted);
  margin-left: 12px;
}
.green {
  color: #356448;
}
.red {
  color: #9e4637;
}
.empty,
.loading {
  padding: 40px 10px;
  color: var(--muted);
  text-align: center;
}
#notice:not(:empty) {
  position: fixed;
  z-index: 30;
  bottom: 16px;
  left: 5%;
  right: 5%;
  background: var(--card);
  border: 1px solid var(--accent);
  padding: 14px;
  border-radius: 6px;
}
dialog {
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  max-width: min(440px, calc(100vw - 32px));
}
dialog p {
  margin: 16px 0 22px;
}
dialog::backdrop {
  background: #14293288;
}
html[data-theme="dark"] {
  --page: #18262c;
  --card: #213139;
  --ink: #d4e1e4;
  --muted: #9baeb3;
  --line: #394b53;
  --soft: #344650;
  --hover: #293c45;
  --accent: #d5a183;
  --green: #d4e1e4;
  color-scheme: dark;
}
html[data-theme="dark"] :is(.option.right, .question-grid .correct, .good) {
  background: #284438;
  color: #c4e6cd;
}
html[data-theme="dark"] :is(.option.incorrect, .question-grid .wrong, .bad) {
  background: #49322d;
  color: #efc5b8;
}
html[data-theme="dark"] :is(.revision, .question-grid .draft) {
  background: #433e2d;
  color: #e6d5a5;
}
html[data-theme="dark"] .green {
  color: #acd7b5;
}
html[data-theme="dark"] .red {
  color: #efb7ac;
}
@media (max-width: 950px) {
  .library-layout {
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 28px;
  }
  .level-tabs button {
    padding: 16px;
    gap: 10px;
  }
  .level-tabs small {
    display: none;
  }
  .paper-detail {
    max-width: 180px;
    line-height: 1.9;
  }
  .library-heading {
    align-items: start;
    flex-direction: column;
    gap: 14px;
  }
  .workbench {
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 24px;
  }
  .question-card {
    padding: 26px;
  }
}
@media (max-width: 650px) {
  .topbar {
    height: 60px;
    padding: 0 18px;
    gap: 14px;
  }
  .brand {
    font-size: 20px;
    gap: 7px;
  }
  .brand img {
    width: 28px;
    height: 28px;
  }
  .brand span {
    display: none;
  }
  .topbar-actions {
    gap: 15px;
    font-size: 11px;
  }
  main {
    padding: 0 20px 40px;
  }
  .grammar-intro {
    padding: 32px 0 26px;
    gap: 0;
  }
  .grammar-intro h1 {
    font-size: 32px;
  }
  .grammar-intro p {
    font-size: 12px;
    max-width: 260px;
  }
  .intro-types {
    display: none;
  }
  .level-tabs button {
    padding: 14px 10px;
    display: block;
  }
  .level-tabs strong {
    font-size: 25px;
  }
  .level-tabs span {
    display: block;
    margin-top: 6px;
    font-size: 11px;
  }
  .library-layout {
    display: flex;
    flex-direction: column;
    padding-top: 25px;
    gap: 28px;
  }
  .study-guide {
    order: 2;
    border-top: 1px solid var(--line);
    padding-top: 24px;
  }
  .study-guide ol {
    display: none;
  }
  .study-progress {
    border: 0;
    padding-top: 10px;
  }
  .study-progress strong {
    font-size: 20px;
  }
  .library-heading {
    gap: 14px;
  }
  .library-heading h2 {
    font-size: 16px;
  }
  .library-heading p {
    font-size: 10px;
  }
  .paper {
    grid-template-columns: 70px minmax(0, 1fr) 85px;
    gap: 8px;
    padding: 16px 2px;
  }
  .paper-detail {
    font-size: 10px;
  }
  .paper-date {
    font-size: 14px;
  }
  .paper-action b {
    font-size: 11px;
  }
  .practice-view,
  .results-view {
    padding-top: 20px;
  }
  .exercise-heading {
    gap: 8px;
    margin-bottom: 20px;
    font-size: 11px;
  }
  .exercise-heading button {
    padding: 8px;
    font-size: 11px;
  }
  .workbench {
    display: block;
  }
  .workbench > aside {
    position: static;
    padding: 0 0 18px;
  }
  .workbench .section-title {
    margin-bottom: 8px;
  }
  .question-grid {
    display: flex;
    overflow-x: auto;
    padding: 2px 1px 8px;
    margin: 12px 0 0;
    gap: 6px;
  }
  .question-grid button {
    flex: 0 0 30px;
    padding: 6px 0;
  }
  .legend,
  aside #reset {
    display: none;
  }
  .question-card {
    padding: 22px 18px;
  }
  .question-meta {
    font-size: 10px;
  }
  .stem {
    font-size: 19px;
  }
  .option-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .option {
    padding: 12px 10px;
    font-size: 13px;
  }
  .question-actions {
    gap: 8px;
  }
  .question-actions button {
    font-size: 12px;
    padding: 9px 12px;
  }
  .passage {
    padding: 16px;
  }
  .passage [lang="ja"] {
    font-size: 15px;
  }
  .review-row small {
    display: block;
    margin: 4px 0 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

.practice-modes {
  display: flex;
  gap: 28px;
  border-bottom: 1px solid var(--line);
  margin: 0 0 24px;
}
.practice-modes button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 12px 0;
  font-size: 14px;
  color: var(--muted);
}
.practice-modes button[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 600;
}
.random-form {
  padding: 12px 0 36px;
}
.random-heading {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.random-heading h2 {
  font-size: 19px;
}
.random-heading p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}
#resume-random {
  font-size: 12px;
  background: transparent;
}
.random-levels {
  padding: 0;
  border: 0;
  margin: 0 0 36px;
  display: flex;
  gap: 26px;
}
.random-levels legend {
  margin-bottom: 14px;
  font-size: 13px;
}
.random-levels legend span {
  color: var(--muted);
  font-size: 11px;
  margin-left: 10px;
}
.random-levels label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.random-levels input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.random-types {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0;
}
.random-types button {
  padding: 12px 20px;
  border: 1px solid var(--line);
}
.random-types button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--page);
  border-color: var(--ink);
}
.random-quantity {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 0;
  border-block: 1px solid var(--line);
}
.random-quantity small {
  color: var(--muted);
}
.number-field {
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.number-field input {
  width: 105px;
  max-width: 100%;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 5px;
  font:
    24px/1.4 Georgia,
    serif;
}
.number-field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.number-field span {
  font-size: 12px;
  color: var(--muted);
}
.random-count small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 12px;
}
.random-start {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: center;
  padding-top: 28px;
}
.random-start strong {
  font-size: 19px;
  font-weight: 550;
}
.random-start p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}
.random-start button {
  min-height: 48px;
  padding-inline: 26px;
}
.random-note {
  margin-top: 24px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.9;
}
#random-error:not(:empty) {
  margin-top: 18px;
  color: var(--accent);
  font-size: 13px;
}
@media (max-width: 650px) {
  .practice-modes {
    gap: 24px;
    margin-bottom: 22px;
  }
  .practice-modes button {
    font-size: 13px;
  }
  .random-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .random-types {
    gap: 8px;
  }
  .random-types button {
    flex: 1;
    padding: 12px 7px;
    font-size: 12px;
  }
  .random-quantity {
    gap: 14px;
    flex-wrap: wrap;
  }
  .number-field input {
    width: 80px;
  }
  .random-start {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }
  .random-start p {
    font-size: 11px;
  }
}
