/* */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* */

/* */
:root,
:root[data-theme="paper"] {
  --bg: #ffffff;
  --text: #333333;
  --muted: #666666;
  --border: #e0e0e0;
  --elev: #fafafa;
  --primary: #8B6914;
  --toolbar-bg: linear-gradient(120deg, rgba(255, 255, 255, 0.94), rgba(139, 105, 20, 0.08));
  --toolbar-border: rgba(139, 105, 20, 0.16);
  --toolbar-shadow: 0 10px 24px rgba(139, 105, 20, 0.09);
  --toolbar-chip-bg: rgba(255, 255, 255, 0.88);
  --toolbar-chip-border: rgba(139, 105, 20, 0.15);
  --toolbar-chip-hover: rgba(139, 105, 20, 0.12);
  --toolbar-chip-neutral: rgba(255, 255, 255, 0.92);
  --toolbar-chip-neutral-border: rgba(139, 105, 20, 0.16);
  --header-shadow-strong: rgba(180, 150, 80, 0.13);
  --header-shadow-soft: rgba(120, 100, 40, 0.08);
}

:root[data-theme="sakura"] {
  --bg: #fff6f9;
  --text: #4e2b36;
  --muted: #8f5b6a;
  --border: #f3d3e0;
  --elev: #ffeeF5;
  --primary: #d97ea8;
  --toolbar-bg: linear-gradient(135deg, rgba(255, 241, 248, 0.95), rgba(217, 126, 168, 0.22));
  --toolbar-border: rgba(217, 126, 168, 0.32);
  --toolbar-shadow: 0 14px 32px rgba(217, 126, 168, 0.18);
  --toolbar-chip-bg: rgba(255, 239, 246, 0.9);
  --toolbar-chip-border: rgba(217, 126, 168, 0.25);
  --toolbar-chip-hover: rgba(217, 126, 168, 0.16);
  --toolbar-chip-neutral: rgba(255, 245, 249, 0.94);
  --toolbar-chip-neutral-border: rgba(217, 126, 168, 0.22);
  --header-shadow-strong: rgba(217, 126, 168, 0.18);
  --header-shadow-soft: rgba(217, 126, 168, 0.1);
}

:root[data-theme="sticky"] {
  --bg: #fbf1dc;
  --text: #463828;
  --muted: #8a7153;
  --border: #ead5b2;
  --elev: #fef7e6;
  --primary: #c58b3b;
  --toolbar-bg: linear-gradient(135deg, rgba(255, 245, 225, 0.96), rgba(197, 139, 59, 0.24));
  --toolbar-border: rgba(197, 139, 59, 0.32);
  --toolbar-shadow: 0 14px 32px rgba(197, 139, 59, 0.18);
  --toolbar-chip-bg: rgba(253, 244, 223, 0.9);
  --toolbar-chip-border: rgba(197, 139, 59, 0.24);
  --toolbar-chip-hover: rgba(197, 139, 59, 0.16);
  --toolbar-chip-neutral: rgba(254, 246, 229, 0.96);
  --toolbar-chip-neutral-border: rgba(197, 139, 59, 0.22);
  --header-shadow-strong: rgba(197, 139, 59, 0.18);
  --header-shadow-soft: rgba(197, 139, 59, 0.12);
}

:root[data-theme="green"] {
  --bg: #f1f7f2;
  --text: #294235;
  --muted: #5d7666;
  --border: #d1e4d7;
  --elev: #f7fbf6;
  --primary: #4aa96d;
  --toolbar-bg: linear-gradient(135deg, rgba(236, 249, 240, 0.96), rgba(74, 169, 109, 0.2));
  --toolbar-border: rgba(74, 169, 109, 0.26);
  --toolbar-shadow: 0 14px 34px rgba(74, 169, 109, 0.16);
  --toolbar-chip-bg: rgba(237, 248, 240, 0.9);
  --toolbar-chip-border: rgba(74, 169, 109, 0.23);
  --toolbar-chip-hover: rgba(74, 169, 109, 0.15);
  --toolbar-chip-neutral: rgba(244, 252, 246, 0.96);
  --toolbar-chip-neutral-border: rgba(74, 169, 109, 0.2);
  --header-shadow-strong: rgba(74, 169, 109, 0.16);
  --header-shadow-soft: rgba(74, 169, 109, 0.1);
}

:root[data-theme="blue"] {
  --bg: #f0f6ff;
  --text: #1f3658;
  --muted: #546784;
  --border: #c6d9f2;
  --elev: #f6f9ff;
  --primary: #5188dd;
  --toolbar-bg: linear-gradient(135deg, rgba(240, 248, 255, 0.96), rgba(81, 136, 221, 0.2));
  --toolbar-border: rgba(81, 136, 221, 0.28);
  --toolbar-shadow: 0 14px 32px rgba(81, 136, 221, 0.16);
  --toolbar-chip-bg: rgba(237, 245, 255, 0.9);
  --toolbar-chip-border: rgba(81, 136, 221, 0.24);
  --toolbar-chip-hover: rgba(81, 136, 221, 0.14);
  --toolbar-chip-neutral: rgba(244, 249, 255, 0.96);
  --toolbar-chip-neutral-border: rgba(81, 136, 221, 0.2);
  --header-shadow-strong: rgba(81, 136, 221, 0.18);
  --header-shadow-soft: rgba(81, 136, 221, 0.1);
}

:root[data-theme="dark"] {
  --bg: #16181d;         /* 深炭黑底色 */
  --text: #e7eaf0;       /* 稍亮的正文色 */
  --muted: #a6aebb;      /* 次级文字 */
  --border: #2c323d;     /* 低对比边框 */
  --elev: #1e2229;       /* 提升层（卡片/面板） */
  --primary: #d9b35a;    /* 暖金主色 */
  --toolbar-bg: linear-gradient(120deg, rgba(217, 179, 90, 0.1), rgba(16, 19, 26, 0.96));
  --toolbar-border: rgba(217, 179, 90, 0.22);
  --toolbar-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  --toolbar-chip-bg: rgba(36, 42, 52, 0.92);
  --toolbar-chip-border: rgba(217, 179, 90, 0.24);
  --toolbar-chip-hover: rgba(217, 179, 90, 0.2);
  --toolbar-chip-neutral: rgba(30, 36, 46, 0.94);
  --toolbar-chip-neutral-border: rgba(217, 179, 90, 0.24);
  --header-shadow-strong: rgba(0, 0, 0, 0.55);
  --header-shadow-soft: rgba(0, 0, 0, 0.35);
}

/* */
:root,
:root[data-theme="paper"] {
  --scroll-track: rgba(0,0,0,0.06);      /* 轻浅轨道 */
  --scroll-thumb: rgba(0,0,0,0.28);      /* 默认拇指 */
  --scroll-thumb-hover: rgba(0,0,0,0.38);/* 悬停拇指 */
}
:root[data-theme="sakura"] {
  --scroll-track: rgba(217,126,168,0.12);
  --scroll-thumb: rgba(217,126,168,0.34);
  --scroll-thumb-hover: rgba(217,126,168,0.44);
}
:root[data-theme="sticky"] {
  --scroll-track: rgba(197,139,59,0.12);
  --scroll-thumb: rgba(197,139,59,0.32);
  --scroll-thumb-hover: rgba(197,139,59,0.42);
}
:root[data-theme="green"] {
  --scroll-track: rgba(74,169,109,0.12);
  --scroll-thumb: rgba(74,169,109,0.3);
  --scroll-thumb-hover: rgba(74,169,109,0.42);
}
:root[data-theme="blue"] {
  --scroll-track: rgba(81,136,221,0.12);
  --scroll-thumb: rgba(81,136,221,0.32);
  --scroll-thumb-hover: rgba(81,136,221,0.44);
}
:root[data-theme="dark"] {
  --scroll-track: rgba(255,255,255,0.06);
  --scroll-thumb: rgba(255,255,255,0.26);
  --scroll-thumb-hover: rgba(255,255,255,0.36);
}

/* */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }

/* */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background-color: var(--scroll-thumb);
  border-radius: 999px;
  border: 3px solid transparent;        /* 让拇指更细，露出透明轨道 */
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
*::-webkit-scrollbar-corner { background: transparent; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* */
:root[data-theme="dark"] body {
  background: var(--bg);
}

/* */
.header {
  display: none;
}

.header-content {
  display: none;
}

.header-left {
  display: none;
}

.logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.logo-text {
  color: var(--text);
}

.logo-icon {
  width: 36px;
  height: auto;
  display: inline-block;
}

/* */
/* */

/* */

.nav-menu {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav-item {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 2px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--elevated);
  color: var(--text);
}

/* */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 20px;
  border-radius: 15px;
  position: relative;
  transition: all 0.3s ease;
  background-color: #000;
  /* border: 2px solid #ddd; */
  overflow: hidden;
}

:root[data-theme="dark"] .theme-toggle {
  background-color: #fff;
}

.theme-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-icon {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.3s ease;
  left: 1px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* */
[data-theme="dark"] .theme-toggle .theme-icon {
  left: 25px;
  background: #2c2c2c;
  color: white;
}

/* */
.theme-toggle:hover .theme-icon {
  transform: rotate(180deg);
}

/* */
.nav-lang {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  /* margin-left: 8px; */
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.lang-flag {
  line-height: 1;
  background: none;
  color: var(--text);
  /* border-radius: 4px; */
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border: 1px solid #a6a6a6;
}

.lang-flag:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

.lang-flag.active {
  border-color: var(--primary);
}

.flag-icon {
  width: 20px;
  height: 14px;
  display: block;
}

/* */
.nav-lang .lang-flag { display: none; }

/* */
.lang-dropdown { display: inline-flex; position: relative; }
.lang-dropdown-btn {
  line-height: 1;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border: 1px solid #a6a6a6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.lang-dropdown-btn:hover { transform: translateY(-1px); opacity: 0.9; }
.lang-dropdown.open .lang-dropdown-btn { border-color: var(--primary); }

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  padding: 6px;
  display: none;
  min-width: 160px;
  z-index: 1200;
}
.lang-dropdown.open .lang-dropdown-menu { display: block; }

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background 0.2s ease;
}
.lang-option .flag-icon {
  border: 1px solid #a6a6a6;
}
.lang-option:hover { background: var(--elevated); }
.lang-name { font-size: 13px; }

:root[data-theme="dark"] .lang-dropdown-menu {
  background: rgba(255,255,255,0.06);
  border-color: var(--control-border);
}
:root[data-theme="dark"] .lang-option:hover { background: rgba(255,255,255,0.08); }

/* */

/* */
.main-container {
  display: grid;
  grid-template-columns: 240px 1fr; /* 左侧导航240px / 内容区占满剩余空间 */
  gap: 0;
  box-shadow: 0 10px 30px var(--border);
  height: 100vh; /* 去掉 header 后，使用完整视口高度 */
  /* overflow: hidden; */
  transition: grid-template-columns 0.3s ease;
}

/* */
.main-container.collapsed {
  grid-template-columns: 1fr;
}

/* */
.sidebar-stack {
  background: var(--bg);
  position: relative;
  /* overflow: hidden; */
  border-right: 1px solid var(--border);
  /* display: flex; */
  /* flex-direction: column; */
  height: 100vh;
  z-index: 1; /* PC端保持低z-index */
  width: 240px;
  padding-top: 44px; /* 为固定的 editor-toolbar 留出空间 */
}

.collapsed .sidebar-stack {
  left: -240px;
  height: 0;
}

/* */
.folder-management {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: visible; /* 允许子菜单溢出显示 */
}

/* */
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  /* height: 91.5vh; */
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 8px;
  opacity: 0.6;
}
/* */
.list-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: none;
  background: transparent;
  padding-top: 10px;
}


/* */
.sidebar-toggle-btn {
  position: absolute;
  top: 12px;
  right: -12px;
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  background: #6B5B00;
  transform: scale(1.1);
}

.sidebar-toggle-btn .toggle-icon {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}



/* */
.content-main {
  height: 100vh; /* 去掉 header 后，使用完整视口高度 */
  min-height: 0;
  overflow-y: auto;
  padding-top: 0;
  position: relative;
}

.content-container { 
  height: 100%; 
  padding-top: 40px; /* 为固定的 editor-toolbar 留出空间 */
}

.collapsed .content-container {
  padding-top: 0;
}

/* */
.resizer {
  height: 12px;
  background: var(--border);
  cursor: row-resize;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
  margin: 0;
  z-index: 10;
  /* */
  padding: 4px 0;
  /* margin: -4px 0; */
}

