/* CHERISHH English — ユーザー向けPWAのスタイル。
   CSP(script-src/style-src 'self')を満たすため、外部ファイルとして配信する(インラインstyleはstyle-src 'self'の
   もとでは適用されない: docs/local-browser-test.md参照)。外部フォント・外部画像は使わない(システムフォントのみ)。

   ブランド配色は暫定値(ブランドガイド未確定: docs/production-runbook.md「未確認事項」参照)。色はすべて下記のトークンに
   集約しているため、ブランド確定時はここだけを差し替える。ダークモードはOS設定(prefers-color-scheme)に追従する。 */
:root {
  --bg: #faf7f5;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --accent: #be123c;
  --accent-ink: #ffffff;
  --accent-soft: #fff1f2;
  --danger: #b91c1c;
  --focus: #1d4ed8;
  --radius: 1rem;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 8px 24px rgb(15 23 42 / 0.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2e;
    --ink: #f1f5f9;
    --muted: #a7b3c6;
    --line: #26324a;
    --accent: #fb7185;
    --accent-ink: #1b0a10;
    --accent-soft: #2a1520;
    --danger: #fca5a5;
    --focus: #93c5fd;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
  margin: 0;
  /* ノッチ・ホームバー(iPhone standalone)を避ける */
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  color: var(--ink);
  background: var(--bg);
  max-width: 30rem;
  margin-inline: auto;
}

/* --- ヘッダ(ブランド) ---
   アプリアイコン(濃紺背景×ゴールドのC)と色・書体を揃える。ヘッダはアイコンの濃紺を基調にした帯にし、
   CHERISHHは白、ENGLISHは落ち着いたゴールドで表示する(ライト/ダークどちらのテーマでも同じ配色)。
   CHERISHHとENGLISHは同じ書体で、同じ行のベースラインに揃える。 */
:root {
  --brand-navy: #0f172e; /* アプリアイコンの背景色 */
  --brand-gold: #d4af37; /* アイコンのゴールドの基準色 */
  --brand-white: #ffffff;
}
.app-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem 0.6rem 0.65rem;
  background: var(--brand-navy);
  border: 1px solid rgb(212 175 55 / 0.22);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand-icon {
  flex: none;
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
  box-shadow: 0 0 0 1px rgb(212 175 55 / 0.45);
}
.brand-name {
  min-width: 0;
  white-space: nowrap; /* iPhoneの狭い幅でも途中で改行しない */
  font-family: inherit; /* CHERISHHとENGLISHは同じ書体(本文と同じシステムフォント) */
  font-size: clamp(0.78rem, 3.7vw, 0.98rem); /* 狭い画面では少し小さくして、はみ出さない */
  line-height: 1.2;
  text-transform: uppercase;
}
.brand-cherishh {
  color: var(--brand-white);
  font-weight: 700;
  letter-spacing: 0.16em;
}
.brand-english {
  margin-left: 0.5em;
  color: var(--brand-gold);
  font-size: 0.82em; /* CHERISHHより少し小さく、同じベースラインに揃える */
  font-weight: 600;
  letter-spacing: 0.28em;
}
.noscript-message {
  color: var(--danger);
}

/* --- 画面(カード) --- */
[data-screen] {
  display: none;
}
[data-screen].is-active {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.25rem;
}
h1 {
  font-size: 1.35rem;
  line-height: 1.35;
  margin: 0 0 0.75rem;
}
h2 {
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
}
p {
  margin: 0 0 0.9rem;
}
.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}
.lesson-title {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
}
.status-line {
  font-weight: 700;
}
.loading-line {
  color: var(--muted);
}

/* --- ボタン(タップしやすい高さ44px以上) --- */
button {
  font: inherit;
  display: block;
  width: 100%;
  min-height: 2.9rem;
  padding: 0.7rem 1.2rem;
  margin-top: 0.6rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
button.primary,
button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
button.secondary {
  background: transparent;
}
button.link {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  min-height: 2.5rem;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* --- 入力 --- */
input {
  font: inherit;
  font-size: 1.4rem;
  padding: 0.7rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0.35em;
  text-align: center;
}

.error-message {
  color: var(--danger);
  min-height: 1.2em;
  margin-top: 0.75rem;
}
.hint {
  color: var(--muted);
  font-size: 0.9em;
}
[hidden] {
  display: none !important;
}

#dev-otp-panel {
  border: 1px dashed var(--muted);
  padding: 0.75rem;
  margin-top: 1rem;
}
#dev-otp-result {
  font-weight: bold;
}
#install-manual-guidance-steps {
  padding-left: 1.4rem;
}
#install-manual-guidance-steps > li {
  margin-bottom: 1.25rem;
}
/* iPhone実機フィードバック対応: 「このマークを探せばよい」と一目で分かるよう、
   説明文に埋め込む小さな挿絵ではなく、大きく独立したブロックとして表示する。 */
