/* ウカルラボ — マークシートと赤ペンをモチーフにしたスタイル */

:root {
  --paper: #ffffff;
  --sheet: #f3f8f5;          /* 答案用紙の地色 */
  --sheet-line: #9ccbb2;     /* マークシートのドロップアウトカラー */
  --sheet-line-soft: #d9ece1;
  --sheet-ink: #3d8762;      /* 枠内の数字・ラベル */
  --graphite: #22252a;       /* 鉛筆の黒・本文 */
  --muted: #5b626b;
  --red: #d1253a;            /* 赤ペン */
  --red-soft: #fdecee;
  --focus: #1d6fd6;

  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
  --font-pen: "Klee One", "Hiragino Mincho ProN", "Yu Mincho", serif;

  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--graphite);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  font-feature-settings: "palt" 0;
}

img, svg { max-width: 100%; }

a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--red); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.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;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--graphite); color: #fff; padding: 8px 12px;
}
.skip:focus { left: 8px; top: 8px; z-index: 10; }

h1, h2, h3 { line-height: 1.35; margin: 0; letter-spacing: 0.01em; }
h1 { font-weight: 900; }
h2 { font-weight: 900; font-size: clamp(1.5rem, 3.4vw, 2rem); }
h3 { font-weight: 700; font-size: 1.125rem; }
p { margin: 0 0 1em; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 22px;
  border: 2px solid var(--graphite);
  border-radius: 999px;
  background: var(--graphite);
  color: #fff;
  font: inherit; font-weight: 700; font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #000; color: #fff; }
.btn-ghost { background: transparent; color: var(--graphite); }
.btn-ghost:hover { background: var(--sheet); color: var(--graphite); }
.btn[disabled], .btn[aria-disabled="true"] {
  background: #e6e8ea; border-color: #e6e8ea; color: #7a8088; cursor: not-allowed;
}

/* ---------- ヘッダー ---------- */
.site-header { border-bottom: 1px solid var(--sheet-line-soft); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 64px;
}
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  white-space: nowrap; flex-shrink: 0;
  font-weight: 900; font-size: 1.2rem; text-decoration: none;
}
.logo-mark {
  width: 18px; height: 24px; border-radius: 50%;
  background: var(--graphite);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--sheet-line);
}
.site-nav { display: flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.site-nav a {
  padding: 6px 12px; border-radius: 999px;
  font-weight: 500; font-size: 0.95rem; text-decoration: none;
}
.site-nav a[aria-current="page"] { background: var(--sheet); color: var(--sheet-ink); }

/* ---------- ヒーロー ---------- */
.hero { padding: clamp(32px, 7vw, 88px) 0 clamp(24px, 4vw, 48px); }
.hero .wrap {
  display: grid; gap: clamp(28px, 5vw, 64px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  align-items: center;
}
.hero h1 {
  font-size: clamp(2.05rem, 5vw, 3.6rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
/* 日本語の見出しを語の途中で折り返さないためのかたまり */
.nb { display: inline-block; white-space: nowrap; }
.hero-lead { margin-top: 20px; color: var(--muted); max-width: 30em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hero-note { margin-top: 18px; font-size: 0.875rem; color: var(--muted); }

/* ---------- 答案用紙カード ---------- */
.sheet {
  position: relative;
  background: var(--sheet);
  border: 1.5px solid var(--sheet-line);
  border-radius: 6px;
  padding: clamp(18px, 3vw, 28px);
}
/* 左端のタイミングマーク（マークシートの黒い目印） */
.sheet::before {
  content: "";
  position: absolute; left: -1.5px; top: 22px; bottom: 22px; width: 6px;
  background: repeating-linear-gradient(to bottom, var(--graphite) 0 10px, transparent 10px 26px);
}
.sheet-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--sheet-line);
  padding-bottom: 10px; margin-bottom: 16px;
}
.sheet-title { font-weight: 700; color: var(--sheet-ink); }
.tag {
  display: inline-block;
  border: 1px solid var(--sheet-line); border-radius: 4px;
  padding: 0 8px; font-size: 0.8rem; color: var(--sheet-ink); background: var(--paper);
  white-space: nowrap;
}
.q-text { font-size: 1.08rem; line-height: 1.75; margin-bottom: 16px; }
.blank {
  display: inline-block; width: 4.2em; height: 1.1em;
  border-bottom: 2px solid var(--graphite);
  vertical-align: -0.1em; margin: 0 0.25em;
}

/* ---------- 選択肢（マーク） ---------- */
.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.choice {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--sheet-line-soft);
  border-radius: 6px;
  font: inherit; color: var(--graphite); text-align: left;
  cursor: pointer;
}
.choice:hover:not([disabled]) { border-color: var(--sheet-line); }
.choice[disabled] { cursor: default; }
.bubble {
  position: relative; flex: none;
  width: 22px; height: 30px;
  border: 1.5px solid var(--sheet-line);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 700; color: var(--sheet-ink);
  background: var(--paper);
}
/* 鉛筆で塗りつぶした状態 */
.choice[aria-pressed="true"] .bubble {
  border-color: var(--graphite);
  color: transparent;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.18), transparent 45%),
    var(--graphite);
}
.choice-text { flex: 1; line-height: 1.5; }