/* */
.resizer::after {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  bottom: -8px;
  cursor: row-resize;
  z-index: 1;
}

.resizer:hover {
  background: var(--primary);
}

.resizer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--muted);
  opacity: 0.6;
  pointer-events: none;
  z-index: 2;
}

.resizer:hover::before {
  background: var(--bg);
  opacity: 1;
}

.resizer.resizing {
  background: var(--primary);
}

.resizer.resizing::after {
  top: -100vh;
  bottom: -100vh;
}

/* */
.main-container.two-pane .resizer {
  display: none;
}

/* */
.main-container.two-pane #editorPanels{display:flex;gap:12px;align-items:stretch}
.main-container.two-pane #editorPanels .input-section{flex:1 1 50%;max-width:50%;display:flex;flex-direction:column}
.main-container.two-pane #editorPanels .content-area{flex:1 1 50%;max-width:50%;display:flex;flex-direction:column;overflow-y:auto;}
.main-container.two-pane #editorPanels{height:calc(100vh - 44px)}
.main-container.two-pane #editorPanels .input-section{overflow:visible; margin: 0 10px 10px 10px;}
.main-container.two-pane #editorPanels .content-area{overflow-y:auto;}
.main-container.two-pane .input-section .editor{flex:1 1 auto}
.main-container.two-pane .content-area .content{flex:1 1 auto}
.main-container.two-pane .input-section {
  margin: 0 10px;
}
.main-container.two-pane .content-main {
  overflow: hidden;
}
.main-container.two-pane #textInput {
  height: calc(100vh - 125px);
}

/* */
.main-container.two-pane .input-section .input-group {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 44px - 60px); /* 减去工具栏和播放控制栏高度 */
}

/* */
.main-container.two-pane .content-area .play-control-bar {
  flex: 0 0 auto;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0 0 2px 0;
  /* border-bottom: 1px solid var(--border); */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* */
.main-container.two-pane .input-section .EasyMDEContainer .editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--elev);
}
@media (max-width: 900px){
  .main-container.two-pane #editorPanels{
    display:flex;
    flex-direction:column;
  }
  .main-container.two-pane #editorPanels .input-section,
  .main-container.two-pane #editorPanels .content-area{
    max-width:100%;
    flex:1 1 auto;
    min-height:calc(100vh - 44px);
  }
  .main-container.two-pane #editorPanels{height:auto}
  .main-container.two-pane #editorPanels .input-section{
    overflow:visible;
  }
  .main-container.two-pane #editorPanels .content-area{
    overflow-y:auto;
  }
}


/* */
.sidebar-content {
  padding: 0 12px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* */
.folder-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  height: 27px;
  margin-bottom: 2px;
}

.folder-title-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.folder-title-row .theme-icon-btn,
.folder-title-row .btn-sort {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: background 20ms ease-in;
  color: var(--muted);
  flex-shrink: 0;
}

.folder-title-row .theme-icon-btn:hover,
.folder-title-row .btn-sort:hover {
  background: var(--elev);
  color: var(--text);
}

.folder-title-row .theme-icon-btn svg,
.folder-title-row .btn-sort svg {
  width: 16px;
  height: 16px;
}

.folder-collapse-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--control-border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.folder-collapse-btn svg {
  transition: transform 0.2s ease;
  transform: rotate(0deg); /* 默认向左箭头 */
}

/* */
.main-container.collapsed .folder-collapse-btn svg {
  transform: rotate(180deg);
}

.folder-collapse-btn:hover {
  background: var(--elevated);
}


/* */
.doc-list-toolbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 2;
  height: 32px;
}

/* */
.doc-list-toolbar #folderToolbarCollapseBtn {
  margin-right: auto;
}

/* Avoid dblclick targeting inner SVG (SVGAnimatedString className), let button receive events */
.doc-list-toolbar .folder-collapse-btn svg,
.doc-list-toolbar .folder-collapse-btn svg *,
.doc-list-toolbar .theme-icon-btn svg,
.doc-list-toolbar .theme-icon-btn svg * {
  pointer-events: none;
}

.doc-list-toolbar .btn-new svg { width: 18px; height: 18px; }
.doc-list-toolbar .btn-sort {
  font-size: 12px;
  padding: 4px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--control-border);
}

/* */
.btn-sort .sort-icon { width: 16px; height: 16px; }
.btn-sort .arrow-up, .btn-sort .arrow-down { fill: currentColor; transition: opacity .2s ease; }
.btn-sort.asc .arrow-up { opacity: 1; }
.btn-sort.asc .arrow-down { opacity: .35; }
.btn-sort.desc .arrow-up { opacity: .35; }
.btn-sort.desc .arrow-down { opacity: 1; }


/* */

/* */
.settings-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.settings-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.settings-modal-content {
  background: var(--bg);
  border-radius: 20px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-modal.show .settings-modal-content {
  transform: scale(1);
}

.settings-modal-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark, var(--primary)));
  color: white;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.settings-modal-title .settings-icon {
  width: 22px;
  height: 22px;
}

.settings-modal-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-modal-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.settings-modal .toolbar-content {
  padding: 28px 24px;
  max-height: calc(85vh - 100px);
  overflow-y: auto;
  overflow-x: hidden;
}

/* */
.search-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.search-modal.show {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 1;
}

.search-modal-content {
  background: var(--bg);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.1);
  width: 90%;
  max-width: 640px;
  max-height: 70vh;
  overflow: hidden;
  transform: scale(0.96) translateY(-10px);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.search-modal.show .search-modal-content {
  transform: scale(1) translateY(0);
}

.search-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-modal-header svg {
  color: var(--muted);
  flex-shrink: 0;
}

.search-modal-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
}

.search-modal-input::placeholder {
  color: var(--muted);
}

.search-modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-modal-close:hover {
  background: var(--elev);
  color: var(--text);
}

.search-modal-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 200px;
}

.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.search-empty-state p {
  margin-top: 16px;
  font-size: 14px;
}

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 4px;
}

.search-result-item:hover {
  background: var(--elev);
}

.search-result-item.selected {
  background: var(--elev);
  box-shadow: 0 0 0 2px var(--primary);
}

.search-result-icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 2px;
}

.search-result-content {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-snippet {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.search-highlight {
  background: rgba(255, 215, 0, 0.3);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

.search-modal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.search-tip {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-tip kbd {
  background: var(--elev);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* */
[data-theme="dark"] .search-modal {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .search-modal-content {
  background: rgba(31, 36, 44, 0.95);
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .search-highlight {
  background: rgba(255, 215, 0, 0.25);
  color: var(--text);
}

.sidebar-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 0;
  line-height: 27px;
  user-select: none;
}

.list-panel .sidebar-title {
  display: none;
}

/* */
.folder-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 4px;
}

/* */
.search-doc-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border-radius: 0;
  transition: background 20ms ease-in;
  min-height: 27px;
  user-select: none;
  margin-bottom: 1px;
}

.search-doc-btn:hover {
  background: var(--elev);
}

.search-doc-btn svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.search-doc-btn span {
  flex: 1;
  text-align: left;
}

:root[data-theme="dark"] .search-doc-btn:hover {
  background: var(--elev);
}

.folder-item {
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 20ms ease-in;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 27px;
  user-select: none;
}
.folder-item:hover {
  background: var(--elev);
}

.folder-item.active {
  background: var(--elev);
  color: var(--text);
  font-weight: 500;
}

.folder-item svg {
  opacity: 0.7;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 0 0 5px;
  margin-bottom: 8px;
}

.doc-item {
  padding: 5px 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  border-radius: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  position: relative;
  user-select: none;
  background: var(--bg);
  border: 1px solid transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.doc-item:hover {
  background: var(--elev);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

.doc-item.active {
  background: color-mix(in srgb, var(--primary) 10%, var(--bg)); /* 主题色背景 */
  color: var(--text);
  font-weight: 500;
  border-left: 3px solid var(--primary); /* 主题色左侧边框 */
  padding-left: 13px; /* 减少左侧内边距以补偿边框 */
  box-shadow: 0 2px 6px color-mix(in srgb, var(--primary) 15%, transparent); /* 主题色阴影 */
  border-color: color-mix(in srgb, var(--primary) 20%, transparent);
}

.doc-item svg {
  flex-shrink: 0;
  opacity: 0.5;
  width: 20px;
  height: 20px;
  transition: opacity 0.2s ease;
}

.doc-item:hover svg {
  opacity: 0.7;
}

.doc-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.doc-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.doc-item-time {
  font-size: 11.5px;
  color: var(--muted);
  opacity: 0.65;
  line-height: 1.3;
  transition: opacity 0.2s ease;
}

.doc-item:hover .doc-item-time {
  opacity: 0.8;
}

.doc-item-actions {
  position: absolute;
  right: 12px;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  pointer-events: none;
  padding-left: 20px;
}

.doc-item:hover .doc-item-actions {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}



/* */
.doc-item:hover .doc-item-content {
  padding-right: 70px;
}

/* */
.doc-item:has(.fav-btn.active) .doc-item-actions {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.doc-item:has(.fav-btn.active) .doc-item-content {
  padding-right: 40px;
}

/* */
.doc-item:has(.fav-btn.active):hover .doc-item-content {
  padding-right: 70px;
}

.doc-action-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 2px;
  font-size: 12px;
  color: var(--muted);
  transition: all 0.2s ease;
}

.doc-action-btn:hover {
  background: var(--elevated);
  color: var(--text);
}

/* */
.doc-action-btn.delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s ease;
}

.doc-item:hover .doc-action-btn.delete-btn {
  opacity: 1;
  transform: scale(1);
}

.doc-action-btn.delete-btn:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

/* */
.doc-item:has(.fav-btn.active) .doc-action-btn.delete-btn {
  opacity: 0;
  transform: scale(0.8);
}

.doc-item:has(.fav-btn.active):hover .doc-action-btn.delete-btn {
  opacity: 1;
  transform: scale(1);
}

.doc-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.new-doc-btn, .delete-doc-btn {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.new-doc-btn:hover {
  background: var(--elevated);
  border-color: var(--primary);
  color: var(--primary);
}

.delete-doc-btn {
  background: var(--bg);
  border-color: #cc6666;
  color: #cc6666;
}

.delete-doc-btn:hover:not(:disabled) {
  background: rgba(204, 102, 102, 0.1);
  border-color: #ff9999;
  color: #cc3333;
}

.delete-doc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* */
/* .content-main {
  display: flex;
  flex-direction: column;
} */

/* */
.input-section {
  padding: 0;
  border: 1px solid var(--border);
  background: var(--elevated);
  border-radius: 10px;
  margin: 0 10px 10px 10px;
  max-width: 860px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#textInput {
  flex: 1 1 auto;
  border: none;
  padding: 5px 10px;
  font-size: calc(14px * var(--font-scale));
  font-family: inherit;
  resize: vertical;
  min-height: 88px;
  border-radius: 2px;
  color: var(--text);
  /* */
  background: transparent;
  outline: none;
  overflow: auto;
}



.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--elevated);
  border-color: var(--border);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: #6B5B00;
}

/* */
a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* */
.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

/* */
input, textarea, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  transition: all 0.2s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* */
.content-area {
  flex: 1;
  margin: 0 10px;
  /* overflow-y: auto; */
  background: var(--bg);
  padding-bottom: 50px;
}
.two-pane .content-area {
  margin: 0 10px 0 0;
}

/* */
.line-container {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0;
  /* padding: 8px 0; */
  position: relative;
}

.line-container:last-child {
  border-bottom: none;
}

/* */
.token-pill {
  position: relative;
  display: inline-flex;
  /* align-items: self-start; */
  padding: 4px 8px;
  background: var(--bg);
  color: var(--text);
  border-bottom: 3px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  /* transition: all 0.2s ease; */
  margin: 2px;
  flex-direction: column;
  /* min-width: 60px; */
  text-align: center;
}

/* */
.token-pill[data-pos="名"] {
  border-color: #4CAF50; /* 绿色 - 名词 */
}

.token-pill[data-pos="动"] {
  border-color: #2196F3; /* 蓝色 - 动词 */
}

.token-pill[data-pos="形"] {
  border-color: #FF9800; /* 橙色 - 形容词 */
}

.token-pill[data-pos="副"] {
  border-color: #9C27B0; /* 紫色 - 副词 */
}

.token-pill[data-pos="助"] {
  border-color: #F44336; /* 红色 - 助词 */
}

.token-pill[data-pos="助动"] {
  border-color: #E91E63; /* 粉红色 - 助动词 */
}

.token-pill[data-pos="连体"] {
  border-color: #00BCD4; /* 青色 - 连体词 */
}

.token-pill[data-pos="接续"] {
  border-color: #795548; /* 棕色 - 接续词 */
}

.token-pill[data-pos="感叹"] {
  border-color: #FFEB3B; /* 黄色 - 感叹词 */
}

.token-pill[data-pos="标点"] {
  border-color: #607D8B; /* 蓝灰色 - 标点符号 */
}

.token-pill[data-pos="符号"] {
  border-color: #607D8B; /* 蓝灰色 - 符号 */
}

.token-pill[data-pos="填充"] {
  border-color: #9E9E9E; /* 灰色 - 填充词 */
}

.token-pill[data-pos="其他"] {
  border-color: #9E9E9E; /* 灰色 - 其他 */
}

.token-pill[data-pos="未知"] {
  border-color: #ddd; /* 默认灰色 - 未知词性 */
}

.token-pill:hover {
  /* background: rgb(230, 230, 230); */
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(189, 189, 189, 0.3);
}

.token-pill.active,
.token-pill.playing {
  background: linear-gradient(135deg, #ffffff, #fffac0);
  border-color: #4CAF50;
  /* color: white !important; */
  /* transform: scale(1.05); */
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
  animation: pulse-playing 1.5s ease-in-out infinite;
  /* z-index: 9999; */
}
/* .token-pill.active .token-content *,
.token-pill.playing .token-content * {
  color: white !important;
} */

.token-pill.playing .token-content {
  color: white;
}

/* .token-pill.playing .token-kana,
.token-pill.playing .token-romaji,
.token-pill.playing .token-kanji,
.token-pill.playing .token-pos {
  color: white;
} */

/* */
@keyframes pulse-playing {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
  }
  50% {
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
  }
}

.token-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.token-kana {
  font-size: 10px;
  color: var(--muted);
  min-height: 12px;
}

.token-romaji {
  font-size: 9px;
  color: var(--muted);
  font-style: italic;
  min-height: 11px;
}

.token-kanji {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.token-pos {
  font-size: 8px;
  color: var(--muted);
  background: var(--elevated);
  padding: 1px 3px;
  border-radius: 8px;
  margin-top: 1px;
}

/* */
#reading-mode .display-pos {
  display: none !important;
}
#reading-mode .token-pill.active, #reading-mode .token-pill.playing {
  /* */
  color: inherit;
}
#reading-mode .main-container.two-pane #editorPanels {
  height: calc(100vh);
}
#reading-mode .main-container.two-pane #editorPanels .content-area {
    max-width: 100%;
}
/* */
:root[data-theme="dark"] #reading-mode .token-pill.active,
:root[data-theme="dark"] #reading-mode .token-pill.playing {
  color: var(--text);
}
#reading-mode .token-pill {
  border-bottom: none;
  padding: 0 2px;
  margin: 8px 0;
  background: transparent !important;
  box-shadow: none !important;
  min-width: auto;
}

