:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-strong: #f0f3ef;
  --text: #17201b;
  --muted: #65706a;
  --line: #d9dfd9;
  --accent: #176b5c;
  --accent-strong: #0f4f45;
  --accent-soft: #dceee8;
  --warn: #a76118;
  --focus: #2457c5;
  --shadow: 0 18px 50px rgba(20, 31, 27, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  /* iOS でのテキスト自動拡大やタップ時のグレーのちらつきを防ぐ */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh; /* モバイルのアドレスバー分の高さズレを防ぐ（未対応環境は上の100vh） */
  overflow-x: hidden; /* 横スクロールの発生を防ぐ */
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 22px;
  font-size: 0.85rem;
}

.app-footer a {
  color: var(--muted);
  font-weight: 750;
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}

.topbar,
.section-heading,
.action-row,
.control-strip {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar-actions,
.view-tabs,
.practice-actions {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.brand-tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.brand-button:hover {
  color: var(--accent-strong);
}

.view-tabs {
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.view-tabs button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.view-tabs button:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.view-tabs button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-wrap {
  position: relative;
  display: flex;
}

.auth-wrap > #authToggleButton {
  width: 100%;
}

.auth-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: min(300px, 84vw);
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(20, 31, 27, 0.18);
}

.account-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-email {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  word-break: break-all;
}

.account-menu .ghost-button {
  width: 100%;
}

.auth-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
}

/* display 指定は hidden 属性より優先されるため、明示的に打ち消す。 */
.account-menu[hidden],
.auth-form[hidden] {
  display: none;
}

.auth-form .action-row {
  margin: 0;
  gap: 8px;
}

.auth-form .action-row .primary-button,
.auth-form .action-row .ghost-button {
  flex: 1;
}

#authStatus {
  margin: 8px 0 0;
}

.topbar h1,
.section-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 2rem;
  line-height: 1.05;
}

.section-heading h2 {
  font-size: 1.05rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.save-state {
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.api-status {
  min-height: 1.3em;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.workspace.is-practice-only {
  grid-template-columns: minmax(0, 1fr);
}

.workspace.is-source-collapsed {
  grid-template-columns: 52px minmax(0, 1fr);
}

.setup-panel,
.practice-panel,
.library-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.setup-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.setup-panel.is-collapsed {
  position: sticky;
  top: 18px;
  display: flex;
  justify-content: flex-start;
  min-height: 180px;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.setup-panel.is-collapsed .section-heading {
  flex-direction: column;
  justify-content: flex-start;
  margin: 0;
}

.setup-panel.is-collapsed .section-heading > div,
.setup-panel.is-collapsed #sampleButton {
  display: none;
}

.practice-panel {
  min-width: 0;
  padding: 18px;
}

.practice-player-sticky {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -18px;
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(20, 31, 27, 0.06);
}

.workspace.is-practice-only .practice-panel {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

.library-panel {
  padding: 18px;
}

.library-panel[hidden],
.workspace[hidden],
.setup-panel[hidden],
.practice-form[hidden],
.selected-source[hidden],
.mini-hero[hidden],
.speed-menu[hidden] {
  display: none;
}

.section-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.source-toggle-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  font-weight: 850;
}

.setup-panel.is-collapsed .source-toggle-button {
  writing-mode: vertical-rl;
  min-width: 44px;
  min-height: 132px;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: #e9f3ee;
  box-shadow: -4px 8px 18px rgba(20, 31, 27, 0.08);
  padding: 12px 6px;
  letter-spacing: 0;
}

.practice-form,
.field {
  display: grid;
  gap: 10px;
}

.practice-form {
  gap: 14px;
}

.form-grid,
.single-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.single-grid {
  grid-template-columns: 1fr;
}

.field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  outline: none;
  font-size: 16px; /* iOS で入力時に画面が拡大されるのを防ぐ（16px未満だと拡大される） */
}

input {
  min-height: 44px;
  padding: 0 12px;
}

select {
  min-height: 44px;
  padding: 0 36px 0 12px;
}

textarea {
  min-height: 144px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(36, 87, 197, 0.14);
}

.primary-button,
.ghost-button,
.text-button,
.icon-button,
.segmented-control button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}

.primary-button {
  flex: 1;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.text-button {
  padding: 0 13px;
}

.ghost-button:hover,
.text-button:hover,
.icon-button:hover,
.segmented-control button:hover {
  border-color: #aab6ae;
  background: var(--surface-strong);
}

.action-row {
  gap: 10px;
}

.practice-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.practice-status {
  margin-bottom: 12px;
}

.practice-status:empty {
  display: none;
}

.selected-source {
  display: grid;
  gap: 10px;
}

.selected-source-label,
.selected-source h3,
.selected-source p {
  margin: 0;
}

.selected-source-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.selected-source h3 {
  font-size: 1rem;
  line-height: 1.35;
}

#selectedSourceMeta,
#selectedSourceStatus {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.library-heading {
  align-items: flex-start;
}

.library-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 12px;
  margin-bottom: 16px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.video-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.video-card:hover {
  border-color: #aab6ae;
  box-shadow: 0 12px 30px rgba(20, 31, 27, 0.08);
}

.video-card-thumb {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #17201b;
}

.video-card-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.duration-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(16, 24, 21, 0.86);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.video-card-body {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.video-card-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.28;
}

.video-card-meta,
.video-card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip,
.difficulty-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.difficulty-chip {
  border-color: var(--accent-soft);
  color: var(--accent-strong);
}

.transcript-base-chip {
  border-color: #b8c8bf;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.video-card-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 0 12px 12px;
}

.video-card-action {
  margin: 0;
}

.card-menu {
  position: relative;
}

.card-menu summary {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 850;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

.card-menu summary::-webkit-details-marker {
  display: none;
}

.card-menu summary:hover {
  border-color: #aab6ae;
  background: var(--surface-strong);
}

.card-menu-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 5;
  display: grid;
  gap: 6px;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(20, 31, 27, 0.14);
}

.card-menu-panel button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: left;
}

