/* ===============================
   ベースカラー（ダーク／ライト）
   =============================== */
:root {
  color-scheme: dark light;
  /* 初期値はダーク寄り */
  --bg:        #0f1115;
  --card:      #161a1f;
  --text:      #f5f5ff;
  --muted:     #a9b1c7;
  --accent:    #9b87ff;
  --chip:      #202632;
  --border:    #303646;
}

/* data-theme="light" のときだけライト色 */
:root[data-theme="light"] {
  --bg:        #f4f5fb;
  --card:      #ffffff;
  --text:      #17151f;
  --muted:     #6c6b7a;
  --accent:    #7b5cff;
  --chip:      #ece9ff;
  --border:    #d5d6e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI",
        Roboto, "Noto Sans JP", "Noto Sans Khmer", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ヘッダー */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 14px;
}
.brand{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.brand .logo{
  margin:0;
  font-size:20px;
  font-weight:800;
  letter-spacing:.2px;
}
.theme{
  border:0;
  background:transparent;
  color:var(--muted);
  font-size:22px;
  cursor:pointer;
}
.searchbar{
  display:flex;
  gap:8px;
  margin-top:6px;
}
.searchbar input{
  flex:1;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
}
.searchbar input::placeholder{
  color:var(--muted);
}
.searchbar button{
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--chip);
  color:var(--text);
  cursor:pointer;
  white-space:nowrap;
}

/* おすすめカード */
.chip-card {
  margin-top: 10px;
}
/* おすすめヘッダー（タイトル + 言語トグル） */
.chip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
/* 「おすすめ」は左側固定 */
.chip-header .meta {
  flex: 0 0 auto;
}
/* 言語トグル */
.suggest-lang-toggle {
  margin-left: auto;
  display: flex;
  gap: 4px;
  align-items: center;
}
:root[data-theme="light"] .suggest-lang-toggle {
  background: rgba(0, 0, 0, 0.04);
}
.chip-card .chips {
  margin-top: 8px;
}

/* 漢字エントリ用ブロック */
.kanji-block {
  margin-top: 6px;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.9;     /* ★ 行間を広く */
}

/* 各行の間隔を少しあける */
.kanji-block > div {
  margin-top: 4px;
}

/* 「よく使う熟語： ○○ ○○ ○○」行 */
.kanji-comp-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.kanji-comp-label {
  flex: 0 0 auto;
}

.kanji-comp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suggest-lang-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
  opacity: 0.7;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.suggest-lang-btn.is-active {
  background: var(--chip);
  color: var(--text);
  opacity: 1;
}

.suggest-lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* おすすめチップ */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.chips button {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

/* 本文 */
main .section {
  margin: 10px auto;
  max-width: 960px;
  padding: 0 14px 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
}

.row {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}
.row:hover {
  border-color: var(--accent);
}

.pos {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.pill {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  font-size: 12px;
}

.back {
  display: inline-block;
  margin: 10px 0 14px;
  color: var(--accent);
  cursor: pointer;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* フッター */
footer {
  border-top: 1px solid var(--border);
  margin-top: 18px;
}
.footer-nav {
  font-size: 14px;
}

.footer-nav a {
  margin-right: 10px;
  color: var(--accent);
}

.footer-nav a.is-active {
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
}
small {
  color: var(--muted);
}

.center {
  text-align: center;
}

/* AdSense 未充填時に自動で畳む */
.ad-slot {
  margin: 8px 0;
  background: transparent;
}
.ad-slot[hidden] {
  display: none !important;
}
.ad-slot .adsbygoogle {
  display: block;
  background: transparent !important; /* ★白背景を消す */
}
.ad-slot .adsbygoogle[data-ad-status="unfilled"] {
  display: none;
}

@media (max-width: 600px) {
  .brand .logo {
    font-size: 18px;
  }
  main .section {
    padding: 0 10px 16px;
  }
}

/* 例文ブロック（詳細画面） */
.examples {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.example-item { }

.example-line {
  line-height: 1.5;
}

.ex-no {
  font-weight: 600;
  margin-right: 4px;
}

.example-km {
  color: var(--muted);
}

/* 汎用の薄いテキスト（説明など） */
.muted {
  color: var(--muted);
  font-size: 14px;
}

/* お問い合わせフォーム */
.contact-form {
  max-width: 640px;
  margin: 0 auto;
}
.contact-form label {
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
}
.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.contact-form textarea {
  resize: vertical;
}
.contact-form button {
  margin-top: 16px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.contact-form button:hover {
  opacity: .9;
}
.contact-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

/* 日本語学習ミニガイド */
.kana-guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.kana-column h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.kana-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 14px;
}

.kana-list li {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.kana-list li span:first-child {
  font-weight: 600;
  margin-right: 8px;
}

.kana-section-title {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.kana-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0.75rem;
}

.kana-cell {
  flex: 0 0 calc(20% - 8px); /* 1行に最大5つ並ぶイメージ */
  min-width: 70px;
  padding: 6px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
}

[data-theme="light"] .kana-cell {
  background: rgba(0, 0, 0, 0.03);
}

.kana-jp {
  display: block;
  font-size: 1.2rem;
  line-height: 1.2;
}

.kana-ro {
  display: block;
  font-size: 0.75rem;
  opacity: 0.85;
  line-height: 1.2;
}

.kana-km {
  display: block;
  font-size: 0.85rem;
  line-height: 1.2;
}

/* 意味テキスト用：枠だけ・背景透明 */
.meaning-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  margin-left: 4px;

  border-radius: 999px;
  border: 1px solid currentColor;  /* テキストと同じ色の枠 */
  background: transparent;         /* 背景は無色 */
  color: inherit;
  font: inherit;

  cursor: pointer;
}

/* ちょっとだけ反応する程度のホバー */
.meaning-chip:hover {
  background: transparent; /* 塗りつぶさない */
  opacity: 0.85;
}

/* 入力中サジェスト全体のカード */
.typing-suggest-box {
  position: absolute;           /* JS で left/right は指定済み */
  top: calc(100% + 4px);        /* 検索ボックスのすぐ下 */
  z-index: 40;

  display: flex;
  flex-direction: column;
  gap: 0;                        /* 行のスキマなしで一枚のカードに見せる */

  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);

  max-height: 260px;
  overflow-y: auto;
  padding: 0;                    /* 内側パディングなし → 行の高さで調整 */
}

/* 候補1行ぶん */
.typing-suggest-item {
  display: block;
  width: 100%;
  padding: 6px 12px;

  border: 0;
  border-radius: 0;              /* 角はカード側に任せる */
  background: transparent;
  color: var(--text);

  font-size: 14px;
  text-align: left;
  cursor: pointer;
  outline: none;
}

/* 行の区切り線（最後の行以外） */
.typing-suggest-item + .typing-suggest-item {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* マウスで上に乗せた行が「選択されている」ように見せる */
.typing-suggest-item:hover,
.typing-suggest-item:focus-visible {
  background: var(--chip);
}