#reading-mode .token-pill:hover {
  background: none !important;
  box-shadow: none !important;
}

.pos-tag {
  font-size: 10px;
  color: var(--muted);
  margin-left: 4px;
  padding: 1px 3px;
  background: var(--elevated);
  border-radius: 2px;
}

/* */
.token-kana:empty,
.token-romaji:empty {
  display: none !important;
}

/* */
.token-pill .token-content:empty::after {
  content: "•";
  color: var(--muted);
  font-size: 12px;
}

/* */
.token-details {
  position: fixed;
  top: 0;
  left: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 35px 10px 10px 10px;
  z-index: 10000;
  min-width: 240px;
  max-width: 300px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  border-radius: 6px;
  display: none;
}

.detail-item {
  margin-bottom: 6px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

.detail-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.detail-item strong {
  color: var(--muted);
  font-weight: 600;
  margin-right: 6px;
  font-size: 11px;
}

/* */
.sidebar-right {
  position: fixed;
  top: 80px; /* 头部高度 + 间距 */
  right: 20px;
  width: 220px;
  height: 500px; /* 改为height，由JavaScript动态调整 */
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  z-index: 1000;
  cursor: move;
  user-select: none;
  transition: right 0.3s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  /* */
  transform: translateX(0);
  opacity: 1;
}

.sidebar-right:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}


/* */
.toolbar-header {
  background: linear-gradient(135deg, var(--primary), #463201);
  color: white;
  padding: 5px 10px;
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-drag-icon {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

.toolbar-minimize-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.toolbar-minimize-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* */
.toolbar-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1; /* 自动填充剩余空间 */
}

/* */

/* */
.settings-section {
  margin-bottom: 20px;
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-section .sidebar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

/* */
.system-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-select,
.lang-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-select:hover,
.theme-select:focus,
.lang-select:hover,
.lang-select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 1px var(--primary);
}

/* */
.voice-controls,
.display-controls {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
  row-gap: 10px;
  align-items: center;
  min-height: 40px;
}

.control-group {
  margin-bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 12px;
}

/* */
.select-group {
  flex: 1 1 calc(50% - 12px);
  min-width: 240px;
}
.checkbox-group {
  flex: 1 1 calc(33.333% - 12px);
  min-width: 200px;
}
.control-group.full-width {
  flex: 1 1 100%;
  min-width: 100%;
}

.control-label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 0;            /* 工具栏横排时不需要额外下边距 */
  font-weight: 600;
  cursor: pointer;
  white-space: normal;         /* 允许标签文本换行以适配更紧凑布局 */
}
.control-label .label-text { white-space: normal; }

.control-label input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

select, input[type="range"] {
  width: 100%;
  padding: 4px;
  border: 1px solid var(--border);
  font-size: 12px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.speed-display {
  font-size: 12px;
  color: var(--control-muted);
  text-align: right;
  margin-top: 0;
  line-height: 36px;           /* 与控件等高 */
}

.play-all-btn {
  width: 100%;
  padding: 0 12px; height: 36px; display: inline-flex; align-items: center;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.play-all-btn:hover {
  background: #6B5B00;
}

.display-controls { margin-top: 4px; }

.display-controls .control-group { margin-bottom: 0; }

/* */
.play-line-btn {
  background: none;
  border: 1px solid var(--border);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s ease;
  margin-left: auto;
  border-radius: 8px;
}

.play-line-btn:hover {
  background: var(--elevated);
  border-color: var(--border);
}

.play-token-btn {
  background: none;
  border: 1px solid var(--border);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s ease;
  margin-top: 6px;
  border-radius: 8px;
}

.play-token-btn:hover {
  background: var(--elevated);
}

/* */
.token-details .play-token-btn {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 22px;
  height: 22px;
  margin: 0;
  border-radius: 50%;
  background: var(--control-bg);
  border-color: var(--control-border);
  color: var(--control-text);
}
.token-details .play-token-btn:hover {
  background: var(--control-elev);
}

/* */
.loading {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.empty-state, .error-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 13px;
}

/* */

/* */
.translation-item {
  background: var(--elevated);
  border-radius: 4px;
  padding: 8px;
  margin: 6px 0;
}

.translation-content {
  display: block;
  margin-top: 4px;
}

.main-translation {
  color: var(--primary);
  font-weight: 500;
}

.expand-translation-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 11px;
  text-decoration: underline;
  margin-left: 8px;
  padding: 0;
}

.expand-translation-btn:hover {
  color: #8B6914;
}

.translation-kana {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}

/* */
.translation-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.translation-modal-content {
  background: var(--bg);
  border-radius: 8px;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.translation-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.translation-modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-modal-btn:hover {
  color: var(--text);
}

.translation-modal-body {
  padding: 20px;
}

.sense-item {
  display: flex;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sense-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sense-number {
  font-weight: bold;
  color: var(--primary);
  margin-right: 12px;
  min-width: 20px;
}

.sense-content {
  flex: 1;
}

.sense-gloss {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
}

.sense-pos, .sense-field, .sense-misc, .sense-chinese {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 3px;
}

.sense-pos {
  color: var(--primary);
}

.sense-field {
  color: #ff6b35;
}

.sense-misc {
  color: var(--muted);
  font-style: italic;
}

.sense-chinese {
  color: #e74c3c;
  font-weight: 500;
}

/* */
.nhk-controls {
  margin-top: 8px;
}

.nhk-news-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--elevated);
}

.nhk-news-item {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  line-height: 1.4;
}

.nhk-news-item:hover {
  background: var(--bg);
}

.nhk-news-item:last-child {
  border-bottom: none;
}

.nhk-news-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nhk-news-meta {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nhk-news-category {
  background: var(--elevated);
  color: var(--primary);
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 9px;
}

.nhk-news-date {
  color: var(--muted);
}

.nhk-loading {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 12px;
}

.nhk-error {
  text-align: center;
  padding: 20px;
  color: #e74c3c;
  font-size: 12px;
}

.nhk-category-section {
  margin-bottom: 12px;
}

.nhk-category-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  padding: 4px 8px;
  background: var(--elevated);
  border-radius: 2px;
}

/* */
.article-content {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.article-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.4;
}

.article-meta {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.article-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--primary);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.article-link:hover {
  background: var(--primary);
  color: white;
}

.article-body {
  margin-bottom: 20px;
  line-height: 1.6;
}

.article-body pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--elevated);
  padding: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  max-height: 400px;
  overflow-y: auto;
}

.article-actions {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.article-debug {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  margin: 12px 0;
  font-size: 12px;
}

.article-debug code {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 8px;
  margin-top: 4px;
  word-break: break-all;
  font-family: monospace;
  font-size: 11px;
  color: var(--text);
}

/* */


/* */
.theme-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* width: 28px;
  height: 28px; */
  padding: 0;
  background: var(--bg);
  color: var(--text);
  /* border-radius: 4px; */
  cursor: pointer;
  border: none;
}
.theme-icon-btn svg { fill: var(--text); }

/* */
#syncBtn svg path {
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.theme-icon-btn:hover { background: rgba(0,0,0,0.06); }
:root[data-theme="dark"] .theme-icon-btn:hover { background: rgba(255,255,255,0.06); }
.theme-icon-btn.is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.9;
}
/* */
.theme-icon-btn.is-loading svg {
  opacity: 1;
}
/* */
/* */
.theme-icon-btn.is-loading::before,
.theme-icon-btn.is-loading::after {
  content: '';
  display: none;
}

/* */
.theme-icon-btn.is-rotating svg {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: pwa-spin 0.9s linear infinite reverse;
}

/* */
.theme-icon-btn.rotate-3 svg {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: pwa-spin 0.6s linear 3 reverse;
}

@keyframes pwa-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* */
.pwa-toast {
  position: fixed;
  right: 24px;
  top: 64px; /* 顶部导航下方显示 */
  bottom: auto;
  z-index: 1100;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid rgba(139, 105, 20, 0.18);
  box-shadow: 0 4px 18px rgba(180, 150, 80, 0.13), 0 1.5px 6px rgba(120, 100, 40, 0.08);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  color: var(--text);
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  transform: translateY(-12px); /* 自顶部轻微滑入 */
}

.pwa-toast[hidden] {
  display: none;
}

.pwa-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.pwa-toast.is-success {
  border-color: rgba(76, 175, 80, 0.5);
  background: linear-gradient(140deg, rgba(236, 255, 240, 0.99), rgba(76, 175, 80, 0.25));
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
}

.pwa-toast.is-error {
  border-color: rgba(244, 67, 54, 0.5);
  background: linear-gradient(140deg, rgba(255, 241, 241, 0.99), rgba(244, 67, 54, 0.25));
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
}

:root[data-theme="dark"] .pwa-toast {
  border-color: rgba(217, 179, 90, 0.5);
  background: linear-gradient(140deg, rgba(24, 27, 35, 0.98), rgba(217, 179, 90, 0.2));
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.5);
}

:root[data-theme="dark"] .pwa-toast.is-success {
  border-color: rgba(76, 175, 80, 0.6);
  background: linear-gradient(140deg, rgba(19, 29, 22, 0.98), rgba(76, 175, 80, 0.3));
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
}

:root[data-theme="dark"] .pwa-toast.is-error {
  border-color: rgba(244, 67, 54, 0.6);
  background: linear-gradient(140deg, rgba(35, 21, 21, 0.98), rgba(244, 67, 54, 0.3));
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
}

.pwa-toast__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(139,105,20,0.35));
  color: var(--primary);
}

