:root{
    --ink:#20281f;
    --orange:#ff7a1a;
    --orange-deep:#e05e00;
    --green:#4c7a5e;
    --green-deep:#365a44;
    --paper:#fff8ef;
    --card:#fffcf7;
    --muted:#e8dcc8;
    --muted-2:#c9bda3;
    --danger:#c65b3f;
    --radius-lg:26px;
    --radius-md:16px;
    --shadow:0 18px 40px -18px rgba(32,40,31,0.35);
  }
  *{box-sizing:border-box;}
  body{
    margin:0;
    font-family:'Inter','Zen Maru Gothic',sans-serif;
    background:
      radial-gradient(circle at 12% 8%, #ffe6c9 0%, transparent 45%),
      radial-gradient(circle at 88% 92%, #dcead9 0%, transparent 40%),
      var(--paper);
    color:var(--ink);
    min-height:100vh;
    display:flex;
    flex-direction:column;
    align-items:center;
    padding:28px 16px;
  }
  /* 縦中央寄せは auto margin で行う（align-items:center だと長いカード一覧の上端が切れてスクロールできない） */
  #app{
    width:100%;
    max-width:420px;
    margin-block:auto;
  }
  .view{display:none;}
  .view.active{display:block;}

  /* ---------- shared bits ---------- */
  .brand{
    display:flex;
    align-items:baseline;
    gap:8px;
    margin-bottom:22px;
  }
  .brand-mark{
    font-family:'Baloo 2','Zen Maru Gothic',sans-serif;
    font-weight:800;
    font-size:26px;
    color:var(--orange-deep);
  }
  .brand-sub{
    font-size:13px;
    color:var(--green-deep);
    font-weight:500;
  }
  h1{
    font-family:'Baloo 2','Zen Maru Gothic',sans-serif;
    font-size:22px;
    font-weight:700;
    margin:0 0 6px;
  }
p.lead{
  font-size:14px;
  font-weight:500;
  line-height:1.75;
  letter-spacing:.02em;
  color:#6b604f;
  margin:0 0 18px;
}
  textarea{
    width:100%;
    min-height:170px;
    resize:vertical;
    border:1.5px solid var(--muted);
    border-radius:var(--radius-md);
    padding:16px;
    font-family:'Inter','Zen Maru Gothic',sans-serif;
    font-size:14.5px;
    line-height:1.6;
    color:var(--ink);
    background:var(--card);
    outline:none;
    transition:border-color .15s ease;
  }
  textarea:focus{border-color:var(--orange);}
  textarea::placeholder{color:#a79c88;}

  .format-hint{
    display:flex;
    gap:10px;
    margin-top:12px;
    font-size:12.5px;
    color:#7a6f5c;
    background:#fdf1de;
    border-radius:12px;
    padding:10px 12px;
    line-height:1.6;
  }
  .format-hint b{color:var(--orange-deep);}

  .extract-link{
    display:inline-block;
    margin:0 0 14px;
    font-size:13.5px;
    font-weight:600;
    color:var(--green-deep);
    text-decoration:underline;
    text-decoration-color:var(--muted-2);
    text-underline-offset:3px;
  }
  .extract-link:hover{color:var(--orange-deep);text-decoration-color:var(--orange);}

  button{
    font-family:'Inter','Zen Maru Gothic',sans-serif;
    cursor:pointer;
    border:none;
  }
  .btn-primary{
    width:100%;
    margin-top:18px;
    background:var(--orange);
    color:#fff8ef;
    font-weight:700;
    font-size:15.5px;
    padding:15px 20px;
    border-radius:999px;
    box-shadow:0 12px 24px -10px rgba(255,122,26,0.55);
    transition:transform .12s ease, box-shadow .12s ease;
  }
  .btn-primary:active{transform:scale(0.97);}
  .btn-primary:disabled{
    background:var(--muted-2);
    box-shadow:none;
    cursor:not-allowed;
  }
  .btn-ghost{
    background:transparent;
    color:var(--green-deep);
    font-weight:600;
    font-size:14px;
    padding:10px 6px;
  }

  /* ---------- edit view ---------- */
  .edit-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:14px;
  }
  .count-pill{
    background:var(--green);
    color:#fff;
    font-size:12.5px;
    font-weight:600;
    padding:4px 12px;
    border-radius:999px;
  }
  .card-list{
    display:flex;
    flex-direction:column;
    gap:10px;
    max-height:46vh;
    overflow-y:auto;
    padding-right:4px;
    margin-bottom:8px;
  }
  .card-row{
    display:flex;
    align-items:center;
    gap:10px;
    background:var(--card);
    border:1.5px solid var(--muted);
    border-radius:14px;
    padding:10px 12px;
  }
  .card-row .word{
    font-family:'Baloo 2','Zen Maru Gothic',sans-serif;
    font-weight:700;
    font-size:15px;
    min-width:88px;
    color:var(--ink);
  }
  .card-row input{
    flex:1;
    border:none;
    background:transparent;
    font-size:13.5px;
    font-family:'Zilla Slab','Zen Maru Gothic',serif;
    color:#5a5347;
    outline:none;
    border-bottom:1.5px dashed transparent;
  }
  .card-row input:focus{border-bottom-color:var(--orange);}
  .card-row.has-note{flex-wrap:wrap;}
  .card-note{
    flex-basis:100%;
    white-space:pre-line;
    font-size:12px;
    line-height:1.5;
    color:#8a7f6c;
  }
  .card-row input::placeholder{color:#b8ac97;font-family:'Inter','Zen Maru Gothic',sans-serif;}
  .remove-btn{
    background:none;
    color:#b8ac97;
    font-size:18px;
    line-height:1;
    padding:4px 6px;
    border-radius:8px;
    flex-shrink:0;
  }
  .remove-btn:hover{color:var(--danger);background:#fbeae5;}
  .add-row-btn{
    width:100%;
    background:transparent;
    border:1.5px dashed var(--muted-2);
    border-radius:14px;
    padding:10px;
    font-size:13px;
    color:#7a6f5c;
    font-weight:600;
    margin-bottom:6px;
  }
  .add-row-btn:hover{border-color:var(--orange);color:var(--orange-deep);}
  .edit-actions{
    display:flex;
    gap:10px;
    margin-top:14px;
  }
  .edit-actions .btn-primary{margin-top:0;flex:1;}
  .edit-actions .btn-secondary{
    flex:1;
    background:var(--card);
    border:1.5px solid var(--muted);
    color:var(--green-deep);
    font-weight:600;
    font-size:14px;
    padding:15px 12px;
    border-radius:999px;
  }
  .edit-actions .btn-secondary:hover{border-color:var(--green);}

  
/* ---------- study view ---------- */
  .study-top{
    display:flex;
    align-items:center;
    gap:10px;
    margin-bottom:22px;
  }
  .close-btn{
    background:var(--card);
    border:1.5px solid var(--muted);
    width:34px;height:34px;
    border-radius:50%;
    font-size:15px;
    color:#7a6f5c;
    flex-shrink:0;
    display:flex;align-items:center;justify-content:center;
  }
  .progress-track{
    flex:1;
    height:8px;
    background:var(--muted);
    border-radius:999px;
    overflow:hidden;
  }
  .progress-fill{
    height:100%;
    background:linear-gradient(90deg,var(--orange),#ffb35c);
    border-radius:999px;
    transition:width .25s ease;
  }
  .progress-count{
    font-size:12.5px;
    font-weight:600;
    color:#7a6f5c;
    white-space:nowrap;
  }
  .dots{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
    margin-bottom:22px;
    justify-content:center;
  }
  .dot{
    width:8px;height:8px;border-radius:50%;
    background:var(--muted);
  }
  .dot.done{background:var(--green);}
  .dot.again{background:var(--danger);}
  .dot.current{background:var(--orange);transform:scale(1.35);}

  .scene{
    position:relative;
    perspective:1400px;
    margin-bottom:22px;
  }
  .card-slide{
    transition:transform .32s cubic-bezier(.22,.75,.3,1), opacity .28s ease;
  }
  .card-slide.exit-review{ transform:translateX(-135%) rotate(-8deg); opacity:0; }
  .card-slide.exit-known{ transform:translateX(135%) rotate(8deg); opacity:0; }
  .card-slide.exit-skip{
    transition:transform .18s ease, opacity .18s ease;
    transform:translateY(-10px);
    opacity:0;
  }
  .card-slide.pop-in{ animation:cardPopIn .24s ease; }
  @keyframes cardPopIn{
    from{ opacity:0; transform:scale(.95); }
    to{ opacity:1; transform:scale(1); }
  }

  .judge-stamp{
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%,-50%) scale(.7) rotate(0deg);
    padding:10px 22px;
    border-radius:14px;
    font-family:'Baloo 2','Zen Maru Gothic',sans-serif;
    font-weight:800;
    font-size:22px;
    white-space:nowrap;
    background:#fffcf7;
    opacity:0;
    pointer-events:none;
    transition:opacity .16s ease, transform .16s ease;
    z-index:5;
  }
  .judge-stamp.show{ opacity:1; transform:translate(-50%,-50%) scale(1) rotate(var(--stamp-rot,0deg)); }
  .judge-stamp.stamp-review{ color:var(--danger); border:3px solid var(--danger); --stamp-rot:-7deg; }
  .judge-stamp.stamp-known{ color:var(--green-deep); border:3px solid var(--green-deep); --stamp-rot:7deg; }

  .flashcard{
    position:relative;
    width:100%;
    height:280px;
    transform-style:preserve-3d;
    transition:transform .5s cubic-bezier(.2,.9,.3,1);
    cursor:pointer;
  }
  .flashcard.flipped{transform:rotateY(180deg);}
  .face{
    position:absolute;
    inset:0;
    backface-visibility:hidden;
    border-radius:var(--radius-lg);
    overflow:hidden;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    padding:26px;
    box-shadow:var(--shadow);
  }
  .face-front{
    background:var(--card);
    border:1.5px solid var(--muted);
  }
  /* 答えの面：落ち着いたセージ色。表のクリーム色と同じトーンでそろえる */
  .face-back{
    background:linear-gradient(170deg, #f3f6ee 0%, #e4ecdf 100%);
    border:1.5px solid #d2ddcb;
    color:#2e4a39;
    transform:rotateY(180deg);
  }
  .word-text{
    font-family:'Baloo 2','Zen Maru Gothic',sans-serif;
    font-weight:800;
    font-size:30px;
    line-height:1.35;
    color:var(--ink);
    word-break:break-word;
    overflow-wrap:anywhere;
  }
  /* 長い文でも枠に収める：文字サイズは JS（fitText）で自動調整し、
     最小サイズでも入りきらない場合はカード内でスクロールする */
  .word-text,
  .meaning-text{
    flex:0 1 auto;
    min-height:0;
    max-width:100%;
    overflow:hidden;
  }
  .word-text.is-scroll,
  .meaning-text.is-scroll{
    overflow-y:auto;
    overscroll-behavior:contain;
    scrollbar-width:thin;
  }
  .hint-text,.meaning-label{flex-shrink:0;}
  /* 答えに添える説明（Read the Room の手がかりなど）。長ければカードの中でスクロール */
  .note-text{
    flex:0 1 auto;
    min-height:0;
    max-width:100%;
    overflow-y:auto;
    overscroll-behavior:contain;
    scrollbar-width:thin;
    margin-top:10px;
    padding-top:8px;
    border-top:1px dashed #c3d1bb;
    white-space:pre-line;
    font-size:12.5px;
    line-height:1.6;
    font-weight:500;
    text-align:left;
    opacity:.85;
  }
  .note-text[hidden]{display:none;}
  .flashcard.is-long{height:360px;}
  .flashcard.is-long .word-text,
  .flashcard.is-long .meaning-text{text-align:left;}
  /* 裏面：長い文のときは下の判定コーナーと重ならないよう余白を取る */
  .flashcard.is-long .face-back{padding-bottom:108px;}
  .hint-text{
    margin-top:14px;
    font-size:12px;
    color:#a79c88;
    font-weight:500;
  }
  .meaning-label{
    font-size:11.5px;
    letter-spacing:.02em;
    text-transform:none;
    opacity:.75;
    margin-bottom:10px;
    font-weight:600;
  }
  .meaning-text{
    font-family:'Zilla Slab','Zen Maru Gothic',serif;
    font-size:42px;
    font-weight:800;
    line-height:1.5;
    word-break:break-word;
    overflow-wrap:anywhere;
  }

  /* 円の1/4を各コーナーに配置した判定エリア（左下＝もう一度／右下＝覚えた） */
  .face-judge{
    position:absolute;
    bottom:0;
    width:104px;
    height:104px;
    display:flex;
    align-items:flex-end;
    font-size:12.5px;
    font-weight:700;
    letter-spacing:.01em;
    line-height:1.3;
    white-space:nowrap;
    cursor:pointer;
    transition:background-color .15s ease, transform .12s ease;
  }
  .face-judge-review{
    left:0;
    justify-content:flex-start;
    padding:0 0 16px 16px;
    border-top-right-radius:100%;
    transform-origin:0% 100%;
    background:#f6e7dc;
    color:#a4563d;
  }
  .face-judge-review:hover{background:#f2dccd;}
  .face-judge-review:active{background:#ecd0bd;transform:scale(0.94);}
  .face-judge-known{
    right:0;
    justify-content:flex-end;
    padding:0 16px 16px 0;
    border-top-left-radius:100%;
    transform-origin:100% 100%;
    background:#cfdfc8;
    color:var(--green-deep);
  }
  .face-judge-known:hover{background:#c3d7bb;}
  .face-judge-known:active{background:#b5ceac;transform:scale(0.94);}

  /* ---------- result view ---------- */
  .result-emoji{
    font-family:'Baloo 2','Zen Maru Gothic',sans-serif;
    font-size:44px;
    text-align:center;
    margin-bottom:6px;
  }
  .result-stats{
    display:flex;
    justify-content:center;
    gap:22px;
    margin:20px 0 26px;
  }
  .stat{
    text-align:center;
  }
  .stat-num{
    font-family:'Baloo 2','Zen Maru Gothic',sans-serif;
    font-weight:800;
    font-size:30px;
  }
  .stat-num.known{color:var(--green-deep);}
  .stat-num.review{color:var(--danger);}
  .stat-label{
    font-size:12px;
    color:#7a6f5c;
    margin-top:2px;
  }
  .result-actions{
    display:flex;
    flex-direction:column;
    gap:10px;
  }

  @media (prefers-reduced-motion: reduce){
    .flashcard{transition:none;}
  }

.howto-link{
  margin:14px 0 0;
  text-align:center;
  font-size:13px;
}
.howto-link a{color:var(--green-deep);text-underline-offset:3px;}

/* 出題順のシャッフル */
.shuffle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
  cursor: pointer;
}
.shuffle-label input {
  width: 18px;
  height: 18px;
}

/* 前回のカードを続ける */
.resume-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 13px 16px;
  border: 1.5px solid var(--orange);
  border-radius: 999px;
  background: transparent;
  color: var(--orange-deep);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.resume-btn:hover {
  background: color-mix(in srgb, var(--orange) 10%, transparent);
}

/* 追加した行の単語入力 */
.card-row input.word-input {
  flex: 0 0 110px;
  min-width: 0;
  font-family: 'Baloo 2','Zen Maru Gothic',sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  border-bottom-color: var(--muted);
}

.deck-name-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: #8a7f6b;
}
.deck-name-label input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1.5px solid var(--muted);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
.direction {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 10px;
  font-size: 14px;
}
.direction-title { font-size: 13px; font-weight: 700; color: #8a7f6b; }
.direction label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }

/* 共通ナビ: body の余白（上28px・左右16px）を打ち消して、画面の上端と左右いっぱいに置く */
.site-bar {
  margin: -28px -16px 24px;
  width: calc(100% + 32px);
}

/* 辞書から訳を入れたときのお知らせ */
.dict-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #eef4ec;
  color: #365a44;
  font-size: 13px;
  line-height: 1.6;
}

/* ===== 学習画面：アプリのような全画面 ===== */
body.is-studying {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
}
body.is-studying .site-bar,
body.is-studying .series-footer { display: none; }
body.is-studying #app { margin-block: 0; height: 100%; max-width: 480px; }
#view-study.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#view-study .study-top { margin-bottom: 14px; }
#view-study .dots { margin-bottom: 0; }
#view-study .scene {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  margin: 12px 0 8px;
}
#view-study .card-slide { width: 100%; }
#view-study .flashcard,
#view-study .flashcard.is-long {
  height: clamp(280px, 64dvh, 560px);
  touch-action: pan-y;
}
.undo-btn:disabled { opacity: .35; cursor: default; }

/* 裏面：問題を小さく表示（タップで表に戻る） */
.back-question {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 58px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(54,90,68,0.08);
  color: #4f6b58;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  width: fit-content;
  max-width: calc(100% - 72px);
}
.back-question-icon { flex: none; opacity: .8; }
.back-question-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.speak-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(54,90,68,0.08);
  font-size: 17px;
  line-height: 1;
}
.speak-btn:active { transform: scale(.92); }
.face-back { padding-top: 58px; }

/* ドラッグ中に、判定するコーナーを強調 */
.flashcard.lean-review .face-judge-review { background: #ecd0bd; transform: scale(1.12); }
.flashcard.lean-known .face-judge-known { background: #b5ceac; transform: scale(1.12); }

/* 結果の割合バー */
.result-bar {
  height: 10px;
  margin: -10px 0 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 35%, var(--muted));
  overflow: hidden;
}
.result-bar-fill { height: 100%; width: 0; background: var(--green); border-radius: 999px; transition: width .6s ease; }

/* 編集画面：出題オプションを1行に */
.study-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--muted);
}
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  color: #7a6f5c;
  transition: background .15s ease, color .15s ease;
}
.segmented input:checked + span { background: var(--card); color: var(--ink); box-shadow: 0 2px 6px -2px rgba(32,40,31,.3); }
.segmented input:focus-visible + span { outline: 2px solid var(--orange); }
.study-options .shuffle-label { margin-top: 0; font-weight: 600; color: #5a5347; }

/* 結果画面でも同じ見た目のサブボタンにする */
.result-actions .btn-secondary {
  background: var(--card);
  border: 1.5px solid var(--muted);
  color: var(--green-deep);
  font-weight: 600;
  font-size: 14.5px;
  padding: 14px 12px;
  border-radius: 999px;
}

/* ===== ホーム（マイデッキ） ===== */
.home-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.home-title { margin: 0; font-family: 'Baloo 2','Zen Maru Gothic',sans-serif; font-size: 22px; font-weight: 700; }
.home-count { font-size: 13px; font-weight: 600; color: #8a7f6b; }
.deck-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.deck-card {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 4px;
  background: var(--card);
  border: 1.5px solid var(--muted);
  border-radius: 18px;
  box-shadow: 0 10px 22px -18px rgba(32,40,31,.45);
  transition: border-color .15s ease;
}
.deck-card:hover { border-color: var(--muted-2); }
.deck-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 12px;
  background: none;
  text-align: left;
  font: inherit;
  color: var(--ink);
}
.deck-name { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-meta { font-size: 12px; color: #8a7f6b; }
.deck-open:hover .deck-name { color: var(--orange-deep); }
.deck-play {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 14px;
  padding-left: 3px;
  box-shadow: 0 8px 16px -8px rgba(255,122,26,.6);
}
.deck-play:active { transform: scale(.93); }
.deck-delete {
  flex: none;
  border: none;
  background: none;
  font: inherit;
  font-size: 16px;
  color: #b8ac97;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.deck-delete.confirm { font-size: 12px; font-weight: 700; color: #fff; background: var(--danger); }
#view-home .btn-primary { margin-top: 16px; }

/* ===== 作成画面 ===== */
.input-top { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.input-top .brand { margin-bottom: 0; }
.detect {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  min-height: 30px;
  margin-top: 8px;
}
.detect-text { font-size: 13px; font-weight: 600; color: #8a7f6b; }
.detect-text.is-ok { color: var(--green-deep); }
.detect-text.is-ok::before { content: '✓ '; }
.detect-text.is-warn { color: var(--danger); }
.detect-switch {
  margin-left: auto;
  padding: 4px 2px;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--orange-deep);
  text-decoration: underline;
  text-decoration-color: var(--muted-2);
  text-underline-offset: 3px;
}
.detect + .btn-primary { margin-top: 10px; }

/* ===== 確認画面の ⋯ と書き出しシート ===== */
.edit-head .count-pill { margin-left: auto; }
.more-btn {
  margin-left: 8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--muted);
  color: #7a6f5c;
  font-size: 18px;
  line-height: 1;
}
.more-btn:hover { border-color: var(--green); color: var(--green-deep); }
body.sheet-open { overflow: hidden; }
.sheet[hidden] { display: none; }
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(32,40,31,.35); animation: sheetFade .2s ease; }
.sheet-body {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  box-shadow: 0 -12px 40px -16px rgba(32,40,31,.4);
  animation: sheetUp .26s cubic-bezier(.22,.75,.3,1);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-family: 'Baloo 2','Zen Maru Gothic',sans-serif; font-size: 18px; font-weight: 700; }
.sheet-note { margin: 14px 0 0; font-size: 12.5px; color: #8a7f6b; text-align: center; }
.sheet-note a { color: var(--green-deep); text-underline-offset: 3px; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetFade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 560px) {
  .sheet { align-items: center; }
  .sheet-body { border-radius: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet-body, .sheet-backdrop { animation: none; }
}

/* ドラッグ中：表面でも、判定する側の色がにじむ */
.flashcard.lean-known .face-front { border-color: #9fbf94; box-shadow: var(--shadow), inset 0 0 0 3px rgba(76,122,94,.18); }
.flashcard.lean-review .face-front { border-color: #e2b9a2; box-shadow: var(--shadow), inset 0 0 0 3px rgba(198,91,63,.14); }
#view-study .flashcard { cursor: grab; }
#view-study .flashcard:active { cursor: grabbing; }

/* ---------- 学習のしかた（めくる／タイプ） ---------- */
.study-mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 14px;
}
.mode-hint { margin: 0; font-size: 12.5px; color: #7a6f5c; }
.segmented-wide span { padding: 8px 22px; }
.segmented.is-off { opacity: .45; }
.segmented.is-off label { cursor: default; }

/* ---------- タイプ ---------- */
.type-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 20px 22px;
  background: var(--card);
  border: 1.5px solid var(--muted);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}
.type-pane[hidden] { display: none; }
.type-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 22px;
}
.type-combo {
  font-family: 'Baloo 2', 'Zen Maru Gothic', sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: var(--orange-deep);
}
.type-again {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--danger);
  background: #fbeae5;
  padding: 3px 10px;
  border-radius: 999px;
}
.type-question {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 800;
  font-size: 24px;
  line-height: 1.45;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.type-slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px; /* 語と語のあいだ */
  max-width: 100%;
  min-height: 40px;
}
.type-slots .slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 36px;
  border-bottom: 3px solid var(--muted-2);
  font-family: 'Baloo 2', ui-monospace, monospace;
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  transition: border-color .12s ease, transform .12s ease;
}
.type-slots .slot.ok { border-bottom-color: var(--green); color: var(--green-deep); }
.type-slots .slot.ng { border-bottom-color: var(--danger); color: var(--danger); }
.type-slots .slot.ghost { color: #c9bda3; }
.type-slots .slot-word { display: inline-flex; gap: 4px; white-space: nowrap; }
.type-slots .mark {
  display: inline-flex;
  align-items: flex-end;
  height: 36px;
  font-family: 'Baloo 2', ui-monospace, monospace;
  font-weight: 800;
  font-size: 22px;
  color: #a79c88;
}
/* マスに直接打つ：入力欄はマスの上に透明に重ねる（タップするとキーボードが出る） */
.type-board {
  position: relative;
  display: block;
  width: 100%;
  padding: 10px 4px;
  border-radius: 14px;
  cursor: text;
}
.type-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  font-size: 16px; /* 16px 以上で iPhone が拡大しない */
  color: transparent;
  caret-color: transparent;
  background: transparent;
  cursor: text;
}
.type-slots .slot.cursor { border-bottom-color: var(--muted-2); }
.type-board:focus-within .type-slots .slot.cursor {
  border-bottom-color: var(--orange);
  animation: type-blink 1s steps(1) infinite;
}
@keyframes type-blink { 50% { border-bottom-color: transparent; } }
.type-slots .slot.ng { animation: type-pop .38s ease; }
@keyframes type-pop { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }
.type-pane.is-done .type-slots .slot { transform: translateY(-2px); }
.type-pane.is-wrong .type-board { animation: type-shake .28s ease; }
@keyframes type-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.type-feedback { min-height: 22px; font-size: 15px; font-weight: 700; }
.type-feedback.good { color: var(--green-deep); }
.type-feedback.soft { color: var(--orange-deep); }
.type-note {
  width: 100%;
  max-height: 120px;
  overflow-y: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  text-align: left;
  white-space: pre-line;
  color: #5a5347;
}
.type-actions { display: flex; gap: 10px; }
.type-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--muted);
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: #7a6f5c;
  cursor: pointer;
}
.type-btn:hover { border-color: var(--orange); color: var(--orange-deep); }
.result-extra { text-align: center; margin: -12px 0 20px; font-weight: 700; color: var(--orange-deep); }
@media (prefers-reduced-motion: reduce) {
  .type-pane.is-wrong .type-board,
  .type-slots .slot.ng,
  .type-board:focus-within .type-slots .slot.cursor { animation: none; }
}
