/* 故事工具栏：语言切换 + 朗读同一行 */
.story-lang {
  --sl-accent: #ff522b;
  --sl-accent-rgb: 255, 82, 43;
  --sl-ink: #1f2937;
  --sl-muted: #6b7280;
  --sl-line: rgba(17, 24, 39, .08);
  --sl-soft: #f3f4f6;
  margin: 0 0 .85rem;
}

.story-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: .65rem .75rem;
  margin: 0 0 .85rem;
  min-height: 2.25rem;
}

.story-toolbar.is-tts-open {
  flex-wrap: wrap;
}

.story-lang-seg {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 3px;
  border-radius: 999px;
  background: var(--sl-soft);
  border: 1px solid var(--sl-line);
  gap: 2px;
}

.story-toolbar-tts {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
}

.story-toolbar-tts .story-tts-entry {
  align-items: flex-end;
}

.story-toolbar-tts .story-tts-menu {
  left: auto;
  right: 0;
}

.story-toolbar-tts .story-tts {
  margin: 0;
  width: auto;
  max-width: 100%;
}

/* 播放/合成中：播放条占满下一行 */
.story-toolbar.is-tts-open .story-toolbar-tts {
  flex: 1 1 100%;
  width: 100%;
  margin-left: 0;
  order: 2;
}

.story-toolbar.is-tts-open .story-lang-seg {
  order: 1;
}

.story-toolbar.is-tts-open .story-toolbar-tts .story-tts {
  width: 100%;
}

.story-toolbar.is-tts-open .story-tts-panel {
  width: 100%;
}

.story-lang-tab {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--sl-muted);
  font: inherit;
  font-size: .8125rem;
  font-weight: 650;
  line-height: 1;
  min-height: 1.85rem;
  padding: 0 .9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
  -webkit-tap-highlight-color: transparent;
}

.story-lang-tab .sl-label-short {
  display: none;
}

.story-lang-tab:hover {
  color: var(--sl-ink);
}

.story-lang-tab.is-active {
  background: #fff;
  color: var(--sl-ink);
  box-shadow: 0 1px 2px rgba(17, 24, 39, .08);
}

.story-lang-tab:focus-visible {
  outline: 2px solid rgba(var(--sl-accent-rgb), .4);
  outline-offset: 2px;
}

.story-lang-panel {
  display: none;
  animation: story-lang-in .22s ease;
}

.story-lang-panel.is-active {
  display: block;
}

.story-lang-panel[hidden] {
  display: none !important;
}

.story-en-body {
  line-height: 1.75;
  color: var(--sl-ink);
  font-size: 1rem;
}

.story-lang-gate {
  text-align: center;
  padding: 1.35rem 1rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #fafafa, #f3f4f6);
  border: 1px dashed rgba(17, 24, 39, .12);
}

.story-lang-gate-title {
  margin: 0 0 .35rem;
  font-size: .9375rem;
  font-weight: 700;
  color: var(--sl-ink);
}

.story-lang-gate-desc {
  margin: 0 0 .9rem;
  font-size: .8125rem;
  color: var(--sl-muted);
}

.story-lang-gate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.1rem;
  padding: 0 1.1rem;
  border-radius: 999px;
  background: var(--sl-accent);
  color: #fff !important;
  font-size: .8125rem;
  font-weight: 700;
  text-decoration: none !important;
  transition: filter .15s ease;
}

.story-lang-gate-btn:hover {
  filter: brightness(1.05);
  color: #fff !important;
}

@keyframes story-lang-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.nice-dark-mode .story-lang {
  --sl-ink: #f3f4f6;
  --sl-muted: #9ca3af;
  --sl-line: rgba(255, 255, 255, .1);
  --sl-soft: rgba(255, 255, 255, .06);
}

.nice-dark-mode .story-lang-tab.is-active {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.nice-dark-mode .story-lang-gate {
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .12);
}

/* —— 移动端：同排紧凑，标签缩短 —— */
@media (max-width: 575.98px) {
  .story-toolbar {
    gap: .5rem;
    margin-bottom: .7rem;
    min-height: 2.4rem;
  }

  .story-lang-tab {
    min-height: 2rem;
    padding: 0 .7rem;
    font-size: .75rem;
  }

  .story-lang-tab .sl-label-long {
    display: none;
  }

  .story-lang-tab .sl-label-short {
    display: inline;
  }

  /* 移动端朗读按钮更短：隐藏文案只留图标+短字，由 tts css 配合 */
  .story-toolbar-tts .story-tts-start {
    min-height: 2rem;
    padding: .32rem .75rem .32rem .65rem;
    font-size: .75rem;
  }

  .story-lang-gate {
    padding: 1.1rem .85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-lang-panel,
  .story-lang-tab {
    animation: none !important;
    transition: none !important;
  }
}
