/* hirei.css — 比例式の計算機。すべて .iq 配下にスコープ（サイトのCSSと干渉しない）。
   デザインはsimeq/eqn/bunsu/insuと同じ「方眼ノートに青インク・答えは赤」の系統で計算機ファミリーの統一感を保つ。
   ダークは .iq[data-iq-theme="dark"] で切替（サイト本番は常にライト）。 */
.iq {
  --iq-paper: #ffffff;
  --iq-ground: #f3f6fc;
  --iq-ink: #1a2657;
  --iq-sub: #55618a;
  --iq-line: #d3daee;
  --iq-grid: rgba(70, 100, 190, .10);
  --iq-accent: #2f52c4;
  --iq-accent-ink: #ffffff;
  --iq-red: #d23c50;
  --iq-warn-bg: #fff3ef;
  --iq-warn: #a63a26;
  --iq-key: #eef2fb;
  --iq-font: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", Meiryo, sans-serif;
  --iq-math: "Hiragino Mincho ProN", "BIZ UDPMincho", "Yu Mincho", "Noto Serif JP", "Times New Roman", serif;
  box-sizing: border-box;
  max-width: 680px;
  margin: 0 auto;
  color: var(--iq-ink);
  font-family: var(--iq-font);
  font-size: 16px;
  line-height: 1.7;
  text-align: left;
}
.iq[data-iq-theme="dark"] {
  --iq-paper: #182036;
  --iq-ground: #0f1526;
  --iq-ink: #e4e9fb;
  --iq-sub: #a2aed3;
  --iq-line: #303c66;
  --iq-grid: rgba(140, 165, 245, .09);
  --iq-accent: #8fa8ff;
  --iq-accent-ink: #0f1526;
  --iq-red: #ff7d8e;
  --iq-warn-bg: #3a2320;
  --iq-warn: #ffb4a3;
  --iq-key: #222c4a;
}
.iq *, .iq *::before, .iq *::after { box-sizing: border-box; }
:where(.iq button) { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
.iq :focus-visible { outline: 3px solid var(--iq-accent); outline-offset: 2px; }

.iq-card { background: var(--iq-paper); border: 1px solid var(--iq-line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.iq-grid {
  background-image:
    linear-gradient(var(--iq-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--iq-grid) 1px, transparent 1px);
  background-size: 22px 22px;
  background-color: var(--iq-paper);
}
.iq-h { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--iq-sub); letter-spacing: .04em; }
.iq-h-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.iq-h-row .iq-h { margin: 0; }

/* ---- 入力 ---- */
.iq-input {
  width: 100%; height: 52px; padding: 0 14px; border: 2px solid var(--iq-line); border-radius: 10px;
  background: var(--iq-paper); color: var(--iq-ink); font-family: var(--iq-math); font-size: 24px;
  letter-spacing: .04em; margin-bottom: 10px;
}
.iq-quickkeys { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.iq-key { min-width: 40px; height: 36px; padding: 0 12px; border-radius: 8px; background: var(--iq-key); font-size: 14px; color: var(--iq-sub); }
.iq-key:hover { background: var(--iq-line); }

.iq-examples { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.iq-chip { padding: 6px 12px; border-radius: 999px; background: var(--iq-key); color: var(--iq-sub); font-size: 13px; border: 1px solid var(--iq-line); }
.iq-chip:hover { background: var(--iq-line); }

.iq-error { background: var(--iq-warn-bg); color: var(--iq-warn); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.iq-solve {
  display: block; width: 100%; height: 52px; border-radius: 14px; background: var(--iq-accent);
  color: var(--iq-accent-ink); font-size: 20px; font-weight: 700; letter-spacing: .05em;
}
.iq-solve:active { transform: translateY(1px); }

/* ---- 答え ---- */
.iq-answer-card { text-align: center; }
.iq-answer-badge { font-family: var(--iq-math); font-size: 30px; font-weight: 700; color: var(--iq-red); min-height: 44px; word-break: break-word; }
.iq-answer-sub { margin-top: 8px; font-size: 14px; color: var(--iq-sub); word-break: break-word; }

/* ---- とき方 ---- */
.iq-hint-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--iq-sub); }
.iq-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.iq-step { border: 1px solid var(--iq-line); border-radius: 10px; overflow: hidden; }
.iq-step-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--iq-ground); cursor: pointer; }
.iq-step-badge { flex: none; padding: 2px 10px; border-radius: 999px; background: var(--iq-accent); color: var(--iq-accent-ink); font-size: 12px; font-weight: 700; }
.iq-step-title { font-weight: 700; font-size: 14px; }
.iq-step-body { padding: 10px 14px 14px; }
.iq-step-note { font-size: 13px; color: var(--iq-sub); margin-bottom: 6px; }
.iq-step-line { font-family: var(--iq-math); font-size: 17px; margin-bottom: 4px; word-break: break-word; }

/* ---- 注意（答えは出るが、比としては不自然なとき） ---- */
.iq-answer-warn { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: var(--iq-warn-bg); color: var(--iq-warn); font-size: 13px; text-align: left; }
.iq-error a { color: inherit; font-weight: 700; text-decoration: underline; }

/* ---- 共有 ---- */
.iq-share-card { display: flex; align-items: center; gap: 10px; }
.iq-copylink { padding: 8px 14px; border-radius: 10px; background: var(--iq-key); color: var(--iq-sub); font-size: 13px; border: 1px solid var(--iq-line); }
.iq-copymsg { font-size: 13px; color: var(--iq-accent); }

@media (max-width: 420px) {
  .iq-input { font-size: 20px; }
  .iq-answer-badge { font-size: 24px; }
}

/* ---- 数式（分数・根号・べき） ---- */
.iq i { font-family: var(--iq-math); font-style: italic; font-weight: 500; }
.iq sup { font-size: .68em; line-height: 0; vertical-align: super; }
.iq-fr { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .12em; line-height: 1.05; font-size: .92em; }
.iq-fr > span:first-child { padding: 0 .18em .04em; border-bottom: 1.5px solid currentColor; }
.iq-fr > span:last-child { padding: .04em .18em 0; }
.iq-rt { white-space: nowrap; }
.iq-rti { border-top: 1.6px solid currentColor; padding: 0 .1em; margin-left: .02em; }

/* ---- 数直線 ---- */
.iq-linebox { margin-top: 14px; }
.iq-nl { display: block; width: 100%; height: auto; max-width: 460px; margin: 0 auto; }
.iq-linecap { margin-top: 4px; font-size: 12px; color: var(--iq-sub); text-align: center; }

/* ---- 連立の番号つきとき方 ---- */
.iq-step-group { flex: none; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%; border: 2px solid var(--iq-accent); color: var(--iq-accent); font-size: 14px; font-weight: 700; }
.iq-step-line { overflow-x: auto; }

.iq-piece { display: inline-block; white-space: nowrap; }
.iq-or { font-family: var(--iq-font); font-size: .6em; font-weight: 500; color: var(--iq-sub); margin: 0 .3em; }

.iq-answer-badge { overflow-x: auto; overflow-y: hidden; }
.iq-answer-sub { overflow-wrap: anywhere; }