.card-menu-panel button:hover {
  background: var(--surface-strong);
}

.card-menu-panel .danger-menu-item {
  color: #a33a2b;
}

.tag-menu-screen {
  display: grid;
  gap: 6px;
}

.tag-menu-screen[hidden] {
  display: none;
}

.tag-menu-back {
  color: var(--muted);
}

.tag-menu-section {
  display: grid;
  gap: 8px;
  padding: 4px 0;
}

.tag-menu-section + .tag-menu-section {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.tag-add-form label {
  display: grid;
  gap: 5px;
}

.tag-add-form span,
.tag-menu-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.tag-delete-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-delete-button {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 850;
}

.tag-delete-button:hover {
  border-color: #e2b8b2;
  background: #fff4f2;
  color: #a33a2b;
}

.tag-editor-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.tag-add-form input {
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.tag-add-form button {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
}

.danger-button {
  border-color: #e2b8b2;
  color: #a33a2b;
}

.danger-button:hover {
  border-color: #cf8d84;
  background: #fff4f2;
}

.library-empty {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 48px 20px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.library-empty-title {
  margin: 0;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 800;
}

.library-empty-desc {
  margin: 0;
  max-width: 42ch;
  font-size: 0.9rem;
  line-height: 1.6;
}

.library-empty #libraryEmptyCreateButton {
  margin-top: 6px;
}

.mini-hero {
  position: relative;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 18px 44px 18px 18px;
  border: 1px solid var(--accent-soft);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
}

.mini-hero-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

.mini-hero-close:hover {
  background: rgba(23, 32, 27, 0.08);
  color: var(--text);
}

.mini-hero-eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.mini-hero-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.4;
}

.mini-hero-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
  color: var(--text);
}

.mini-hero-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-hero-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}

.form-step {
  display: grid;
  gap: 10px;
}

.form-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
}

.form-step-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--muted);
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.segmented-control button {
  min-height: 34px;
  border-color: transparent;
}

.segmented-control .is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.media-stage {
  position: relative;
  overflow: hidden;
  width: min(100%, 360px);
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  border: 1px solid #cdd6cf;
  border-radius: 8px;
  background: #101815;
}