/* 赤ペンの丸（正解の選択肢を囲む） */
.pen-circle {
  position: absolute; left: 1px; top: 50%;
  width: 44px; height: 50px; transform: translateY(-50%);
  pointer-events: none; overflow: visible;
}
.pen-circle path {
  fill: none; stroke: var(--red); stroke-width: 2.6; stroke-linecap: round;
  stroke-dasharray: 160; stroke-dashoffset: 160;
  animation: pen-draw 0.45s ease-out forwards;
}
.pen-cross {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; pointer-events: none;
}
.pen-cross path {
  fill: none; stroke: var(--red); stroke-width: 2.6; stroke-linecap: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: pen-draw 0.3s ease-out forwards;
}
.pen-cross path + path { animation-delay: 0.15s; }
@keyframes pen-draw { to { stroke-dashoffset: 0; } }

/* ---------- 赤ペンのフィードバック ---------- */
.feedback { margin-top: 16px; }
.feedback[hidden] { display: none; }
.pen-note {
  font-family: var(--font-pen); font-weight: 600;
  color: var(--red); font-size: 1.35rem; line-height: 1.4;
  margin-bottom: 6px;
}
.explain {
  border-left: 3px solid var(--red);
  padding: 2px 0 2px 14px;
  font-size: 0.95rem; line-height: 1.75;
}
.feedback-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- セクション共通 ---------- */
.section { padding: clamp(40px, 6vw, 72px) 0; }
.section + .section { border-top: 1px solid var(--sheet-line-soft); }
.section-head { max-width: 40em; margin-bottom: clamp(24px, 4vw, 40px); }
.section-head p { margin-top: 10px; color: var(--muted); }

/* ---------- 試験一覧（解答欄の罫線風） ---------- */
.exam-table { border-top: 2px solid var(--graphite); }
.exam-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) auto auto;
  gap: 8px 24px; align-items: center;
  padding: 16px 4px;
  border-bottom: 1px solid var(--sheet-line);
}
.exam-name { font-weight: 700; font-size: 1.08rem; }
.exam-scope { color: var(--muted); font-size: 0.95rem; }
.exam-count { font-size: 0.9rem; color: var(--sheet-ink); white-space: nowrap; }
.exam-row .btn { min-height: 40px; padding: 6px 18px; font-size: 0.95rem; }

/* ---------- できること ---------- */
.features {
  display: grid; gap: 28px 40px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 920px;
}
.feature h3 { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.feature h3::before {
  content: ""; flex: none;
  width: 12px; height: 16px; border-radius: 50%;
  background: var(--graphite);
}
.feature p { color: var(--muted); font-size: 0.97rem; margin: 0; }

/* ---------- 料金 ---------- */
.plans {
  display: grid; gap: 20px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}
.plan {
  display: flex; flex-direction: column;
  padding: 24px;
  border: 1px solid var(--sheet-line);
  border-radius: 6px;
  background: var(--paper);
}
.plan-free { background: var(--sheet); border-color: transparent; }
.plan-main { border: 2.5px solid var(--graphite); position: relative; }
.plan-name { font-weight: 700; }
.plan-price { font-size: 2rem; font-weight: 900; line-height: 1.2; margin: 10px 0 2px; }
.plan-price small { font-size: 0.9rem; font-weight: 500; color: var(--muted); }
.plan-sub { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; }
.plan ul { margin: 0 0 20px; padding-left: 1.2em; font-size: 0.95rem; }
.plan li { margin-bottom: 4px; }
.plan .btn { margin-top: auto; width: 100%; }
.plan-flag {
  position: absolute; top: -18px; right: 16px;
  font-family: var(--font-pen); font-weight: 600; color: var(--red);
  background: var(--paper); padding: 0 8px; font-size: 1.1rem;
  transform: rotate(-4deg);
}
.plans-note { margin-top: 16px; font-size: 0.85rem; color: var(--muted); }
.checkout-msg { margin-top: 8px; font-size: 0.85rem; color: var(--red); min-height: 1.2em; }

/* ---------- FAQ ---------- */
.faq { max-width: 780px; border-top: 2px solid var(--graphite); }
.faq details { border-bottom: 1px solid var(--sheet-line); }
.faq summary {
  cursor: pointer; list-style: none;
  padding: 16px 32px 16px 4px; position: relative; font-weight: 700;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 8px; top: 14px;
  font-weight: 500; font-size: 1.3rem; color: var(--sheet-ink);
}
.faq details[open] summary::after { content: "−"; }
.faq details p { padding: 0 4px 16px; margin: 0; color: var(--muted); }

/* ---------- フッター ---------- */
.site-footer {
  background: var(--sheet);
  border-top: 1.5px solid var(--sheet-line);
  padding: 40px 0 48px;
  font-size: 0.85rem; color: var(--muted);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 20px; }
.footer-links a { color: var(--graphite); }
.disclaimer { max-width: 60em; line-height: 1.7; }
.disclaimer p { margin: 0 0 6px; }

/* ---------- 練習ページ ---------- */
.page-head { padding: clamp(28px, 5vw, 56px) 0 8px; }
.page-head h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); }
.page-head p { margin-top: 10px; color: var(--muted); max-width: 36em; }

