/* ═══════════════════════════════════════════
   LangLearn — UI v0.1.0
   SmaTraLive の青空テーマを継承。こまめに学べる英語。
═══════════════════════════════════════════ */

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

html, body { height: 100%; }
html { background: #38BDF8; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Segoe UI', sans-serif;
  background: #38BDF8;
  min-height: 100%;
  color: #fff;
}

/* メイン画面：デバイスの可視画面ぴったりに収める */
#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(160deg, #1E3A8A 0%, #1D4ED8 35%, #0EA5E9 70%, #38BDF8 100%);
}

#safe-spacer {
  height: env(safe-area-inset-bottom, 0px);
  background: #38BDF8;
}

/* ── ヘッダー ── */
header {
  padding-top: max(22px, env(safe-area-inset-top, 22px));
  padding-bottom: 14px;
  padding-left: max(20px, env(safe-area-inset-left, 20px));
  padding-right: max(20px, env(safe-area-inset-right, 20px));
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.10);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.18);
  flex-shrink: 0;
}
.header-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.header-text { flex-shrink: 0; }
.header-text h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.3px; }
.header-text p {
  font-size: 0.7rem; color: rgba(255,255,255,0.85);
  letter-spacing: 0.04em; margin-top: 1px; white-space: nowrap;
}
.header-right {
  margin-left: auto; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.version { font-size: 0.7rem; font-weight: 700; color: #fff; }
.help-link {
  font-size: 0.7rem; font-weight: 700; color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.28);
  padding: 4px 9px; border-radius: 999px;
}

/* ── 言語バー ── */
#lang-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px max(16px, env(safe-area-inset-left, 16px));
  font-size: 0.85rem; font-weight: 700;
  flex-shrink: 0;
}
.lang-from { opacity: 0.95; }
.lang-arrow { opacity: 0.7; }
#target-lang {
  font-size: 0.85rem; font-weight: 700;
  color: #0B2A6B; background: #fff;
  border: none; border-radius: 10px;
  padding: 6px 10px;
  appearance: none; -webkit-appearance: none;
}

/* ── ビュー共通（中身はスクロール）── */
.view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px max(16px, env(safe-area-inset-left, 16px)) 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── 入力カード ── */
#input-card, #result-card {
  background: rgba(255,255,255,0.97);
  color: #0B2A6B;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.input-label, .result-label {
  display: block;
  font-size: 0.78rem; font-weight: 700;
  color: #2563EB; margin-bottom: 6px;
}
#ja-input {
  width: 100%;
  border: 1.5px solid #CBD5E1;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 1.05rem;
  font-family: inherit;
  color: #0B2A6B;
  resize: vertical;
  min-height: 56px;
  line-height: 1.5;
}
#ja-input:focus { outline: none; border-color: #2563EB; }

.input-actions {
  display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}