.media-stage iframe,
.player-mount {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-mount {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.media-empty {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 18px;
  place-items: center;
  color: #e7eee9;
  text-align: center;
}

.media-loading {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.media-link {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 12px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(16, 24, 21, 0.78);
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 850;
  text-decoration: none;
}

.media-link:hover {
  background: rgba(16, 24, 21, 0.92);
}

.control-strip {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.icon-button {
  width: 48px;
  min-width: 48px;
  padding: 0 4px;
}

.jump-button {
  width: 62px;
  min-width: 62px;
}

.speed-control {
  position: relative;
  display: inline-flex;
}

.speed-control #speedButton {
  width: 56px;
  min-width: 56px;
  font-variant-numeric: tabular-nums;
}

.speed-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: max-content;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(20, 31, 27, 0.18);
}

.speed-menu button {
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 750;
  text-align: center;
}

.speed-menu button:hover {
  background: var(--surface-strong);
}

.time-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.time-readout {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
}

.progress {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  accent-color: var(--accent);
}

/* 再生位置バーを ^ / v で出し入れするトグル。展開時は今までと同じ高さに収まる。 */
.progress-toggle {
  flex: 0 0 auto;
  height: 20px;
  min-width: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.progress-toggle:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.progress-toggle-compact {
  display: none;
}

/* 格納時: 再生位置バー行ごと隠し、時間表示の右横の「v」ボタンで戻せるようにする */
.practice-player-sticky.is-collapsed .progress-wrap {
  display: none;
}

.practice-player-sticky.is-collapsed .progress-toggle-compact {
  display: inline-flex;
}

.segment-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-right: 4px;
}

.segment-item {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  text-align: left;
}

.segment-empty {
  padding: 22px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.segment-item.is-active {
  border-color: var(--accent);
  background: #f3fbf7;
}

.segment-item.is-premium-locked {
  opacity: 0.6;
  background: repeating-linear-gradient(
    -45deg,
    #f4f5f3,
    #f4f5f3 8px,
    #eef0ed 8px,
    #eef0ed 16px
  );
  cursor: not-allowed;
}

.segment-item.is-premium-locked .script-text {
  filter: blur(2.5px);
  user-select: none;
}

.segment-lock {
  color: var(--accent-strong, #0f4f45);
  font-weight: 850;
}

.segment-premium-note {
  margin: 4px 2px 0;
  padding: 12px 14px;
  border: 1px dashed var(--accent, #176b5c);
  border-radius: 8px;
  background: #f3faf7;
  color: var(--accent-strong, #0f4f45);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

.segment-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.script-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.script-text {
  min-width: 0;
  margin: 0;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.script-text.en {
  font-size: 1rem;
  font-weight: 800;
}

.word-token {
  color: #8a948e;
}

.word-token.is-read {
  color: var(--text);
}

.script-text.ja {
  color: #39433d;
}

.status-warn {
  color: var(--warn);
}

.info-section {
  max-width: 760px;
  margin: 40px auto 0;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.info-section h2 {
  margin: 0 0 12px;
  font-size: 1.3rem;
  color: var(--accent-strong);
}

.info-section p {
  margin: 0 0 12px;
  color: var(--text);
  line-height: 1.75;
}

.howto-steps {
  counter-reset: howto-step;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

.howto-steps li {
  position: relative;
  padding: 4px 0 4px 44px;
}

.howto-steps li::before {
  counter-increment: howto-step;
  content: counter(howto-step);
  position: absolute;
  left: 0;
  top: 2px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  font-size: 0.9rem;
}

.howto-steps h3 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  color: var(--text);
}

.howto-steps p {
  margin: 0;
  color: var(--muted);
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-list details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}

.faq-list summary {
  cursor: pointer;
  font-weight: 750;
  color: var(--text);
}

.faq-list summary:hover {
  color: var(--accent);
}

.faq-list details p {
  margin: 10px 0 0;
  color: var(--muted);
}

.faq-list details a {
  color: var(--accent);
}

@media (max-width: 960px) {
  .app-shell {
    padding: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setup-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  body {
    background: var(--surface);
  }

  .app-shell {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }

  .topbar-actions,
  .view-tabs,
  .practice-actions {
    width: 100%;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .account-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .view-tabs button {
    padding: 0 4px;
    font-size: 0.78rem;
  }

  .save-state {
    width: 100%;
    min-height: 38px;
  }

  .setup-panel,
  .practice-panel {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 14px 0;
  }

  .practice-player-sticky {
    top: 0;
    margin: 0 -12px;
    padding: 10px 12px 8px;
    border-radius: 0;
  }

  .section-heading {
    align-items: flex-start;
    gap: 10px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  input,
  textarea,
  .primary-button,
  .ghost-button,
  .text-button,
  .icon-button {
    min-height: 46px;
  }

  textarea {
    min-height: 118px;
  }

  .media-stage {
    width: 100%; /* スマホでは動画を画面幅いっぱいに大きく表示 */
    border-radius: 8px;
    transition: width 0.22s ease;
  }

  /* スクロールすると動画を小さくして、トランスクリプトを見やすくする（スマホのみ） */
  .practice-player-sticky.is-scrolled .media-stage {
    width: 58%;
  }

  .form-grid,
  .single-grid,
  .library-filters {
    grid-template-columns: 1fr;
  }

  /* スマホでも英語(左)と和訳(右)を横並びにして同時に見られるようにする */
  .script-pair {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
  }

  .script-pair .script-text.en {
    font-size: 0.95rem;
  }

  .script-pair .script-text.ja {
    font-size: 0.9rem;
  }

  .library-grid {
    grid-template-columns: 1fr;
  }

  .segment-list {
    max-height: none;
  }

  .topbar h1 {
    font-size: 1.55rem;
  }

  .control-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .icon-button,
  .jump-button {
    width: auto;
    min-width: 0;
  }

  .speed-control,
  .speed-control #speedButton {
    width: 100%;
    min-width: 0;
  }

  .time-row {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
    justify-content: center;
  }

  /* スマホでスクロールしてトランスクリプトを見ている間だけ、再生ボタンを
     丸い浮動ボタンにして画面下中央に固定し、トランスクリプトの上に重ねる
     （片手操作しやすくするため）。スクロール前は通常どおりの並びのまま。 */
  .practice-player-sticky.is-scrolled .control-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .practice-player-sticky.is-scrolled #playButton {
    position: fixed;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 50;
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 10px 28px rgba(20, 31, 27, 0.35);
  }

  /* 浮動ボタンの下に最後の区間が隠れないよう余白を確保する。 */
  .practice-player-sticky.is-scrolled ~ .segment-list {
    padding-bottom: 88px;
  }

  .progress-wrap {
    margin: 10px 0 12px;
  }

  .progress {
    height: 34px;
  }

  .script-text.en {
    font-size: 1.04rem;
  }

  .segment-list {
    gap: 8px;
    padding-right: 0;
  }

  .segment-item {
    padding: 12px;
  }
}