.setup { display: grid; gap: 28px; max-width: 760px; padding-bottom: 64px; }
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset legend { font-weight: 700; margin-bottom: 10px; padding: 0; }
.option-list { display: grid; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; min-height: 56px;
  border: 1px solid var(--sheet-line-soft); border-radius: 6px;
  cursor: pointer; background: var(--paper);
}
.option:hover { border-color: var(--sheet-line); }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option .bubble { width: 18px; height: 24px; }
.option input:checked + .bubble { background: var(--graphite); border-color: var(--graphite); }
.option input:focus-visible + .bubble { outline: 3px solid var(--focus); outline-offset: 3px; }
.option-body { display: flex; flex-direction: column; line-height: 1.5; }
.option-body small { color: var(--muted); }
.option:has(input:checked) { border-color: var(--graphite); background: var(--sheet); }

.history {
  background: var(--sheet); border-radius: 6px; padding: 16px 18px;
  font-size: 0.95rem;
}
.history h2 { font-size: 1.05rem; margin-bottom: 8px; }
.history[hidden] { display: none; }

.quiz { max-width: 760px; padding-bottom: 64px; }
.quiz[hidden], .result[hidden], .setup[hidden] { display: none; }
.quiz-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; font-size: 0.95rem;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.is-low { color: var(--red); }
.progress { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.progress span {
  width: 12px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--sheet-line); background: var(--paper);
}
.progress span.is-current { border-color: var(--graphite); }
.progress span.is-answered { background: var(--graphite); border-color: var(--graphite); }
.progress span.is-wrong { background: var(--red); border-color: var(--red); }

.passage {
  background: var(--paper);
  border: 1px solid var(--sheet-line);
  border-radius: 6px;
  padding: 16px 18px; margin-bottom: 16px;
  font-size: 0.95rem; line-height: 1.7;
}
.passage p:last-child { margin-bottom: 0; }
.passage .mail-head { font-weight: 700; }
.passage-label { font-size: 0.8rem; color: var(--sheet-ink); margin-bottom: 6px; display: block; }

.quiz-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 18px; }

/* ---------- 結果 ---------- */
.result { max-width: 760px; padding-bottom: 72px; }
.score {
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  margin: 8px 0 28px;
}
.score-pen {
  font-family: var(--font-pen); font-weight: 600; color: var(--red);
  font-size: clamp(3.4rem, 12vw, 5.5rem); line-height: 1;
  padding-bottom: 6px;
  border-bottom: 3px double var(--red);
  transform: rotate(-3deg);
}
.score-meta { color: var(--muted); padding-bottom: 8px; }
.breakdown { border-top: 2px solid var(--graphite); margin-bottom: 32px; }
.breakdown-row {
  display: grid; grid-template-columns: 6em minmax(0, 1fr) 4.5em;
  gap: 14px; align-items: center;
  padding: 10px 2px; border-bottom: 1px solid var(--sheet-line);
  font-size: 0.95rem;
}
.bar { height: 10px; background: var(--sheet-line-soft); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--graphite); border-radius: 999px; }
.bar.is-weak i { background: var(--red); }
.breakdown-num { text-align: right; font-variant-numeric: tabular-nums; }