.pwa-toast__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pwa-toast__title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.pwa-toast__message {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-line;
  word-break: break-word;
}

.pwa-toast__progress {
  display: none;
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

:root[data-theme="dark"] .pwa-toast__progress {
  background: rgba(255, 255, 255, 0.12);
}

.pwa-toast__progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), rgba(139, 105, 20, 0.45));
  border-radius: inherit;
  transition: width 0.25s ease;
}

.pwa-toast__progress-value {
  display: none;
}

.pwa-toast__close {
  border: none;
  background: rgba(0,0,0,0.05);
  color: inherit;
  border-radius: 10px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.pwa-toast__close:hover {
  background: rgba(0,0,0,0.12);
}

:root[data-theme="dark"] .pwa-toast__close {
  background: rgba(255,255,255,0.08);
}

:root[data-theme="dark"] .pwa-toast__close:hover {
  background: rgba(255,255,255,0.16);
}

/* */

/* */
select, input[type="text"], textarea, .btn, .new-doc-btn, .delete-doc-btn, .play-all-btn, .nav-item, .play-line-btn, .play-token-btn {
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}

/* */
:root {
  --control-bg: var(--bg);
  --control-border: var(--border);
  --control-text: var(--text);
  --control-muted: var(--muted);
  --control-elev: var(--elev);
  --primary-contrast: #ffffff;
}

/* */
:root[data-theme="dark"] {
  --control-bg: #1b1f26;       /* 输入/按钮 背景 */
  --control-border: #2a303b;   /* 控件边框 */
  --control-text: #e7eaf0;     /* 控件文字 */
  --control-muted: #9fa7b3;    /* 控件次级文字 */
  --control-elev: #222833;     /* 控件悬浮层 */
  --primary-contrast: #0d0f13; /* 金色上的反差文字 */
}

/* */
select, textarea, input[type="text"] {
  color: var(--control-text);
  border: 1px solid var(--control-border);
}
select:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* */
.btn, .new-doc-btn, .delete-doc-btn, .play-line-btn, .play-token-btn {
  background: var(--control-bg);
  color: var(--control-text);
  border: 1px solid var(--control-border);
  border-radius: 18px;
}
.play-line-btn {
  position: absolute;
  right: 0;
}
/* */
.btn:hover, .new-doc-btn:hover, .play-line-btn:hover, .play-token-btn:hover {
  /* background: var(--control-elev); */
  border-color: var(--control-border);
}

/* */
.btn-primary, .play-all-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff !important;
  text-shadow: 0 1px 0 rgba(0,0,0,0.15);
}
.btn-primary:hover, .play-all-btn:hover {
  filter: brightness(0.95);
  box-shadow: 0 0 0 3px rgba(78,161,255,0.25);
}
.btn-primary:focus-visible, .play-all-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(78,161,255,0.35);
}
.btn-primary:disabled, .play-all-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* */
.sidebar-btn { background: var(--control-bg); border: 1px solid var(--control-border); color: var(--control-text); }
.sidebar-btn.active { background: rgba(78,161,255,0.12); border-color: var(--primary); color: var(--primary); }


/* */
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--control-border); border-radius: 999px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; background: var(--primary); border-radius: 50%; margin-top: -6px; border: 2px solid var(--primary-contrast); }
input[type="range"]::-webkit-slider-thumb { box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
input[type="range"]::-moz-range-track { height: 4px; background: var(--control-border); border-radius: 999px; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: var(--primary); border-radius: 50%; border: 2px solid var(--primary-contrast); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }

/* */
.sidebar-title, .control-label, .speed-display { color: var(--control-muted); }

/* */
:root[data-theme="dark"] .token-details { box-shadow: 0 12px 36px rgba(0,0,0,0.55); border-color: var(--control-border); }

/* */
.footer {
  /* margin: 20px auto 50px auto; */
  /* padding: 12px 0 0; */
  font-size: 11.5px;
  color: var(--control-muted);
  line-height: 1.6;
  text-align: center;
}
.footer-inner { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  gap: 8px; 
  flex-wrap: wrap;
}
.footer-brand { color: var(--primary); font-weight: 500; }
.footer a {
  color: var(--primary);
  text-decoration: none;
}
.footer a:hover {
  text-decoration: underline;
}
.footer .theme-icon-btn {
  border:none
}
.footer-link { display: inline-flex; align-items: center; gap: 6px; }
.footer-sep { color: var(--border); }
.footer-copy { color: var(--control-muted); }
/* */

/* */
/* */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) rgba(0, 0, 0, 0.08);
}
:root[data-theme="dark"] html {
  scrollbar-color: rgba(217, 179, 90, 0.75) rgba(255, 255, 255, 0.08);
}

/* */
/* */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}

/* */
::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary), rgba(139, 105, 20, 0.45));
  border: 2px solid transparent; /* 让拇指与轨道之间留一点空隙 */
  background-clip: padding-box;   /* 避免边框覆盖渐变色 */
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--primary), rgba(139, 105, 20, 0.65));
}
::-webkit-scrollbar-corner { background: transparent; }

/* */
:root[data-theme="dark"] ::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(217, 179, 90, 0.85), rgba(217, 179, 90, 0.55));
  border-color: transparent;
}

/* */
.sidebar-right .toolbar-content,
.doc-list,
.sidebar-scroll,
.content-container,
.editor-panels,
.token-details,
.pwa-toast__content {
  scrollbar-width: thin;
}

.editor-panels {
  padding-top: 10px;
}
/* */
.token-pill.playing {
  /* border-color: var(--primary); */
  box-shadow: 0 0 0 3px rgba(78,161,255,0.25);
  /* background: rgba(78,161,255,0.12); */
}
:root[data-theme="dark"] .token-pill.playing {
  box-shadow: 0 0 0 3px rgba(78,161,255,0.35);
  background: rgba(78,161,255,0.18);
}

/* */
.token-details { z-index: 10010; }


/* */
.toolbar-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: background-color 0.2s ease;
}

.toolbar-resize-handle:hover {
  background: var(--elev);
}

.resize-handle-line {
  width: 20px;
  height: 1px;
  background: var(--text);
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

.toolbar-resize-handle:hover .resize-handle-line {
  opacity: 0.7;
}

/* */
.sidebar-right .toolbar-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1; /* 自动填充剩余空间 */
  min-height: 0; /* 允许flex子元素收缩 */
}

/* */
.delete-confirm {
  position: fixed;
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.15s ease-out;
  font-size: 13px;
  z-index: 999;
  width: 230px;
  line-height: 1.5;
}

.delete-confirm-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.delete-confirm-message {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
}

.delete-confirm-icon {
  color: var(--danger);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.delete-confirm-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.delete-confirm-cancel {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 50px;
}

.delete-confirm-cancel:hover {
  background: var(--elev);
  border-color: var(--primary);
}

.delete-confirm-ok {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
  border: 1px solid var(--danger);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 50px;
}

.delete-confirm-ok:hover {
  background: #8c1515;
  border-color: #dc2626;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* */
[data-theme="dark"] .delete-confirm {
  background: var(--elev);
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .delete-confirm-cancel {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .delete-confirm-cancel:hover {
  background: var(--elev);
  border-color: var(--primary);
}

/* */
.reading-mode-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 777;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* width: 78px;
  height: 78px; */
  border: none;
  border-radius: 40px;
  background: linear-gradient(160deg, #fff6d8 0%, #fee6ac 100%);
  color: #70471a;
  box-shadow: 0 8px 14px rgba(122, 86, 32, 0.18), 0 3px 7px rgba(122, 86, 32, 0.10);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.reading-mode-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 36px rgba(122, 86, 32, 0.32), 0 10px 18px rgba(122, 86, 32, 0.18);
}

.reading-mode-toggle:active {
  transform: translateY(0px);
}

.reading-mode-toggle .reading-toggle-icon {
  width: 40px;
  height: 40px;
  border-radius: 40px;
  background: linear-gradient(150deg, #fffef6 0%, #ffe4a8 100%);
  border: 1px solid #e7c98c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

.reading-mode-toggle .reading-toggle-icon::after {
  content: '';
  position: absolute;
  top: -1px;
  right: -1px;
  width: 13px;
  height: 13px;
  background: rgba(255, 255, 255, 0.78);
  border-left: 1px solid #e7c98c;
  border-bottom: 1px solid #e7c98c;
  transform: translate(35%, -35%) rotate(45deg);
  border-radius: 0 3px 0 0;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.08);
}

.reading-icon-lines {
  position: relative;
  width: 60%;
  height: 2px;
  background: rgba(112, 71, 26, 0.38);
  border-radius: 999px;
  box-shadow: 0 8px 0 rgba(112, 71, 26, 0.26), 0 16px 0 rgba(112, 71, 26, 0.22);
  transform: translateY(-6px);
  pointer-events: none;
}

.reading-icon-lines::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -18px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(112, 71, 26, 0.25);
  box-shadow: -10px 0 0 rgba(112, 71, 26, 0.18), 10px 0 0 rgba(112, 71, 26, 0.18);
  transform: translateX(-50%);
}

.reading-mode-toggle.is-active {
  background: linear-gradient(160deg, #ffe2a1 0%, #ffc675 100%);
  color: #5a3410;
  box-shadow: 0 22px 40px rgba(96, 64, 22, 0.38), 0 12px 22px rgba(96, 64, 22, 0.2);
}

.reading-mode-toggle.is-active .reading-toggle-icon {
  background: linear-gradient(150deg, #fff4c1 0%, #ffc46b 100%);
  border-color: #deaa5a;
}

.reading-mode-toggle.is-active .reading-icon-lines {
  background: rgba(90, 52, 16, 0.55);
  box-shadow: 0 8px 0 rgba(90, 52, 16, 0.35), 0 16px 0 rgba(90, 52, 16, 0.28);
}

:root[data-theme="dark"] .reading-mode-toggle {
  border-color: #ad8f60;
  background: linear-gradient(160deg, #4a3a24 0%, #6a502d 100%);
  color: #f8e2c1;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.45);
}

:root[data-theme="dark"] .reading-mode-toggle .reading-toggle-icon {
  background: linear-gradient(150deg, #6a502d 0%, #8b683d 100%);
  border-color: #ad8f60;
}

:root[data-theme="dark"] .reading-mode-toggle .reading-toggle-icon::after {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

:root[data-theme="dark"] .reading-icon-lines {
  background: rgba(254, 227, 181, 0.55);
  box-shadow: 0 8px 0 rgba(254, 227, 181, 0.42), 0 16px 0 rgba(254, 227, 181, 0.35);
}

:root[data-theme="dark"] .reading-icon-lines::after {
  background: rgba(254, 227, 181, 0.36);
  box-shadow: -10px 0 0 rgba(254, 227, 181, 0.28), 10px 0 0 rgba(254, 227, 181, 0.28);
}

:root[data-theme="dark"] .reading-mode-toggle.is-active {
  background: linear-gradient(160deg, #725330 0%, #966939 100%);
  color: #ffe8c8;
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.5);
}

/* */
/* */


/* */
.reading-mode-toggle {
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
              box-shadow 0.3s ease, 
              background 0.3s ease,
              scale 0.2s ease;
}

.reading-mode-toggle:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

/* */
.reading-mode-toggle.click-animation {
  transform: scale(0.95);
  transition: transform 0.1s ease;
  /* */
  position: fixed !important;
  bottom: 28px !important;
  right: 28px !important;
}

/* */
.reading-mode-toggle.exit-animation {
  animation: readingModeExit 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  /* */
  position: fixed !important;
  bottom: 28px !important;
  right: 28px !important;
}

@keyframes readingModeExit {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
  100% {
    transform: scale(0.9);
    opacity: 0.6;
  }
}

/* */
.reading-mode-toggle.is-active {
  animation: readingToggleActivate 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  /* */
  position: fixed !important;
  bottom: 28px !important;
  right: 28px !important;
}

@keyframes readingToggleActivate {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* */
.reading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.reading-overlay .token-pill {
  padding: 0;
  min-width: 0;
}
.reading-overlay .overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 24, 12, 0.35);
  backdrop-filter: blur(2px);
}
.reading-overlay .overlay-content {
  position: relative;
  max-width: 960px;
  width: min(960px, 92vw);
  max-height: 82vh;
  overflow: auto;
  border-radius: 18px;
  box-shadow: 0 26px 60px rgba(0,0,0,0.35);
  background: linear-gradient(180deg, #fffdf8 0%, #fff5da 100%);
  border: 1px solid #e2cfa3;
  padding: 20px 20px 40px;
  color: #4c381a;
  /* */
  font-family: var(--content-font-family, inherit);
  font-size: calc(16px * var(--font-scale));
}
.reading-overlay .overlay-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
}
.reading-overlay .overlay-close {
  border: none;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(139,105,20,0.24);
  color: #5a3410;
  width: 28px;
  height: 28px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
:root[data-theme="dark"] .reading-overlay .overlay-backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(1px);
}
:root[data-theme="dark"] .reading-overlay .overlay-content {
  background: linear-gradient(180deg, rgba(44, 36, 24, 0.92) 0%, rgba(32, 27, 17, 0.92) 100%);
  color: #f2e0c0;
  border-color: rgba(226, 207, 163, 0.18);
}




/* */
.reading-overlay .overlay-content {
  animation: contentSlideIn 0.48s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}




@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes contentSlideIn {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    filter: blur(3px);
  }
  50% {
    opacity: 0.7;
    transform: translateY(-5px) scale(1.01);
    filter: blur(1px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.reading-overlay .token-content{
  gap: 0;
  align-items: baseline;  
}

#reading-mode .main-container {
  display: block;
  max-width: 960px;
  margin: 64px auto;
  padding: 80px 24px;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
  min-height: auto;
  overflow: visible;
}

#reading-mode .content-container {
  height: auto;
  padding-bottom: 200px;
}

#reading-mode .content-main {
  width: 100%;
  display: block;
  background-color: transparent;
  position: static;
}

#reading-mode .content-area {
  background: linear-gradient(180deg, #fffdf8 0%, #fff5da 100%);
  border: 1px solid #e2cfa3;
  border-radius: 18px 18px 12px 18px;
  padding: 20px 20px 40px 20px;
  box-shadow: 0 20px 60px -32px rgba(112, 80, 30, 0.45), 0 18px 28px -26px rgba(112, 80, 30, 0.25);
  color: #4c381a;
}

.reading-overlay .overlay-content .analysis-section,
.reading-overlay .overlay-content .token-pill,
.reading-overlay .overlay-content .translation-card {
  background: transparent;
  box-shadow: none;
  border-color: rgba(226, 207, 163, 0.6);
  border-bottom: none;
}
.reading-overlay .overlay-content .token-pos {
  display: none;
}
#reading-mode .content-area .token-list {
  gap: 16px;
}


.reading-overlay .line-container {
  width: 100%;
  padding: 0 10px;
  margin: 5px 0;
  gap: 0;
  /* border-radius: 22px 22px 14px 22px; */
  border-bottom: 1px solid #e5dbc3;
  /* background: rgba(255, 252, 240, 0.65);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease; */
  cursor: pointer;
  outline: none;
  position: relative;
  /* box-shadow: 0 12px 36px -32px rgba(112, 80, 30, 0.5); */
}

.reading-overlay .line-container.reading-line-active {
  border-bottom: 2px solid rgb(217 169 58 / 60%);
}

.reading-overlay .line-container.reading-line-active .token-pill {
  border-bottom: none;
}


:root[data-theme="dark"] #reading-mode {
  background: #2c2418;
}

/* */
:root[data-theme="dark"] #reading-mode .content-area {
  background:
    linear-gradient(180deg, rgba(44, 36, 24, 0.92) 0%, rgba(32, 27, 17, 0.92) 100%),
    radial-gradient(800px 400px at 20% -10%, rgba(217, 179, 90, 0.08), transparent 60%);
  border-color: rgba(217, 179, 90, 0.28);
  color: var(--text);
  box-shadow: 0 22px 48px -28px rgba(0, 0, 0, 0.55);
  backdrop-filter: saturate(120%) blur(4px);
}


:root[data-theme="dark"] #reading-mode .line-container::before {
  background: rgba(237, 196, 125, 0.32);
}




:root[data-theme="dark"] #reading-mode .line-container.reading-line-active::before {
  background: linear-gradient(200deg, #f7d68a 0%, #f1ac47 100%);
}

:root[data-theme="dark"] #reading-mode .line-container.reading-line-active::after {
  border-color: rgba(255, 235, 200, 0.25);
}


/* */
:root[data-theme="dark"] #reading-mode .token-kanji { color: #f5e8cf; }
:root[data-theme="dark"] #reading-mode .token-kana { color: rgba(245, 232, 207, 0.8); }
:root[data-theme="dark"] #reading-mode .token-romaji { color: rgba(217, 179, 90, 0.85); }
:root[data-theme="dark"] #reading-mode .punct { color: rgba(245, 232, 207, 0.65); }

/* */
:root[data-theme="dark"] #reading-mode .token-pill {
  background: transparent !important;
  box-shadow: none !important;
}

/* */
/* */
/* */
.doc-action-btn.favorite-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.doc-action-btn.favorite-btn:hover { color: var(--text); }
.doc-item.favorited .doc-action-btn.favorite-btn { color: #f5a623; }

/* */
.main-header {
  /* */
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 10px 0 0;
  height: 40px;
  background: var(--bg);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  border-bottom: 1px solid var(--border);
  border-left: none;
  border-right: none;
  border-top: none;
  z-index: 1000;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* */
.main-container.two-pane .main-header {
  position: fixed;
  top: 0;
  z-index: 1000;
}
.main-header-left,
.main-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* */
.main-header-right { justify-content: flex-end; }

/* */
.main-header-left .logo {
  font-size: 16px;
  margin-right: 4px;
  position: relative;
  left: -5px;
}

.main-header-left .logo-icon {
  width: 28px;
  height: 28px;
}

.main-header-left .folder-collapse-btn {
  margin-right: 4px;
  border: none;
  background: transparent;
}

.main-header-left .folder-collapse-btn:hover {
  background: var(--elev);
}

/* */
.user-profile-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: visible; /* 允许下拉菜单和子菜单溢出显示 */
}


#userAvatarBtn {
  width: 24px;
  height: 24px;
  min-width: auto;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--elev);
  cursor: pointer;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#userAvatarBtn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
  opacity: 0;
  transition: opacity 0.25s ease;
}

