/* IT用語ナビ - Material Design風スタイル（ライト/ダーク対応） */

:root {
  --primary: #1a73e8;
  --primary-soft: #e8f0fe;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --text: #1f2328;
  --text-sub: #5f6368;
  --border: #e0e3e7;
  --danger: #d93025;
  --star: #f4b400;
  --shadow: 0 1px 3px rgba(0, 0, 0, .10), 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .12);
  --nav-h: 60px;
}

:root[data-theme="dark"] {
  --primary: #8ab4f8;
  --primary-soft: #1f2f47;
  --bg: #121417;
  --surface: #1d2126;
  --text: #e8eaed;
  --text-sub: #9aa0a6;
  --border: #33383f;
  --danger: #f28b82;
  --star: #fdd663;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ===== ヘッダー ===== */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .app-bar { background: var(--surface); color: var(--text); }
.app-bar-title { font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.app-logo { margin-right: 2px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.icon-btn:active { background: rgba(128, 128, 128, .2); }
.icon-btn.small { width: 36px; height: 36px; font-size: 14px; color: var(--text-sub); }

/* ===== メイン ===== */
#main { max-width: 720px; margin: 0 auto; padding: 12px 14px 24px; }

/* ===== 検索エリア ===== */
.search-area {
  position: sticky;
  top: 58px;
  z-index: 15;
  background: var(--bg);
  padding: 4px 0 8px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 4px 8px 4px 14px;
  box-shadow: var(--shadow);
}
.search-icon { color: var(--text-sub); flex-shrink: 0; }
.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;   /* iOSのズーム防止 */
  height: 44px;
}

.filter-row { display: flex; gap: 8px; margin-top: 8px; }
.chip-select {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.list-title { font-size: 15px; font-weight: 700; margin: 10px 2px 0; }
.result-count { font-size: 12px; color: var(--text-sub); margin: 8px 4px; }

/* ===== カード一覧 ===== */
.card-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .06s ease;
}
.card:active { transform: scale(.985); }

.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-name { font-size: 17px; font-weight: 700; }
.card-fav { color: var(--star); font-size: 15px; }

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tag {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.tag.type { background: var(--primary-soft); color: var(--primary); }
.tag.cat { background: transparent; color: var(--text-sub); border: 1px solid var(--border); }

.card-short {
  font-size: 13.5px;
  color: var(--text-sub);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.empty { text-align: center; color: var(--text-sub); padding: 48px 16px; font-size: 14px; }

/* ===== 詳細 ===== */
.back-link {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  padding: 10px 4px;
  cursor: pointer;
}

.detail-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px 18px;
  box-shadow: var(--shadow);
}
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.detail-name { margin: 0; font-size: 24px; }
.detail-kana { font-size: 13px; color: var(--text-sub); margin-top: 2px; }
.detail-abbr { font-size: 12px; }

.fav-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  font-size: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
}
.fav-btn.on { color: var(--star); }

.detail-freq { font-size: 13px; color: var(--text-sub); margin: 10px 0 4px; }
.stars { color: var(--star); letter-spacing: 2px; }

.detail-short { font-size: 15px; font-weight: 600; margin: 10px 0; }
.detail-h { font-size: 14px; margin: 20px 0 6px; color: var(--primary); }
.detail-text { font-size: 14.5px; margin: 0; white-space: pre-wrap; }

.q-list { margin: 4px 0 0; padding-left: 20px; font-size: 14px; }
.q-list li { margin-bottom: 6px; }

.related { display: flex; flex-wrap: wrap; gap: 8px; }
.rel-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--primary);
  border-radius: 16px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
.rel-chip:active { background: var(--primary-soft); }

.detail-meta { font-size: 11px; color: var(--text-sub); margin: 18px 0 12px; }

/* ===== フォーム ===== */
.form-heading { font-size: 20px; margin: 4px 2px 12px; }

.ai-box {
  background: var(--primary-soft);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.ai-label { font-size: 14px; font-weight: 700; display: block; margin-bottom: 8px; }
.ai-row { display: flex; gap: 8px; }
.ai-row input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
}
.ai-hint { font-size: 12px; color: var(--text-sub); margin: 8px 0 0; }

.field { margin-bottom: 14px; flex: 1; min-width: 0; }
.field-row { display: flex; gap: 10px; }
.field label { display: block; font-size: 12.5px; color: var(--text-sub); margin-bottom: 4px; }
.req {
  font-size: 10px;
  background: var(--danger);
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: 1px;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}
.field textarea { resize: vertical; }

.form-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

/* ===== ボタン ===== */
.btn {
  height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.btn.primary { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
:root[data-theme="dark"] .btn.primary { color: #17324e; }
.btn.outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn.wide { width: 100%; }
.btn:active { opacity: .85; }

/* ===== 下部ナビ ===== */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, .06);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 10.5px;
  cursor: pointer;
  font-family: inherit;
}
.nav-item.active { color: var(--primary); font-weight: 700; }

/* ===== ローディング・トースト ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0, 0, 0, .45);
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: #fff; font-size: 14px; text-align: center; padding: 0 24px; }

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  max-width: 90%;
  background: #323639;
  color: #fff;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  white-space: pre-wrap;
}
.toast.error { background: var(--danger); }

/* ===== PC向け ===== */
@media (min-width: 720px) {
  .card:hover { box-shadow: var(--shadow-lg); }
}