.install-guidance-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 5.5rem;
  height: 5.5rem;
  margin: 0.75rem auto;
  padding: 0.5rem;
  border: 2px solid var(--ink);
  border-radius: 0.75rem;
  color: var(--ink);
}
.install-guidance-icon svg {
  width: 100%;
  height: 100%;
}
.install-guidance-fallback {
  margin-top: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-left: 3px solid var(--muted);
  background: var(--accent-soft);
}
.install-guidance-fallback ol {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

/* LINE招待〜ホーム画面追加の案内: 大きな文字・番号・図で、迷わないようにする */
.lead {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.6;
}
.big-steps {
  padding-left: 1.6rem;
  font-size: 1.1rem;
  line-height: 1.7;
}
.big-steps > li {
  margin-bottom: 1.1rem;
}
.big-steps strong {
  color: var(--accent);
}
.install-diagram {
  max-width: 22rem;
  margin: 0.5rem auto 0.25rem;
  padding: 0.5rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
}
.install-diagram svg {
  display: block;
  width: 100%;
  height: auto;
}
.diagram-hl {
  stroke: var(--accent);
  stroke-width: 3;
}
.line-last-resort {
  margin-top: 1rem;
}

/* 教材Viewer(/a/{token}) */
.viewer-media-element {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 0;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}
/* PDF専用ビューア(pdf.js。canvas描画のみ。標準ビューアの保存・印刷ボタンは使わない) */
.pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0;
}
.pdf-toolbar[hidden] {
  display: none;
}
.pdf-toolbar .pdf-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  flex: 0 0 auto;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.25rem 0.6rem;
  font-size: 1.1rem;
}
.pdf-indicator,
.pdf-zoom-text {
  min-width: 3.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pdf-scroller {
  position: relative; /* 各ページのoffsetTopを、スクロール領域の内側の座標にする(ページ送り・現在ページの判定に使う) */
  height: 75vh;
  height: 75dvh; /* iOSのアドレスバー・ツールバーの出入りに追従する(未対応のブラウザは上の75vh) */
  min-height: 24rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
  background: #d9d9d9;
  border-radius: 0.5rem;
  padding: 0.5rem;
  box-sizing: border-box;
}
.pdf-scroller:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.pdf-page {
  margin: 0 auto 0.5rem;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.pdf-canvas {
  display: block;
  -webkit-touch-callout: none;
}
#viewer-media a {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--accent);
}

/* 教材Viewerだけ: 通常の操作での選択・コピー・長押しメニュー・ドラッグ・印刷を抑える補助策(完全なコピー防止ではない)。
   入力欄・管理画面には適用しない(この画面に入力欄は無い)。スクリーンリーダー・再生操作・ピンチ拡大には影響しない。 */
[data-screen="VIEWER"] {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
[data-screen="VIEWER"] .viewer-media-element {
  -webkit-user-drag: none;
}
#viewer-print-note {
  display: none;
}
@media print {
  [data-screen="VIEWER"] #viewer-media {
    display: none !important;
  }
  #viewer-print-note {
    display: block !important;
  }
}

@media (prefers-reduced-motion: no-preference) {
  [data-screen].is-active {
    animation: screen-in 160ms ease-out;
  }
}
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 通知設定: OSの許可とアプリ内設定の2行、オン・オフのスイッチ */
.status-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  font-size: 0.9rem;
}
.status-list li + li {
  margin-top: 0.35rem;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 3.4rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  letter-spacing: normal;
  cursor: pointer;
  transition: background 120ms ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  transition: transform 120ms ease;
}
.switch:checked {
  background: var(--accent);
}
.switch:checked::after {
  transform: translateX(1.4rem);
}
.switch:disabled {
  opacity: 0.55;
  cursor: wait;
}
@media (prefers-reduced-motion: reduce) {
  .switch,
  .switch::after {
    transition: none;
  }
}

/* 今日の課題・過去の課題(カード一覧) */
.section-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}
.section-title-history {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.lesson-card {
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--bg);
}
.lesson-card-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.lesson-card-meta,
.lesson-card-date {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.lesson-card button {
  margin-top: 0.6rem;
}
.lesson-empty {
  margin: 0 0 0.75rem;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 0.9rem;
  text-align: center;
}
.lesson-empty-title {
  margin: 0;
  font-weight: 700;
}
#today-lessons:empty {
  display: none;
}

/* My Assignments(フォルダ中心の課題一覧): スマートフォンで、フォルダ名・件数・NEWが一目で分かる大きなタップ領域。横スクロールを出さない */
ul.plain {
  list-style: none;
  margin: 0;
  padding: 0;
}
.folder-list {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 1rem;
}
.folder-list li {
  min-width: 0;
}
.folder-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  min-height: 4rem;
  padding: 0.7rem 0.85rem;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.folder-item:active {
  background: var(--accent-soft);
}
.folder-icon {
  position: relative;
  flex: none;
  width: 2.1rem;
  height: 1.55rem;
  margin-top: 0.2rem;
  border-radius: 0.28rem 0.28rem 0.4rem 0.4rem;
  background: var(--accent);
}
.folder-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: -0.3rem;
  width: 0.95rem;
  height: 0.35rem;
  border-radius: 0.25rem 0.25rem 0 0;
  background: var(--accent);
}
.folder-main {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.1rem;
}
.folder-name {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.folder-meta {
  color: var(--muted);
  font-size: 0.85rem;
}
.folder-chevron {
  flex: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}
.new-badge {
  display: inline-block;
  flex: none;
  margin-left: 0.4rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.3;
  vertical-align: middle;
  white-space: nowrap;
}
.folder-item .new-badge {
  margin-left: 0;
}
.folder-breadcrumb {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 0.9rem;
}
.folder-back {
  justify-self: start;
  min-height: 2.75rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.folder-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.85rem;
}
.folder-crumbs li {
  min-width: 0;
  overflow-wrap: anywhere;
}
.folder-crumbs li + li::before {
  content: "›";
  margin-right: 0.4rem;
}
.folder-crumbs li[aria-current="page"] {
  color: var(--ink);
  font-weight: 700;
}
.folder-date-heading {
  margin: 1.1rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}
#folder-lessons .lesson-list {
  margin-bottom: 0.5rem;
}
#folder-list:empty {
  display: none;
}

/* ホーム画面に追加する: 画面の主役になる大きなボタン */
button.big-cta { width: 100%; min-height: 3.75rem; font-size: 1.2rem; font-weight: 700; }