#userAvatarBtn:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#userAvatarBtn:hover::after {
  opacity: 1;
}

#userAvatarBtn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#userAvatarBtn svg {
  width: 22px;
  height: 22px;
  fill: var(--muted);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  overflow: visible;
}

.user-profile-container.open .user-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--elev), var(--bg));
}

.user-dropdown-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}

.user-dropdown-email {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
  opacity: 0.85;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

.user-dropdown-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.user-dropdown-item:hover {
  background: var(--elev);
  padding-left: 20px;
}

.user-dropdown-item:hover::before {
  transform: scaleY(1);
}

.user-dropdown-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: var(--text);
  transition: transform 0.2s ease;
}

.user-dropdown-item:hover svg {
  transform: scale(1.1);
}

.user-dropdown-item.logout {
  color: #dc2626;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.user-dropdown-item.logout::before {
  background: #dc2626;
}

.user-dropdown-item.logout svg {
  fill: #dc2626;
}

.user-dropdown-item.logout:hover {
  background: rgba(220, 38, 38, 0.08);
}

/* */
.user-dropdown-item.submenu-parent {
  position: relative;
  padding-left: 36px;
  cursor: default; /* 改为 default，因为不直接点击 */
}

.user-dropdown-item.submenu-parent:hover {
  background: var(--elev);
  padding-left: 40px;
}

.user-dropdown-item.submenu-parent:hover::before {
  transform: scaleY(0);
}

/* */
.user-dropdown-item.submenu-parent:has(.user-submenu:hover) {
  background: var(--elev);
  padding-left: 40px;
}

.user-dropdown-item.submenu-parent:has(.user-submenu:hover)::before {
  transform: scaleY(0);
}

.submenu-arrow {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%) rotate(180deg); /* 翻转箭头方向 */
  fill: var(--muted);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.submenu-parent:hover .submenu-arrow {
  fill: var(--text);
}

.user-submenu {
  position: absolute;
  right: calc(100% - 4px); /* 从左边展开，稍微重叠消除间隙 */
  top: 0;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px);
  transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
  transition-delay: 0s, 0s, 0s;
  z-index: 10002;
  overflow: hidden;
  pointer-events: none;
}

/* */
.user-dropdown-item.submenu-parent::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 0;
  bottom: 0;
  width: 12px; /* 桥梁宽度 */
  background: transparent;
  z-index: 10001;
}

/* */
.submenu-parent.submenu-open .user-submenu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto !important; /* 强制启用交互 */
  transition-delay: 0s, 0s, 0s;
}

/* */
.user-submenu:hover {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto !important;
}

/* */
.submenu-parent .user-submenu {
  transition-delay: 0s, 0.2s, 0s; /* visibility延迟关闭，增加时间 */
}

/* */

.submenu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  pointer-events: auto !important; /* 确保按钮可以被点击 */
  user-select: none; /* 防止文本选择 */
}

.submenu-item svg {
  flex-shrink: 0;
  fill: var(--text);
  opacity: 0.7;
}

.submenu-item:hover {
  background: var(--elev);
}

.submenu-item:hover svg {
  opacity: 1;
}

.submenu-item.active {
  background: rgba(var(--primary-rgb, 139, 105, 20), 0.1);
  color: var(--primary);
  font-weight: 600;
}

.submenu-item.active svg {
  fill: var(--primary);
  opacity: 1;
}

.submenu-item:not(:last-child) {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* */
.sync-progress-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 10001;
  display: none;
  min-width: 280px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.sync-progress-toast.show {
  display: block;
}

.sync-progress-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.sync-progress-text {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: #dc2626;
  color: white;
  border-radius: 12px;
  padding: 16px 24px;
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.3);
  z-index: 10002;
  display: none;
  min-width: 300px;
  max-width: 400px;
  animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.error-toast.show {
  display: block;
}

.error-toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.error-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.error-text {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

/* */
.editor-date{font-size:12px;color:var(--muted)}
.editor-count{font-size:12px;color:var(--text);opacity:.9}
.editor-star-toggle,.editor-reading-toggle{
  /* background: var(--bg); */
  /* border: 1px solid var(--border); */
  padding: 4px 8px;
  font-size: 12px;
  /* color: var(--text); */
  /* border-radius: 6px; */
  cursor: pointer;
  transition: all .2s ease;
}
.editor-star-toggle:hover,.editor-reading-toggle:hover{background:var(--elevated)}
.editor-star-toggle.is-active{color:#f5a623;border-color:#f5a623;}

/* */
#reading-mode .main-header{display:none!important}

/* */
:root[data-theme="dark"] .main-header{background:rgba(30,34,41,.78);border-color:rgba(255,255,255,.08);box-shadow:0 8px 24px rgba(0,0,0,.35)}
:root[data-theme="dark"] .editor-date{color:var(--muted)}
:root[data-theme="dark"] .editor-star-toggle.is-active{color:#f5d083;border-color:#f5d083;background:rgba(245,208,131,.08)}

/* */
[data-theme="dark"] .folder-management,
[data-theme="dark"] .input-section,
[data-theme="dark"] .content-area,
[data-theme="dark"] .sidebar-right,
[data-theme="dark"] .settings-modal-content {
  background: rgba(30, 34, 41, 0.78);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border-color: rgba(255,255,255,0.08);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}

/* */
[data-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(255, 215, 128, 0.06), transparent 60%),
    radial-gradient(1000px 500px at 120% 110%, rgba(120, 180, 255, 0.06), transparent 60%),
    #171a20;
}

[data-theme="dark"] .header {
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}

[data-theme="dark"] .main-container {
  box-shadow: 0 18px 50px rgba(0,0,0,0.4);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0));
}

[data-theme="dark"] .folder-management {
  background: rgba(28, 33, 41, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
}

[data-theme="dark"] .list-panel {
  background: transparent;
  border: none;
}

[data-theme="dark"] .doc-item {
  background: rgba(30, 35, 42, 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.03);
}
[data-theme="dark"] .doc-item:hover {
  background: rgba(40, 45, 55, 0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .doc-item.active {
  background: color-mix(in srgb, var(--primary) 15%, rgba(30, 35, 42, 0.8)); /* 深色主题下主题色背景 */
  border-left: 3px solid var(--primary); /* 主题色边框 */
  padding-left: 13px;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--primary) 25%, transparent); /* 主题色阴影 */
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}

[data-theme="dark"] .doc-item-actions {
  background: linear-gradient(to left, rgba(30, 35, 42, 0.6) 0%, rgba(30, 35, 42, 0.6) 70%, transparent 100%);
}

[data-theme="dark"] .doc-item:hover .doc-item-actions {
  background: linear-gradient(to left, rgba(40, 45, 55, 0.8) 0%, rgba(40, 45, 55, 0.8) 70%, transparent 100%);
}

[data-theme="dark"] .doc-item.active .doc-item-actions {
  background: linear-gradient(to left, color-mix(in srgb, var(--primary) 15%, rgba(30, 35, 42, 0.8)) 0%, color-mix(in srgb, var(--primary) 15%, rgba(30, 35, 42, 0.8)) 70%, transparent 100%);
}

[data-theme="dark"] .doc-action-btn.delete-btn:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.15);
}