/* ── ボタン共通 ── */
.icon-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.08s ease, background 0.15s ease;
  background: #EFF4FF;
  color: #1D4ED8;
}
.icon-btn:active { transform: scale(0.96); }
.icon-btn.primary { background: #2563EB; color: #fff; margin-left: auto; }
.icon-btn.primary:disabled { opacity: 0.6; }
.icon-btn.mic { background: #DBEAFE; color: #1D4ED8; }
.icon-btn.mic.recording { background: #DC2626; color: #fff; animation: pulse 1.1s infinite; }
.icon-btn.ghost { background: #F1F5F9; color: #334155; }
.icon-btn.ghost.danger { background: #FEE2E2; color: #B91C1C; }
.icon-btn.small { padding: 7px 11px; font-size: 0.82rem; }
.icon-btn.flash-ok { background: #16A34A !important; color: #fff !important; }

@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); }
  50%     { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

.interim-text {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #475569;
  min-height: 1.1em;
}

/* ── 結果カード ── */
.result-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.result-sentence {
  font-size: 1.3rem;
  line-height: 1.7;
  color: #0B2A6B;
  background: #EFF6FF;
  border-radius: 12px;
  padding: 12px 14px;
  word-break: break-word;
}
.result-sentence .word {
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s ease;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: #93C5FD;
  text-underline-offset: 3px;
}
.result-sentence .word:active { background: #BFDBFE; }
.result-hint {
  font-size: 0.74rem; color: #64748B; margin-top: 7px;
}
.result-actions {
  display: flex; gap: 8px; margin-top: 12px;
}

/* ── 別の言い方 ── */
#alt-box {
  margin-top: 14px;
  border-top: 1px solid #E2E8F0;
  padding-top: 12px;
}
.alt-title { font-size: 0.78rem; font-weight: 700; color: #2563EB; margin-bottom: 8px; }
.alt-row {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.alt-text { font-size: 1.02rem; color: #0B2A6B; line-height: 1.5; }
.alt-note { font-size: 0.78rem; color: #64748B; margin-top: 3px; }
.alt-row-actions { display: flex; gap: 6px; margin-top: 8px; }
.alt-empty { font-size: 0.85rem; color: #64748B; padding: 6px 0; }

/* ── ステータス ── */
.status-bar {
  text-align: center;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.92);
  min-height: 1.1em;
  padding: 2px 0;
}
.status-bar.active { font-weight: 700; }

/* ── 保存（復習）画面 ── */
.saved-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 2px;
}
.saved-title { font-size: 1rem; font-weight: 800; }
.saved-empty {
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.9);
  padding: 30px 16px;
}
.saved-item {
  background: rgba(255,255,255,0.97);
  color: #0B2A6B;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.14);
}
.saved-ja { font-size: 0.82rem; color: #64748B; }
.saved-en { font-size: 1.12rem; font-weight: 700; line-height: 1.5; margin-top: 4px; }
.saved-item-foot {
  display: flex; align-items: center; justify-content: space-between; margin-top: 10px;
}
.saved-date { font-size: 0.74rem; color: #94A3B8; }
.saved-item-actions { display: flex; gap: 6px; }

/* ── 著作権 ── */
.copyright {
  text-align: center;
  font-size: 0.66rem;
  color: rgba(255,255,255,0.7);
  padding: 4px 0 6px;
  flex-shrink: 0;
}

/* ── 下タブ ── */
#tabbar {
  display: flex;
  flex-shrink: 0;
  background: rgba(255,255,255,0.10);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.18);
}
.tab-btn {
  flex: 1;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.7);
  font-family: inherit;
  font-size: 1.3rem;
  padding: 9px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tab-btn span { font-size: 0.66rem; font-weight: 700; }
.tab-btn.active { color: #fff; }

/* ── 単語詳細ポップアップ ── */
#word-overlay {
  position: fixed; inset: 0;
  background: rgba(8,20,55,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 10000;
  padding: 0;
}
#word-overlay.hidden { display: none; }
#word-card {
  background: #fff;
  color: #0B2A6B;
  width: 100%;
  max-width: 520px;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px max(18px, env(safe-area-inset-bottom, 18px));
  box-shadow: 0 -6px 24px rgba(0,0,0,0.3);
  animation: sheet-up 0.2s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.word-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.word-term { font-size: 1.5rem; font-weight: 800; color: #1D4ED8; }
.word-close {
  background: #F1F5F9; border: none; border-radius: 999px;
  width: 32px; height: 32px; font-size: 1rem; cursor: pointer; color: #475569;
}
.word-body { font-size: 0.95rem; }
.word-loading { color: #64748B; padding: 14px 0; }
.w-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.w-ipa { font-size: 0.95rem; color: #2563EB; font-weight: 700; }
.w-pos {
  font-size: 0.74rem; font-weight: 700;
  background: #DBEAFE; color: #1D4ED8;
  padding: 3px 9px; border-radius: 999px;
}
.w-speak { margin-left: auto; }
.w-meaning { font-size: 1.05rem; line-height: 1.6; color: #0B2A6B; }
.w-usage-label { font-size: 0.74rem; font-weight: 700; color: #2563EB; margin: 12px 0 4px; }
.w-usage { font-size: 0.92rem; line-height: 1.6; color: #334155; background: #F8FAFC; border-radius: 10px; padding: 10px 12px; }

/* ── PWAバナー（iOS/Android）── */
#ios-pwa-banner, #android-pwa-banner {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 10001;
  background: #0B2A6B;
  padding: 14px 16px max(14px, env(safe-area-inset-bottom, 14px));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}
.ios-pwa-content { display: flex; align-items: center; gap: 12px; }
.ios-pwa-icon { font-size: 1.6rem; flex-shrink: 0; }
.ios-pwa-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.ios-pwa-text strong { font-size: 0.9rem; }
.ios-pwa-text span { font-size: 0.76rem; color: rgba(255,255,255,0.85); line-height: 1.4; }
.android-install-btn {
  background: #2563EB; color: #fff; border: none;
  border-radius: 10px; padding: 9px 16px; font-weight: 700; font-size: 0.85rem;
  cursor: pointer; flex-shrink: 0;
}
.ios-pwa-close {
  background: rgba(255,255,255,0.15); color: #fff; border: none;
  border-radius: 999px; width: 28px; height: 28px; font-size: 0.9rem;
  cursor: pointer; flex-shrink: 0;
}
