/* ==========================================================
 * 未習漢字チェッカー（apps/kan・apps/name）共通の見た目
 * kan と name は「いとこ」：この style.css は 2本で 同じファイル（直すときは 2本そろえる）
 * ========================================================== */
:root {
  --primary: #4A90E2;
  --primary-dark: #2f6fb8;
  --bg: #F8F4E6;
  --red: #D63B3B;
  --red-bg: #ffeaea;
  --yellow: #b07800;
  --yellow-bg: #fff4c2;
  --text: #333333;
  --board: #2C5F2D;
  --font-ui: 'M PLUS Rounded 1c', 'Gowun Dodum', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'BIZ UDPGothic', 'Meiryo', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-kyokasho: 'Klee One', 'M PLUS Rounded 1c', 'Gowun Dodum', 'UD Digi Kyokasho N-R', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'BIZ UDPGothic', 'Meiryo', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }
body {
  font-family: var(--font-ui);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding: calc(76px + env(safe-area-inset-top, 0px)) 20px calc(40px + env(safe-area-inset-bottom, 0px));
  position: relative;
  line-height: 1.6;
}

/* UI要塞化（ページを スクロールする 先生の道具なので、かくした中身で ページが のびないよう 高さも 0 に） */
.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  z-index: -1 !important;
  position: absolute !important;
  max-height: 0 !important; max-width: 0 !important;
  overflow: hidden !important;
}

/* 言語の切りかえ（右上。左上は 🏠 もどる） */
.lang-slot {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  z-index: 100;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  background: #fff;
  padding: 28px 30px;
  border-radius: 18px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
  position: relative;
}

h1 {
  text-align: center;
  color: var(--primary);
  font-size: 1.55rem;
  font-weight: 800;
  margin: 0 0 6px;
}
.lead { text-align: center; color: #666; margin: 0 0 20px; font-size: 0.95rem; }

.panel {
  background-color: #e9f2fb;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
.panel-title { display: block; font-weight: 700; margin-bottom: 8px; }
.note { font-size: 0.85rem; color: #666; margin: 6px 0 0; }

select, textarea {
  font-family: var(--font-ui);
  font-size: 1rem;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid #ccc;
  background: #fff;
  color: var(--text);
}
select { min-height: 48px; }
select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea {
  resize: vertical;
  line-height: 1.7;
  font-family: var(--font-kyokasho);
  font-size: 1.1rem;
}
#input-text { height: 220px; }
#input-names { height: 180px; }

.step { font-weight: 700; margin: 18px 0 8px; }

.ui-btn {
  width: 100%;
  min-height: 56px;
  background-color: var(--primary);
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--primary-dark);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 14px 0 0;
}
.ui-btn:active { transform: translateY(4px); box-shadow: none; }
.ui-btn:focus-visible { outline: 3px solid var(--primary-dark); outline-offset: 2px; }
.copy-btn { background-color: var(--board); box-shadow: 0 4px 0 #1a3c1c; }
.print-btn { background-color: #7a6a5a; box-shadow: 0 4px 0 #5a4c3f; }

.sub-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.sub-btn {
  flex: 1 1 200px;
  min-height: 48px;
  background: #fff;
  color: #333;
  border: 2px solid #c9d6e3;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 3px 0 #c9d6e3;
}
.sub-btn:active { transform: translateY(3px); box-shadow: none; }

/* 結果 */
#result-area { margin-top: 26px; position: relative; }

.summary-panel {
  background-color: #fff;
  border: 2px solid var(--red);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.summary-title { font-weight: 800; color: var(--red); margin: 0 0 8px; }
.kanji-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  background-color: var(--red-bg);
  color: var(--red);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 6px 6px 0;
  font-family: var(--font-kyokasho);
}
.kanji-badge small { font-size: 0.7rem; font-family: var(--font-ui); color: #8a4a4a; }
.none-msg { color: #2e7d32; font-weight: 700; margin: 0; }

.legend {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  font-size: 0.9rem; background: #f9f9f9;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 12px;
}

/* 文章（kan） */
#output-text {
  font-family: var(--font-kyokasho);
  font-size: 1.25rem;
  line-height: 1.9;
  padding: 18px 20px;
  background-color: #fcfcfc;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  min-height: 150px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
#output-text:focus { box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3); background-color: #fff; }
.stats { text-align: right; font-size: 0.85rem; color: #666; margin-top: 6px; }

/* 名前の一覧（name） */
.name-list { list-style: none; padding: 0; margin: 0; }
.name-item {
  font-family: var(--font-kyokasho);
  font-size: 1.45rem;
  padding: 10px 15px;
  margin-bottom: 8px;
  background-color: #fcfcfc;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  min-height: 52px;
  cursor: text;
}
.name-item:focus { outline: 2px solid var(--primary); background-color: #fff; }

/* 色分け */
.unlearned { color: var(--red); font-weight: 700; background-color: var(--red-bg); padding: 0 2px; border-radius: 4px; }
.learning { color: var(--yellow); font-weight: 700; background-color: var(--yellow-bg); padding: 0 2px; border-radius: 4px; }

@media (max-width: 700px) {
  body { padding-left: 10px; padding-right: 10px; padding-top: calc(120px + env(safe-area-inset-top, 0px)); }
  .lang-slot { top: calc(66px + env(safe-area-inset-top, 0px)); }
  .container { padding: 20px 16px; }
  h1 { font-size: 1.3rem; }
}

@media print {
  @page { size: A4 portrait; margin: 15mm; }
  body { background: transparent !important; padding: 0 !important; }
  .lang-slot, .panel, textarea, .ui-btn, .sub-btns, .legend, .step, .lead, .summary-panel, .stats, h1 { display: none !important; }
  .container { box-shadow: none !important; margin: 0 !important; padding: 0 !important; max-width: none !important; }
  #result-area { margin-top: 0 !important; }
  #result-area.hidden { display: none !important; }
  #output-text { border: none !important; padding: 0 !important; background: transparent !important; }
  .name-item { border: none !important; border-bottom: 1px dashed #ccc !important; page-break-inside: avoid; }
  .unlearned, .learning { background-color: transparent !important; color: #000 !important; font-weight: normal !important; }
}