[data-theme="dark"] .input-section {
  background: rgba(31, 36, 44, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 22px rgba(0,0,0,0.32);
}

[data-theme="dark"] .input-font-controls {
  background: rgba(25, 29, 35, 0.85);
  border-top-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .input-font-controls .editor-fontsize-control input[type="range"] {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .input-font-controls .editor-fontsize-control input[type="range"]::-webkit-slider-thumb {
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] .input-font-controls .editor-fontsize-control input[type="range"]::-moz-range-thumb {
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] .input-font-controls #editorFontSizeValue {
  color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .input-font-controls .editor-fontfamily-controls select {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

[data-theme="dark"] .input-font-controls .editor-fontfamily-controls select:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

[data-theme="dark"] .input-font-controls .editor-fontfamily-controls select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .content-area {
  background: rgba(32, 38, 49, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
}

[data-theme="dark"] .token-pill {
  background: rgba(35, 42, 54, 0.7);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
[data-theme="dark"] .token-pill:hover {
  background: #283241;
}
[data-theme="dark"] .token-pill.playing,
[data-theme="dark"] .token-pill.active {
  background: linear-gradient(135deg, rgba(255, 231, 150, 0.25), rgba(217, 179, 90, 0.28));
  border-color: #d9b35a;
  box-shadow: 0 6px 22px rgba(217,179,90,0.22);
}

[data-theme="dark"] .toolbar-header {
  background: linear-gradient(135deg, #745b1e, #3c2d0b);
}

[data-theme="dark"] .footer {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0));
}

/* */
.voice-controls select#voiceSelect { min-width: 220px; height: 36px; }
.voice-controls #speedRange { width: 180px; margin: 0 6px; align-self: center; }
.voice-controls #speedValue { width: 36px; text-align: right; }
.play-all-btn { padding: 0 12px; height: 36px; display: inline-flex; align-items: center; }

.display-controls .control-label .icon { font-size: 12px; }
.display-controls input[type="checkbox"] { margin-right: 4px; margin-top: 0; align-self: center; }

/* 图标按钮统一尺寸（あ / A / 品 等） */
.control-label .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--primary);
  color: var(--primary-contrast);
  /* box-shadow: 0 4px 10px rgba(0,0,0,0.12); */
  font-weight: 700;
}

/* */
select, .btn, .new-doc-btn, .delete-doc-btn { height: 36px; }

/* */
input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* */

:root[data-theme="dark"] .theme-icon-btn {
  border-color: var(--control-border);
  color: var(--control-text);
}
:root[data-theme="dark"] .theme-icon-btn:hover {
  background: rgba(255,255,255,0.12);
}

/* */

/* */
/* */
/* */
.app-icon {
  /* */
  transition: all 0.2s ease;
}

/* */
.app-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 10001;
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
}

.app-drawer.show {
  transform: translateX(0);
}

/* */
.app-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px) saturate(140%);
  -webkit-backdrop-filter: blur(4px) saturate(140%);
  z-index: 10000; /* 低于 .app-drawer(10001)，高于主内容 */
  display: none;
}

/* */
.app-drawer.show + .app-drawer-backdrop {
  display: block;
}

:root[data-theme="dark"] .app-drawer-backdrop {
  background: rgba(0, 0, 0, 0.5);
}


.app-drawer-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.app-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
}

.app-drawer-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.app-drawer-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.app-drawer-close:hover {
  background: var(--elev);
  color: var(--text);
}

.app-drawer-body {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.app-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px;
}

.app-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.app-item:hover {
  background: var(--elev);
  border-color: var(--border);
  transform: translateX(4px);
}

.app-icon-large {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elev);
  border-radius: 12px;
  margin-right: 16px;
  color: var(--primary);
}

/* */
.app-icon-large img {
  width: 32px;
  height: 32px;
  display: block;
}

.app-info {
  flex: 1;
}

.app-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.app-desc {
  font-size: 14px;
  color: var(--muted);
}

.app-drawer-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.user-profile {
  display: flex;
  align-items: center;
  /* margin-bottom: 16px; */
}

.user-avatar {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elev);
  border-radius: 50%;
  margin-right: 12px;
  color: var(--primary);
}

.user-email {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.logout-btn {
  width: 100%;
  padding: 12px 16px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: #c82333;
  transform: translateY(-1px);
}

/* */
:root[data-theme="dark"] .app-drawer {
  background: rgba(20, 20, 20, 0.95);
  border-right-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .app-drawer-header {
  background: rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] .app-drawer-footer {
  background: rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] .app-item {
  background: rgba(255, 255, 255, 0.03);
}

:root[data-theme="dark"] .app-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.app-icon:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* */
.new-doc-group {
  position: relative;
  display: flex;
  align-items: center;
  /* gap: 2px; */
  padding-right: 5px;
}

/* */
.btn-new-dropdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  transition: background 20ms ease-in;
  flex-shrink: 0;
  color: var(--text-sec);
  display: none;
}

.btn-new-dropdown:hover {
  background: var(--elev);
}

.btn-new-dropdown.active {
  background: var(--elev);
}

/* */
.new-doc-dropdown-menu {
  position: fixed;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms;
  z-index: 1000;
  background-color: var(--elev);
  
}

.new-doc-dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* */
.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: background 20ms ease-in, color 20ms ease-in;
  text-decoration: none;
  user-select: none;
}

.dropdown-item:hover {
  background: var(--elev);
  color: var(--text);
}

.dropdown-item:active {
  background: var(--control-border);
}

/* */
:root[data-theme="dark"] .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px) saturate(120%);
  -webkit-backdrop-filter: blur(3px) saturate(120%);
  z-index: 10090;
}

.delete-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 18px 20px;
  background: var(--elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  animation: modalEnter 0.18s ease-out;
  font-size: 14px;
  z-index: 10100;
  width: 520px;
  max-width: calc(100vw - 48px);
  line-height: 1.6;
}

.delete-confirm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.delete-confirm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.delete-confirm-close {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.delete-confirm-content { gap: 14px; }
.delete-confirm-message { gap: 10px; font-size: 15px; }
.delete-confirm-icon { width: 20px; height: 20px; }
.delete-confirm-actions { gap: 10px; }
.delete-confirm-cancel { padding: 8px 14px; border-radius: 6px; font-size: 13px; min-width: 64px; }
.delete-confirm-ok { padding: 8px 14px; border-radius: 6px; font-size: 13px; min-width: 64px; }

@keyframes modalEnter {
  from { opacity: 0; transform: translate(-50%, calc(-50% - 8px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

[data-theme="dark"] .delete-confirm {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
}
.main-header-right .theme-icon-btn {
  color: var(--muted);
  /* background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,255,255,0.75)); */
  /* border-color: rgba(139,105,20,0.14); */
  /* box-shadow: 0 4px 10px rgba(139,105,20,0.08); */
  transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

/* */
#collapseMenuBtn svg path {
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* */
.btn-new svg.compose {
  width: 22px;
  height: 22px;
  display: block;
  fill: currentColor;
  flex-shrink: 0;
}

/* */
#editorDeleteBtn svg.trash {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
  flex-shrink: 0;
}

.main-header-right .theme-icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none !important;
}

.main-header-right .theme-icon-btn:hover {
  color: var(--primary);
  border-color: rgba(139,105,20,0.35);
  box-shadow: 0 8px 18px rgba(139,105,20,0.16);
  transform: translateY(-1px);
}

:root[data-theme="dark"] .main-header-right .theme-icon-btn {
  background: linear-gradient(135deg, rgba(32,36,45,0.96), rgba(19,23,30,0.92));
  border-color: rgba(217,179,90,0.24);
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  color: rgba(217,179,90,0.75);
}

:root[data-theme="dark"] .main-header-right .theme-icon-btn:hover {
  color: var(--primary);
  border-color: rgba(217,179,90,0.38);
  box-shadow: 0 10px 22px rgba(0,0,0,0.45);
}

.main-header-right .theme-icon-btn.is-loading::after {
  border-color: rgba(139, 105, 20, 0.2);
  border-top-color: var(--primary);
}

:root[data-theme="dark"] .main-header-right .theme-icon-btn.is-loading::after {
  border-color: rgba(217, 179, 90, 0.18);
  border-top-color: var(--primary);
}

/* */
:root { --font-scale: 1; }

/* */
.token-pill { font-size: calc(13px * var(--font-scale)); }
.token-details { font-size: calc(12px * var(--font-scale)); }
/* */
input[type="text"], textarea { font-size: 14px; }

/* */

/* */
.play-control-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: var(--bg);
  max-width: 860px;
}

/* */
.content-area .play-control-bar {
  padding: 10px 0;
}

/* */
.content-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 100px 0;
}
.play-control-bar::-webkit-scrollbar {
  height: 6px;
}
.play-control-bar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.play-control-bar::-webkit-scrollbar-track {
  background: transparent;
}
.play-control-bar .play-control-bar-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  transition: all 0.2s ease;
}

.play-control-bar .play-control-bar-buttons:hover {
  border-color: var(--primary);
}

.play-control-bar .play-control-bar-buttons .theme-icon-btn {
  margin: 0;
  border: none;
  border-radius: 0;
  transition: all 0.2s ease;
}

.play-control-bar .play-toggle:hover,
.play-control-bar .pause-toggle:hover {
  background: var(--elev);
}
.play-control-bar .play-progress {
  flex: 1;
  height: 6px;
  min-width: 140px;
  background: var(--control-elev);
  border: 1px solid var(--control-border);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  display: none !important;
}
.play-control-bar .play-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--primary);
}
.play-control-bar .play-volume {
  width: 80px;
  height: 20px;
  display: none;
}
:root[data-theme="dark"] .play-control-bar {
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}

/* */
[data-theme="dark"] #headerSpeedRange {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] #headerSpeedRange::-webkit-slider-thumb {
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] #headerSpeedRange::-moz-range-thumb {
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] #headerSpeedValue {
  color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] #headerVoiceSelect {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

[data-theme="dark"] #headerVoiceSelect:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

[data-theme="dark"] #headerVoiceSelect:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .play-control-bar .play-control-bar-buttons {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .play-control-bar .play-control-bar-buttons:hover {
  border-color: var(--primary);
}

[data-theme="dark"] .play-control-bar .play-toggle:hover,
[data-theme="dark"] .play-control-bar .pause-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* */
.play-control-bar .header-voice-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 5px;
  margin-left: auto; /* 将整组语音/速度控件推到右侧 */
}

/* */
#headerSpeedRange {
  width: 120px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

#headerSpeedRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#headerSpeedRange::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#headerSpeedRange::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#headerSpeedRange::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* */
#headerSpeedValue {
  font-size: 13px;
  color: var(--text-secondary-color, var(--muted));
  min-width: 42px;
  text-align: right;
  font-weight: 500;
}

/* */
#headerVoiceSelect {
  height: 26px;
    font-size: 12px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 160px;
  max-width: 200px;
}

#headerVoiceSelect:hover {
  border-color: var(--primary);
  background: var(--elev);
}

#headerVoiceSelect:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.token-kanji { font-size: calc(14px * var(--font-scale)); }
.token-kana { font-size: calc(10px * var(--font-scale)); }
.token-romaji { font-size: calc(9px * var(--font-scale)); }
.pos-tag, .token-pos { font-size: calc(8px * var(--font-scale)); }

/* */
.input-font-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 10px;
  background: var(--elev);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  border-radius: 0 0 10px 10px;
  margin-top: auto;
}

.input-font-controls .editor-fontsize-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.input-font-controls .editor-fontsize-control input[type="range"] {
  width: 100px;
  height: 5px;
  border-radius: 2.5px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.input-font-controls .editor-fontsize-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.input-font-controls .editor-fontsize-control input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.input-font-controls .editor-fontsize-control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.input-font-controls .editor-fontsize-control input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.input-font-controls #editorFontSizeValue {
  font-size: 12px;
  color: var(--text-secondary-color, var(--muted));
  min-width: 40px;
  text-align: right;
  font-weight: 500;
}

