/* ===== 一問一答メーカー スタイル ===== */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #5f6b7a;
  --border: #d9dee5;
  --primary: #2b5fd9;
  --primary-dark: #1f4ab0;
  --warn-bg: #fff7e0;
  --warn-border: #e6b422;
  --error-bg: #fdecec;
  --error-text: #b42318;
  --ok: #1a7f37;
  --ok-bg: #e7f5ec;
  --ng: #b42318;
  --ng-bg: #fdecec;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

/* 1カラム・最大幅800px */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

h1, h2, h3 { line-height: 1.3; }

/* ヘッダー */
.app-header { padding: 12px 0 4px; }
.app-header h1 { margin: 0 0 4px; font-size: 1.8rem; color: var(--primary-dark); }
.lead { margin: 0; color: var(--muted); }

/* 注意書きボックス */
.notice {
  background: var(--warn-bg);
  border: 2px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 16px 0;
}
.notice h2 { font-size: 1rem; margin: 0 0 6px; }
.notice ul { margin: 0; padding-left: 1.2em; }
.notice li { margin: 2px 0; font-weight: 600; }

/* カード */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { font-size: 1.2rem; margin: 0 0 8px; }
.desc { margin: 0 0 12px; color: var(--muted); font-size: 0.95rem; }

/* フォーム要素 */
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 4px; }

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* iOSでのズーム防止 */
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
textarea { resize: vertical; min-height: 4em; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}
.input-select { max-width: 160px; }

.provider-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px 10px;
  margin: 0 0 14px;
}
.provider-group legend { font-weight: 600; padding: 0 4px; }
.radio { display: inline-flex; align-items: center; gap: 6px; margin: 4px 16px 4px 0; cursor: pointer; }

.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; min-width: 0; }

.hint { margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); }
.counter { margin: 4px 0 0; font-size: 0.9rem; color: var(--muted); text-align: right; }
.req {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  background: #fde2e1;
  color: var(--error-text);
}

/* ボタン */
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
button { font: inherit; cursor: pointer; }
.btn-main {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-weight: 600;
  min-height: 44px;
}
.btn-main:hover:not(:disabled) { background: var(--primary-dark); }
.btn-main:disabled { background: #9aa9c7; cursor: not-allowed; }
.btn-sub {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.9rem;
  min-height: 40px;
}
.btn-sub:hover:not(:disabled) { background: #eef3ff; }
.btn-sub:disabled { color: #9aa9c7; border-color: #c5cfe3; cursor: not-allowed; }
.btn-sub.danger { color: var(--error-text); border-color: #e8a29c; }
.btn-sub.danger:hover { background: var(--error-bg); }
.btn-link {
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--muted);
  text-decoration: underline;
  font-size: 0.9rem;
}

.status-message { color: var(--ok); font-weight: 600; margin: 8px 0 0; min-height: 1.7em; }
.status-message.error { color: var(--error-text); }

/* エラー表示 */
.error-box {
  margin: 16px 0 0;
  padding: 12px;
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid #f3b8b3;
  border-radius: 8px;
  white-space: pre-wrap; /* 改行はCSSで表示（innerHTMLは使わない） */
  word-break: break-word;
}

/* 生成結果 */
.result {
  margin-top: 16px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.result h3 { font-size: 1.05rem; margin: 0 0 8px; }
.qa-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
}
.qa-item { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.qa-item:last-child { border-bottom: none; }
.qa-q, .qa-a { margin: 0; white-space: pre-wrap; word-break: break-word; }
.qa-q { font-weight: 600; }
.qa-a { color: #344150; }
.qa-label { display: inline-block; min-width: 3em; font-weight: 700; color: var(--primary-dark); }
.qa-a .qa-label { color: var(--ok); }

.result-actions { margin-top: 14px; }
.save-row { margin-bottom: 12px; }

/* 学習エリア */
.progress {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 8px 12px;
  background: #eef3ff;
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.progress-item strong { font-size: 1.05rem; }
#progress-pos { font-weight: 700; color: var(--primary-dark); }

.study-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
}
.study-label { margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.study-question {
  margin: 4px 0 16px;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.study-answer-box {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-bottom: 16px;
}
.study-answer {
  margin: 4px 0 0;
  font-size: 1.1rem;
  color: var(--ok);
  font-weight: 600;
  white-space: pre-wrap;
  word-break: break-word;
}
.study-actions { display: flex; justify-content: center; }
.study-actions .btn-main { min-width: 200px; }
.judge-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.btn-judge {
  min-height: 52px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  border: 2px solid;
}
.btn-judge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.btn-judge.ok:hover { background: #d3eddc; }
.btn-judge.ng { background: var(--ng-bg); color: var(--ng); border-color: var(--ng); }
.btn-judge.ng:hover { background: #f9d6d3; }

.study-summary { text-align: center; padding: 8px 0; }
.study-summary h3 { font-size: 1.2rem; margin: 8px 0; }
.summary-text { font-size: 1.05rem; font-weight: 600; white-space: pre-wrap; }
.study-summary .actions { justify-content: center; }
.study-footer { margin-top: 12px; text-align: right; }

/* 保存済みセット */
.sets-list { list-style: none; margin: 0; padding: 0; }
.set-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.set-item:last-child { border-bottom: none; }
.set-info { min-width: 0; }
.set-name { margin: 0; font-weight: 600; word-break: break-word; }
.set-meta { margin: 0; font-size: 0.85rem; color: var(--muted); }
.set-buttons { display: flex; gap: 8px; flex-shrink: 0; }

.app-footer { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 8px 0 24px; }

[hidden] { display: none !important; }

/* スマートフォン */
@media (max-width: 520px) {
  .container { padding: 12px; }
  .app-header h1 { font-size: 1.5rem; }
  .card { padding: 12px; }
  .btn-main { width: 100%; }
  .radio { display: flex; margin-right: 0; }
  .study-question { font-size: 1.2rem; }
  .study-actions .btn-main { min-width: 0; }
  .set-item { flex-direction: column; align-items: stretch; }
  .set-buttons .btn-sub { flex: 1; }
}


/* 有料版導線バナー（無料Web版の追加要素） */
.paid-banner {
  max-width: 800px;
  margin: 16px auto 0;
  padding: 10px 14px;
  background: #eef4ff;
  border: 1px solid #b9cdf5;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
}
.paid-banner p { margin: 0; }
.paid-banner a { color: #1a56db; font-weight: 600; }