.review { display: grid; gap: 12px; margin-bottom: 28px; }
.review details {
  border: 1px solid var(--sheet-line-soft); border-radius: 6px; padding: 0 14px;
}
.review summary {
  cursor: pointer; padding: 12px 0; display: flex; gap: 10px; align-items: baseline;
}
.review .mark { font-family: var(--font-pen); font-weight: 600; color: var(--red); min-width: 1.4em; }
.review .mark.is-ok { color: var(--sheet-ink); }
.review-body { padding-bottom: 14px; font-size: 0.95rem; }
.review-body .answers { margin: 8px 0; }

/* ---------- ライティング ---------- */
.writing { max-width: 820px; padding-bottom: 72px; }
.prompt-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.prompt-tabs button {
  font: inherit; font-size: 0.92rem; cursor: pointer;
  border: 1px solid var(--sheet-line); background: var(--paper);
  border-radius: 999px; padding: 6px 14px; color: var(--graphite);
}
.prompt-tabs button[aria-selected="true"] { background: var(--graphite); color: #fff; border-color: var(--graphite); }
.prompt-topic { font-size: 1.05rem; line-height: 1.7; margin-bottom: 10px; }
.points { font-size: 0.95rem; color: var(--muted); margin: 0; }
.points b { color: var(--graphite); }

.answer-box { margin-top: 20px; }
.answer-box label { font-weight: 700; display: block; margin-bottom: 8px; }
textarea {
  width: 100%; min-height: 240px; resize: vertical;
  font: inherit; font-size: 1rem; line-height: 2;
  padding: 10px 14px;
  border: 1.5px solid var(--sheet-line); border-radius: 6px;
  color: var(--graphite);
  background:
    repeating-linear-gradient(to bottom, transparent 0 calc(2em - 1px), var(--sheet-line-soft) calc(2em - 1px) 2em)
    0 10px / 100% 2em local,
    var(--paper);
}
.count-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 10px; font-size: 0.95rem;
}
.count strong { font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.count.is-out strong { color: var(--red); }
.count.is-in strong { color: var(--sheet-ink); }

.checks { list-style: none; padding: 0; margin: 20px 0 0; border-top: 2px solid var(--graphite); }
.checks li {
  display: grid; grid-template-columns: 2em minmax(0, 1fr); gap: 8px;
  padding: 12px 2px; border-bottom: 1px solid var(--sheet-line);
}
.checks .mark { font-family: var(--font-pen); font-weight: 600; font-size: 1.3rem; color: var(--red); line-height: 1.3; }
.checks .mark.is-ok { color: var(--sheet-ink); }
.checks small { display: block; color: var(--muted); }
.model { margin-top: 24px; }
.model summary { cursor: pointer; font-weight: 700; }
.model p { margin-top: 10px; background: var(--sheet); padding: 14px 16px; border-radius: 6px; }

/* ---------- 規約ページ ---------- */
.legal { max-width: 820px; padding-bottom: 72px; }
.legal .notice {
  background: var(--red-soft); color: #8f1424;
  border-radius: 6px; padding: 12px 16px; font-size: 0.95rem; margin: 16px 0 24px;
}
.legal table { width: 100%; border-collapse: collapse; border-top: 2px solid var(--graphite); }
.legal th, .legal td {
  text-align: left; vertical-align: top;
  padding: 12px 8px; border-bottom: 1px solid var(--sheet-line); font-size: 0.95rem;
}
.legal th { width: 32%; font-weight: 700; }
.legal h2 { font-size: 1.2rem; margin: 28px 0 8px; }
.todo { color: var(--red); font-weight: 700; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 860px) {
  .hero .wrap { grid-template-columns: minmax(0, 1fr); }
  .plans { grid-template-columns: minmax(0, 1fr); max-width: 480px; }
  .plan-main { order: -1; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .exam-row { grid-template-columns: minmax(0, 1fr) auto; }
  .exam-scope { grid-column: 1 / -1; grid-row: 2; }
  .exam-count { grid-column: 1; grid-row: 3; }
  .exam-row .btn { grid-column: 2; grid-row: 1 / span 3; }
  .features { grid-template-columns: minmax(0, 1fr); }
  .site-header .wrap { gap: 8px; }
  .site-nav { gap: 0; }
  .site-nav a { padding: 6px 7px; font-size: 0.85rem; }
  .logo { font-size: 1.02rem; gap: 8px; }
  .legal th { width: 38%; }
}

@media (prefers-reduced-motion: reduce) {
  .pen-circle path, .pen-cross path { animation: none; stroke-dashoffset: 0; }
}