.input-font-controls .editor-fontfamily-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.input-font-controls .editor-fontfamily-controls select {
  height: 26px;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 0;
  max-width: 160px;
}

.input-font-controls .editor-fontfamily-controls select:hover {
  border-color: var(--primary);
  background: var(--elev);
}

.input-font-controls .editor-fontfamily-controls select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* */
.main-container.two-pane .input-section .input-font-controls {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--elev);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

/* */
.main-header-right .editor-fontsize-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}

#editorFontSizeValue {
  font-size: 12px;
  color: var(--text-secondary-color, #666);
}

/* */
.main-header-right .editor-fontfamily-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* margin-right: 8px; */
}
.main-header-right .editor-fontfamily-controls select {
  height: 28px;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* */
.main-container .input-section,
.main-container .content-area {
  font-size: calc(16px * var(--font-scale));
  font-family: var(--input-font-family, inherit);
}

/* */
.main-container .content-area {
  font-family: var(--content-font-family, inherit);
}
/* */
.content-container .theme-icon-btn {
  color: var(--text-secondary);
  width: 25px;
  height: 25px;
}
.content-container #headerPauseToggle:hover {
  color: var(--text-primary);
}
.content-container #headerPauseToggle.disabled {
  opacity: 0.6;
}
/* */


#collapseMenuBtn {
  display: none;
}

/* ========================================
   EasyMDE Markdown 编辑器自定义样式
   ======================================== */

/* */
.input-group .EasyMDEContainer {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* */
.input-section .EasyMDEContainer .CodeMirror {
  border: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--input-font-family, inherit);
  font-size: calc(14px * var(--font-scale));
  height: 100%;
  min-height: 200px;
  padding: 0 5px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

/* */
.input-section .EasyMDEContainer .editor-toolbar {
  background: var(--elev);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  padding: 0;
  opacity: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.input-section .EasyMDEContainer .editor-toolbar::before,
.input-section .EasyMDEContainer .editor-toolbar::after {
  display: none;
}

/* */
.input-section .EasyMDEContainer .editor-toolbar button {
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 4px;
  padding: 5px 7px;
  transition: all 0.2s;
  margin: 0;
}

.input-section .EasyMDEContainer .editor-toolbar button:hover {
  background: var(--toolbar-chip-hover);
  color: var(--text);
  border: none;
}

.input-section .EasyMDEContainer .editor-toolbar button.active {
  background: var(--toolbar-chip-bg);
  color: var(--primary);
  border: 1px solid var(--toolbar-chip-border);
}

/* */
.input-section .EasyMDEContainer .editor-toolbar i.separator {
  border-left: 1px solid var(--border);
  border-right: none;
  margin: 0 2px;
}

/* */
.input-section .EasyMDEContainer .editor-toolbar button.side-by-side i {
  transition: transform 0.3s ease;
  display: inline-block;
}

.input-section .EasyMDEContainer .editor-toolbar button.side-by-side.active i {
  transform: rotate(90deg);
}

/* */
.input-section .EasyMDEContainer .CodeMirror-scroll {
  min-height: 200px;
  max-height: 500px;
  overflow: auto;
  flex: 1 1 auto;
}

/* */
.main-container.two-pane .input-section .EasyMDEContainer {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.main-container.two-pane .input-section .EasyMDEContainer .CodeMirror-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.main-container.two-pane .input-section .EasyMDEContainer .CodeMirror {
  flex: 1 1 auto;
  height: 100%;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.main-container.two-pane .input-section .EasyMDEContainer .CodeMirror-scroll {
  height: 100%;
  min-height: 300px;
  max-height: none;
  overflow: auto;
  flex: 1 1 auto;
}

/* */
.input-section .EasyMDEContainer .CodeMirror-cursor {
  border-left: 2px solid var(--primary);
}

/* */
.input-section .EasyMDEContainer .CodeMirror-selected {
  background: color-mix(in srgb, var(--primary) 20%, transparent);
}

/* */
.input-section .EasyMDEContainer .CodeMirror-placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* */
.input-section .EasyMDEContainer .editor-preview,
.input-section .EasyMDEContainer .editor-preview-side {
  background: var(--bg);
  color: var(--text);
  padding: 15px;
  font-family: var(--content-font-family, inherit);
  line-height: 1.8;
}

/* */
.input-section .EasyMDEContainer .editor-preview p,
.input-section .EasyMDEContainer .editor-preview-side p {
  line-height: 1.8;
  margin-bottom: 1em;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side p,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side li,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side h1,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side h2,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side h3,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side h4,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side blockquote {
  display: flex;
  flex-wrap: wrap;
  align-items: self-end;
  margin-bottom: 10px;
  /* border-bottom: 1px solid var(--border); */
  /* padding-bottom: 10px; */
  /* line-height: 4em;
  min-height: 4em; */
}

/* */
.input-section .EasyMDEContainer.fullscreen {
  z-index: 9999;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.input-section .EasyMDEContainer.fullscreen .CodeMirror {
  height: 100% !important;
  min-height: 100vh;
  max-height: 100vh;
}

.input-section .EasyMDEContainer.fullscreen .CodeMirror-scroll {
  height: 100%;
  min-height: 100vh;
  max-height: 100vh;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 10000;
  flex-shrink: 0;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side {
  display: block !important;
  width: 50%;
  height: calc(100vh - 44px); /* 减去工具栏高度 */
  position: fixed;
  top: 44px; /* 工具栏高度 */
  right: 0;
  overflow: auto;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 9999;
  padding: 20px;
  font-size: 16px;
  line-height: 1.8;
  padding: 10px 40px;
}

.input-section .EasyMDEContainer.fullscreen .CodeMirror-sided {
  width: 50% !important;
}

/* */
.input-section .EasyMDEContainer.fullscreen .CodeMirror {
  position: fixed;
  top: 44px; /* 工具栏高度 */
  left: 0;
  width: 50% !important;
  height: calc(100vh - 44px) !important;
}

/* */
[data-theme="dark"] .input-section .EasyMDEContainer.fullscreen .editor-preview-side {
  background: rgba(31, 36, 44, 0.95);
  color: var(--text);
}

[data-theme="dark"] .input-section .EasyMDEContainer.fullscreen .editor-preview-side code {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .input-section .EasyMDEContainer.fullscreen .editor-preview-side pre {
  background: rgba(255, 255, 255, 0.05);
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-wrapper {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  margin: 12px 3px 8px 3px;
  vertical-align: top;
  position: relative;
  padding: 2px 0;
  /* min-height: 3.5em;
  height: 3.5em; */
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-reading {
  font-size: 0.75em;
  color: #9b59b6;
  white-space: nowrap;
  line-height: 1.3;
  min-height: 0.85em;
  height: 0.85em;
  text-align: center;
  order: 1;
  display: block;
  margin-bottom: 3px;
  font-weight: 500;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-hiragana {
  font-size: 0.7em;
  color: #e74c3c;
  white-space: nowrap;
  line-height: 1.3;
  min-height: 0.8em;
  height: 0.8em;
  text-align: center;
  order: 2;
  margin-bottom: 3px;
  display: block;
  font-weight: 500;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-romaji {
  font-size: 0.65em;
  color: #3498db;
  opacity: 0.85;
  font-style: italic;
  white-space: nowrap;
  line-height: 1.3;
  min-height: 0.75em;
  height: 0.75em;
  text-align: center;
  order: 3;
  margin-bottom: 5px;
  display: block;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-base {
  font-size: 1em;
  line-height: 1;
  color: var(--text);
  white-space: nowrap;
  min-height: 1em;
  text-align: center;
  order: 4;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-wrapper.furigana-plain .furigana-reading,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-wrapper.furigana-plain .furigana-hiragana,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-wrapper.furigana-plain .furigana-romaji {
  visibility: hidden;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-reading:empty::before,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-hiragana:empty::before,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-romaji:empty::before {
  content: '\00a0'; /* 不间断空格 */
  opacity: 0;
}

/* */
[data-theme="dark"] .input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-reading {
  color: #bb8fce;
}

[data-theme="dark"] .input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-hiragana {
  color: #f1948a;
}

[data-theme="dark"] .input-section .EasyMDEContainer.fullscreen .editor-preview-side .furigana-romaji {
  color: #5dade2;
  opacity: 0.9;
}

/* */
.input-section .EasyMDEContainer.fullscreen .editor-preview-side h1,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side h2,
.input-section .EasyMDEContainer.fullscreen .editor-preview-side h3 {
  color: var(--text);
  /* margin-top: 1.5em; */
  margin-bottom: 0.5em;
}

.input-section .EasyMDEContainer.fullscreen .editor-preview-side h1 {
  font-size: 2em;
  padding-bottom: 0.3em;
}

.input-section .EasyMDEContainer.fullscreen .editor-preview-side h2 {
  font-size: 1.5em;
  padding-bottom: 0.2em;
}

.input-section .EasyMDEContainer.fullscreen .editor-preview-side code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
}

.input-section .EasyMDEContainer.fullscreen .editor-preview-side pre {
  background: rgba(0, 0, 0, 0.1);
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
}

.input-section .EasyMDEContainer.fullscreen .editor-preview-side blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1em;
  margin-left: 0;
  color: var(--text-light);
}

/* */
[data-theme="dark"] .input-section .EasyMDEContainer .CodeMirror {
  background: rgba(31, 36, 44, 0.72);
  color: var(--text);
}

[data-theme="dark"] .input-section .EasyMDEContainer .editor-toolbar {
  background: rgba(25, 29, 35, 0.85);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .input-section .EasyMDEContainer .editor-toolbar button {
  color: var(--muted);
}

[data-theme="dark"] .input-section .EasyMDEContainer .editor-toolbar button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

[data-theme="dark"] .input-section .EasyMDEContainer .editor-preview,
[data-theme="dark"] .input-section .EasyMDEContainer .editor-preview-side {
  background: rgba(31, 36, 44, 0.72);
  color: var(--text);
}

/* */
.input-section .EasyMDEContainer .cm-header {
  color: var(--primary);
  font-weight: bold;
}

.input-section .EasyMDEContainer .cm-quote {
  color: var(--muted);
  font-style: italic;
}

.input-section .EasyMDEContainer .cm-link {
  color: var(--primary);
  text-decoration: underline;
}

.input-section .EasyMDEContainer .cm-strong {
  font-weight: bold;
}

.input-section .EasyMDEContainer .cm-em {
  font-style: italic;
}

/* ============================================================
   EPUB / Ebook view (ajout pour le mode lecture de livre traduit)
   ============================================================ */

.ebook-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--bg-secondary, #f7f8fb);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
}

.ebook-meta { min-width: 0; }

.ebook-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text, #1a202c);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ebook-author {
  font-size: 0.85rem;
  color: var(--muted, #718096);
  margin-top: 0.2rem;
}

.ebook-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ebook-nav-btn {
  background: var(--primary, #4a90e2);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: opacity 0.15s;
}
.ebook-nav-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ebook-nav-btn:not(:disabled):hover { filter: brightness(1.08); }

.ebook-chapter-select {
  max-width: 280px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border, #cbd5e0);
  border-radius: 6px;
  background: #fff;
  font-size: 0.85rem;
}

.ebook-untranslated {
  padding: 1.5rem;
  text-align: center;
  background: var(--bg-secondary, #f7f8fb);
  border-radius: 10px;
  margin-top: 1rem;
}

.ebook-french-preview {
  text-align: left;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  max-height: 260px;
  overflow-y: auto;
}

.ebook-french-label {
  font-size: 0.8rem;
  color: var(--muted, #718096);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ebook-french-body {
  color: var(--text, #2d3748);
  line-height: 1.6;
  white-space: pre-wrap;
}

.ebook-translate-btn {
  min-width: 260px;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
}
.ebook-translate-btn:disabled { opacity: 0.6; cursor: wait; }

.ebook-translate-hint {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted, #718096);
}

.ebook-analyzing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 2rem;
  color: var(--muted, #718096);
}

.ebook-error {
  padding: 1rem;
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 8px;
  color: #c53030;
}
.ebook-error-message { margin-bottom: 0.75rem; }

.ebook-import-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  padding: 0.7rem 1.2rem;
  background: var(--text, #2d3748);
  color: #fff;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 9999;
  pointer-events: none;
}
.ebook-import-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ebook-import-toast.error { background: #c53030; }

/* Gloses françaises sur les groupes sémantiques */
.token-pill.in-semantic-group {
  position: relative;
  background-image: linear-gradient(to bottom, transparent calc(100% - 2px), rgba(74, 144, 226, 0.35) calc(100% - 2px));
}
.token-pill.group-start { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.token-pill.group-end { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }

.fr-gloss {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 0;
  white-space: nowrap;
  font-size: 0.7rem;
  color: #4a90e2;
  background: rgba(74, 144, 226, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  pointer-events: none;
  font-style: italic;
  z-index: 5;
}

.line-container { padding-top: 1.5rem; }

@media (max-width: 640px) {
  .ebook-header { flex-direction: column; align-items: stretch; }
  .ebook-nav { justify-content: space-between; }
  .ebook-chapter-select { flex: 1; max-width: none; }
  .fr-gloss { font-size: 0.65rem; }
}

/* ============================================================
   Karakoto — Panneau flottant OpenAI TTS (haute qualité)
   ============================================================ */
.kk-tts-toggle-btn {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kk-tts-toggle-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.kk-tts-panel {
  position: fixed;
  bottom: 72px;
  right: 18px;
  width: 280px;
  padding: 14px 14px 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  z-index: 9001;
  font-size: 0.88rem;
  color: #2d3748;
}
.kk-tts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.kk-tts-title {
  font-weight: 700;
  color: #4a5568;
}
.kk-tts-close {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #a0aec0;
  cursor: pointer;
  padding: 0 4px;
}
.kk-tts-close:hover { color: #4a5568; }
.kk-tts-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}
.kk-tts-row select {
  min-width: 120px;
  padding: 4px 6px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
}
.kk-tts-switch-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.kk-tts-hint {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #edf2f7;
  font-size: 0.75rem;
  color: #718096;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .kk-tts-toggle-btn { bottom: 14px; right: 14px; }
  .kk-tts-panel { right: 10px; left: 10px; width: auto; bottom: 66px; }
}

/* Masquer l'éditeur EasyMDE quand on lit un ebook (mode lecture pur) */
.input-section.karakoto-ebook-mode {
  display: none !important;
}

/* ============================================================
   Karakoto — ajustements tablette Android (Xiaomi Pad 7 Pro, 11")
   ============================================================ */
@media (min-width: 769px) and (max-width: 1280px) and (pointer: coarse) {
  /* Boutons plus cliquables au doigt */
  .ebook-nav-btn,
  .ebook-translate-btn,
  .karakoto-submit-btn,
  .btn {
    min-height: 44px;
  }
  .token-pill {
    padding: 8px 10px;
  }
  .fr-gloss {
    font-size: 0.78rem;
  }
  .kk-tts-toggle-btn {
    width: 52px;
    height: 52px;
    bottom: 22px;
    right: 22px;
  }
  /* Navigation de chapitres plus lisible en paysage tablette */
  .ebook-chapter-select {
    max-width: 360px;
    font-size: 0.95rem;
  }
}

/* ============================================================
   Karakoto — Carte ebook enrichie dans la sidebar
   ============================================================ */

.doc-item.karakoto-ebook-item {
  padding-bottom: 10px;
}

.doc-item.karakoto-ebook-item .doc-item-title {
  font-weight: 600;
  line-height: 1.3;
}

.karakoto-ebook-meta {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
}

.karakoto-ebook-author {
  color: var(--muted, #718096);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.karakoto-ebook-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.karakoto-ebook-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(74, 144, 226, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.karakoto-ebook-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transition: width 0.3s ease;
}

.karakoto-ebook-progress-label {
  font-variant-numeric: tabular-nums;
  color: var(--muted, #4a5568);
  font-size: 0.7rem;
  font-weight: 600;
}

.karakoto-ebook-current {
  color: var(--muted, #718096);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-item.karakoto-ebook-item.active .karakoto-ebook-progress-bar {
  background: rgba(255, 255, 255, 0.25);
}
.doc-item.karakoto-ebook-item.active .karakoto-ebook-author,
.doc-item.karakoto-ebook-item.active .karakoto-ebook-current,
.doc-item.karakoto-ebook-item.active .karakoto-ebook-progress-label {
  color: rgba(255, 255, 255, 0.9);
}

/* ============================================================
   Karakoto — Bouton "Traduire FR → JP" dans l'éditeur
   ============================================================ */
.karakoto-translate-editor-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem 0;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, opacity 0.15s;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}
.karakoto-translate-editor-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.karakoto-translate-editor-btn:active:not(:disabled) {
  transform: translateY(0);
}
.karakoto-translate-editor-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.karakoto-translate-editor-btn svg {
  flex-shrink: 0;
}

.karakoto-translate-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999;
  pointer-events: none;
  max-width: 80vw;
  text-align: center;
}
.karakoto-translate-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.karakoto-translate-toast.error {
  background: linear-gradient(135deg, #c53030 0%, #822727 100%);
}

@media (max-width: 640px) {
  .karakoto-translate-editor-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================
   Karakoto — Layout 3 panneaux (FR / JP / Analyse)
   ============================================================ */

/* Le conteneur hérité .editor-panels devient un flex vertical à 3 zones */
.editor-panels.three-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Panneau 1 : saisie française */
.french-input-section {
  flex: 0 1 25%;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 12px;
  background: #fbfbfd;
  border-bottom: 1px solid #e2e8f0;
  box-sizing: border-box;
}

.french-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.french-input-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6366f1;
}
.french-input-status {
  font-size: 0.78rem;
  color: var(--muted, #718096);
  min-height: 1em;
}
.french-input-status.error {
  color: #c53030;
  font-weight: 600;
}
.french-input-status.success {
  color: #38a169;
}

#frenchInput {
  flex: 1 1 auto;
  min-height: 60px;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #cbd5e0;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1.5;
  background: #fff;
  color: #1a202c;
  resize: none;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
#frenchInput:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
#frenchInput:disabled {
  background: #f7fafc;
  cursor: not-allowed;
}

.karakoto-translate-editor-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, opacity 0.15s;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}
.karakoto-translate-editor-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.karakoto-translate-editor-btn:active:not(:disabled) {
  transform: translateY(0);
}
.karakoto-translate-editor-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  box-shadow: none;
}
.karakoto-translate-editor-btn svg { flex-shrink: 0; }

/* Panneau 2 : JP lecture seule */
.editor-panels.three-pane .input-section {
  flex: 1 1 35%;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.editor-panels.three-pane .input-section.read-only .EasyMDEContainer .CodeMirror {
  background: #f9f9fb;
}
.jp-pane-label {
  padding: 6px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4a5568;
  background: #edf2f7;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

/* Panneau 3 : zone d'analyse (existe déjà, juste flex) */
.editor-panels.three-pane .content-area {
  flex: 1 1 40%;
  min-height: 150px;
}

/* Resizers (top + existant) — tactiles */
.editor-panels.three-pane .resizer {
  flex-shrink: 0;
  height: 8px;
  background: #edf2f7;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  cursor: ns-resize;
  position: relative;
  transition: background 0.15s;
}
.editor-panels.three-pane .resizer::before {
  content: '';
  position: absolute;
  top: -8px; bottom: -8px;
  left: 0; right: 0;
}
.editor-panels.three-pane .resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 3px;
  background: #a0aec0;
  border-radius: 2px;
}
.editor-panels.three-pane .resizer:hover {
  background: #e2e8f0;
}

/* Mode ebook : masquer le panneau FR (les ebooks ont leur propre flow) */
body.mode-ebook .french-input-section,
body.mode-ebook #panelResizerTop {
  display: none !important;
}

/* Responsive tablette (Xiaomi Pad et autres ~11") */
@media (max-width: 1024px) {
  .french-input-section {
    min-height: 110px;
    padding: 8px 12px 10px;
  }
  .karakoto-translate-editor-btn {
    padding: 14px 16px;
    font-size: 1rem;
  }
  .editor-panels.three-pane .resizer {
    height: 14px;
  }
  .editor-panels.three-pane .resizer::before {
    top: -10px; bottom: -10px;
  }
}

@media (max-width: 640px) {
  .french-input-section {
    min-height: 90px;
  }
  #frenchInput { font-size: 0.95rem; }
  .french-input-label, .jp-pane-label { font-size: 0.72rem; }
}

/* ============================================================
   Karakoto — Modale Bibliothèque EPUB cloud
   ============================================================ */
.karakoto-library-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.karakoto-library-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}
.karakoto-library-panel {
  position: relative;
  width: min(720px, 92vw);
  max-height: 82vh;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #1a202c;
}
.karakoto-library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: #fff;
}
.karakoto-library-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}
.karakoto-library-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  opacity: 0.85;
}
.karakoto-library-close:hover { opacity: 1; }

.karakoto-library-body {
  flex: 1 1 auto;
  padding: 14px 18px;
  overflow-y: auto;
}
.karakoto-library-footer {
  padding: 10px 18px;
  border-top: 1px solid #e2e8f0;
  background: #f7fafc;
}
.karakoto-library-hint {
  font-size: 0.78rem;
  color: #718096;
}

.karakoto-library-loading,
.karakoto-library-error,
.karakoto-library-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #718096;
}
.karakoto-library-error { color: #c53030; }
.karakoto-library-empty p { margin: 0.25rem 0; }
.karakoto-library-sub { font-size: 0.85rem; color: #a0aec0; }

.karakoto-library-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.karakoto-library-item:hover {
  border-color: #cbd5e0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.karakoto-library-item-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.karakoto-library-item-meta {
  flex: 1 1 auto;
  min-width: 0;
}
.karakoto-library-item-name {
  font-weight: 600;
  color: #2d3748;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.karakoto-library-item-sub {
  font-size: 0.78rem;
  color: #718096;
  margin-top: 2px;
}
.karakoto-library-imported { color: #38a169; font-weight: 600; }

.karakoto-library-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.karakoto-library-btn {
  padding: 6px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background: #fff;
  color: #2d3748;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}
.karakoto-library-btn:hover:not(:disabled) { background: #f7fafc; }
.karakoto-library-btn:disabled { opacity: 0.55; cursor: wait; }
.karakoto-library-btn.primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: #fff;
  border-color: transparent;
}
.karakoto-library-btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.karakoto-library-btn.danger {
  padding: 6px 10px;
  font-size: 1rem;
}
.karakoto-library-btn.danger:hover:not(:disabled) {
  background: #fff5f5;
  border-color: #feb2b2;
  color: #c53030;
}

@media (max-width: 640px) {
  .karakoto-library-item { flex-wrap: wrap; }
  .karakoto-library-item-actions { width: 100%; justify-content: flex-end; }
}

/* ============================================================
   Karakoto — Glose française mot-par-mot sous chaque pill
   (5ᵉ ligne après kana / romaji / kanji / pos)
   ============================================================ */
.token-fr-gloss {
  font-size: 9px;
  line-height: 1.25;
  color: #6366f1;         /* violet, marque visuelle "FR" */
  font-style: italic;
  text-align: center;
  min-height: 11px;
  padding: 2px 3px 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
  margin-top: 2px;
  border-top: 1px dashed rgba(99, 102, 241, 0.2);
  width: 100%;
  box-sizing: border-box;
}
.token-fr-gloss:empty {
  display: none;
}

/* En mode lecture / mobile réduit : légèrement plus petit pour tenir */
@media (max-width: 640px) {
  .token-fr-gloss {
    font-size: 8px;
    padding: 1px 2px 0;
  }
}

/* ============================================================
   Karakoto — Bouton "+ Ajouter un livre" dans la bibliothèque
   ============================================================ */
.karakoto-library-actions {
  padding: 12px 18px 0;
  border-bottom: 1px solid #edf2f7;
  background: #fafbfc;
}
.karakoto-library-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1.5px dashed #8b5cf6;
  border-radius: 10px;
  background: #fff;
  color: #6366f1;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.karakoto-library-add-btn:hover:not(:disabled) {
  background: #f5f3ff;
  border-color: #6366f1;
}
.karakoto-library-add-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.karakoto-library-add-btn svg {
  flex-shrink: 0;
}

/* ============================================================
   Karakoto — Bouton Pause en attente (gracieuse fin de phrase)
   ============================================================ */
.pause-pending {
  position: relative;
  background: rgba(139, 92, 246, 0.15) !important;
  animation: karakoto-pause-pulse 1.2s ease-in-out infinite;
}
@keyframes karakoto-pause-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.pause-pending::after {
  content: '…';
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 10px;
  color: #6366f1;
  background: #fff;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  line-height: 8px;
  text-align: center;
}
