:root {
  --bg: #fbfcf8;
  --surface: #ffffff;
  --surface-soft: #f3faf8;
  --surface-warm: #fff5ed;
  --ink: #172027;
  --muted: #69777a;
  --faint: #dfe8e4;
  --teal: #058f86;
  --teal-dark: #03766f;
  --coral: #df6a4c;
  --yellow: #f4c95a;
  --leaf: #78a865;
  --shadow: 0 18px 44px rgba(22, 32, 39, 0.09);
  --soft-shadow: 0 10px 28px rgba(22, 32, 39, 0.07);
  --radius: 8px;
  --fast: 180ms ease;
  font-family:
    Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(251, 252, 248, 0.96), rgba(251, 252, 248, 0.92)),
    radial-gradient(circle at 92% 12%, rgba(244, 201, 90, 0.18), transparent 24%),
    radial-gradient(circle at 4% 72%, rgba(5, 143, 134, 0.1), transparent 28%);
}

button,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

svg {
  display: block;
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 92px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 76px;
  padding: 12px 30px;
  border-bottom: 1px solid rgba(23, 32, 39, 0.08);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 186px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--teal);
}

.brand-mark svg {
  width: 38px;
  height: 38px;
  stroke-width: 1.6;
}

.brand-mark path:first-child {
  fill: rgba(5, 143, 134, 0.14);
}

.brand strong {
  display: block;
  font-size: 1.26rem;
  font-weight: 800;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.tab,
.control-button,
.select-shell,
.icon-button,
.profile {
  min-height: 42px;
  border: 1px solid rgba(23, 32, 39, 0.08);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition:
    transform var(--fast),
    border-color var(--fast),
    background var(--fast),
    color var(--fast),
    box-shadow var(--fast);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  color: #344144;
  font-size: 0.96rem;
  font-weight: 700;
}

.tab .icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
}

.tab.active {
  border-color: transparent;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 20px rgba(5, 143, 134, 0.22);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 17px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--teal);
  font-weight: 700;
  white-space: nowrap;
}

.leaf-dot,
.sprout {
  width: 13px;
  height: 16px;
  border-radius: 90% 0 90% 0;
  background: var(--teal);
  transform: rotate(34deg);
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  color: #344144;
}

.icon-button:hover,
.control-button:hover,
.tab:not(.active):hover,
.profile:hover {
  transform: translateY(-1px);
  border-color: rgba(5, 143, 134, 0.28);
  box-shadow: var(--soft-shadow);
}

.profile {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 105px;
  padding: 0 10px 0 6px;
  background: transparent;
  border-color: transparent;
  font-weight: 700;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: #dfeee9;
  color: var(--teal-dark);
  font-weight: 900;
}

.profile svg {
  width: 15px;
  height: 15px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(580px, 1.35fr) minmax(430px, 0.95fr);
  grid-template-rows: auto auto;
  gap: 18px;
  width: min(1560px, calc(100vw - 44px));
  margin: 18px auto 0;
}

.panel {
  border: 1px solid rgba(23, 32, 39, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--soft-shadow);
}

.reading-panel {
  min-height: 526px;
  padding: 22px 22px 16px;
}

.bridge-panel {
  padding: 22px;
}

.vocab-panel,
.writing-panel {
  min-height: 218px;
  padding: 20px 22px 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(23, 32, 39, 0.08);
}

.compact-head {
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: clamp(1.7rem, 2.6vw, 2.35rem);
  font-weight: 800;
  line-height: 1.18;
}

h2 {
  font-size: 1.35rem;
  font-weight: 850;
  line-height: 1.2;
}

.subline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.reader-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 92px;
  padding: 0 14px;
  color: var(--teal);
  font-size: 0.92rem;
  font-weight: 800;
}

.control-button.is-playing {
  border-color: transparent;
  background: var(--teal);
  color: #fff;
}

.select-shell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 154px;
  padding: 0 10px 0 14px;
}

.select-shell span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

select {
  width: 72px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.reader-stage {
  position: relative;
  min-height: 320px;
  padding: 20px 8px 10px 52px;
}

.reading-lines {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  min-width: 0;
  counter-reset: line;
}

.reading-line {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  min-height: 50px;
  padding: 9px 12px 9px 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  list-style: none;
  transition:
    background var(--fast),
    border-color var(--fast),
    color var(--fast),
    opacity var(--fast),
    transform var(--fast);
}

.reading-line::before {
  display: grid;
  place-items: center;
  color: #9aabab;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  content: attr(data-line);
}

.line-content {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.line-text {
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: clamp(1.32rem, 1.86vw, 1.78rem);
  font-weight: 760;
  line-height: 1.45;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.line-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
}

.pinyin,
.gloss,
.pause-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pinyin,
.gloss {
  display: inline;
}

.pause-chip {
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(244, 201, 90, 0.18);
  color: #8b671b;
  font-weight: 700;
}

.gloss {
  color: #526165;
  flex: 1 1 220px;
}

.reading-line.active {
  border-color: rgba(244, 201, 90, 0.9);
  background:
    linear-gradient(90deg, rgba(5, 143, 134, 0.08), transparent 16%),
    rgba(255, 249, 232, 0.78);
  box-shadow: inset 4px 0 0 var(--teal);
}

.reading-line.active .line-text {
  color: var(--teal-dark);
}

.reader-stage.focus-on .reading-line:not(.active) {
  opacity: 0.34;
}

.reader-stage.focus-on .reading-line.active {
  transform: translateX(3px);
}

.focus-guide {
  position: absolute;
  top: 0;
  left: 14px;
  width: 42px;
  height: 28px;
  transition: transform 260ms ease;
  pointer-events: none;
}

.guide-pin {
  position: absolute;
  top: 7px;
  left: 21px;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 8px 18px rgba(5, 143, 134, 0.24);
  animation: softBounce 1.5s ease-in-out infinite;
}

.guide-pin::after {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--yellow);
  content: "";
}

.guide-trail {
  position: absolute;
  top: 15px;
  right: 21px;
  width: 46px;
  border-top: 3px dotted rgba(5, 143, 134, 0.5);
}

.line-counter {
  position: absolute;
  top: 20px;
  right: 4px;
  display: inline-flex;
  gap: 4px;
  min-height: 36px;
  align-items: center;
  padding: 0 17px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 800;
}

.line-counter strong {
  color: var(--teal);
}

.reader-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(23, 32, 39, 0.08);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: #465557;
  font-size: 0.9rem;
  font-weight: 750;
  white-space: nowrap;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch span {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #d8e2df;
  transition: background var(--fast);
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(23, 32, 39, 0.18);
  transition: transform var(--fast);
  content: "";
}

.switch input:checked + span {
  background: var(--teal);
}

.switch input:checked + span::after {
  transform: translateX(14px);
}

.step-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.primary-icon {
  border-color: transparent;
  background: var(--teal);
  color: #fff;
}

.tiny-tag {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--surface-warm);
  color: var(--coral);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.comparison-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  margin-top: 8px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #edf9f6, #fff1ea);
}

.language-side {
  display: grid;
  align-content: center;
  min-height: 150px;
  gap: 9px;
  padding: 20px 24px;
}

.language-side span {
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 850;
}

.en-side span {
  color: var(--coral);
}

.language-side strong {
  font-size: 1.08rem;
  font-weight: 780;
  line-height: 1.52;
  letter-spacing: 0;
}

.cn-side strong {
  color: var(--teal-dark);
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 1.36rem;
}

.language-side em {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: normal;
  line-height: 1.45;
}

.bridge-swap {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(23, 32, 39, 0.08);
  border-radius: 50%;
  background: #fff;
  color: #435154;
  transform: translate(-50%, -50%);
  box-shadow: var(--soft-shadow);
}

.sound-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  color: #5c686b;
}

.compare-table {
  display: grid;
  gap: 1px;
  overflow: hidden;
  margin-top: 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(23, 32, 39, 0.06);
  background: rgba(23, 32, 39, 0.06);
}

.compare-row {
  display: grid;
  grid-template-columns: 72px 1fr 1fr;
  min-height: 52px;
  background: #fff;
}

.compare-row b,
.compare-row span {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  line-height: 1.42;
}

.compare-row b {
  background: #ecf7f4;
  color: var(--teal);
  font-size: 0.92rem;
}

.compare-row span {
  color: #4f5c5f;
  font-size: 0.86rem;
}

.compare-row span:last-child {
  background: #fff5ef;
}

.insight-strip {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(244, 201, 90, 0.55);
  border-radius: var(--radius);
  background: rgba(255, 249, 232, 0.62);
  color: #715a1f;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.5;
}

.insight-strip svg {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  color: #d9a92f;
}

.visual-banner {
  overflow: hidden;
  height: 76px;
  margin-top: 12px;
  border-radius: var(--radius);
}

.visual-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 46%;
  filter: saturate(0.94);
}

.vocab-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(96px, 1fr));
  gap: 12px;
}

.word-card {
  display: grid;
  align-content: space-between;
  min-height: 126px;
  padding: 14px;
  border: 1px solid rgba(23, 32, 39, 0.1);
  border-radius: var(--radius);
  background: #fff;
}

.word-card.is-learned {
  border-color: rgba(5, 143, 134, 0.36);
  background: #f2fbf8;
}

.word-card strong {
  display: block;
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 1.24rem;
  line-height: 1.1;
}

.word-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.word-card p {
  margin: 8px 0 10px;
  color: #4b595c;
  font-size: 0.82rem;
  line-height: 1.36;
}

.word-card button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  justify-self: center;
  border: 1px solid rgba(5, 143, 134, 0.2);
  border-radius: 50%;
  background: #fff;
  color: var(--teal);
  font-size: 1.04rem;
  font-weight: 900;
}

.mini-progress {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.mini-progress div,
.dock-bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #dce4e1;
}

.mini-progress i,
.dock-bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width var(--fast);
}

.mini-progress strong {
  color: var(--teal);
}

.writing-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

textarea {
  width: 100%;
  min-height: 88px;
  margin-top: 2px;
  padding: 16px;
  resize: none;
  border: 1px solid rgba(23, 32, 39, 0.14);
  border-radius: var(--radius);
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-size: 1rem;
  line-height: 1.7;
  transition:
    border-color var(--fast),
    box-shadow var(--fast);
}

textarea:focus {
  border-color: rgba(5, 143, 134, 0.58);
  box-shadow: 0 0 0 4px rgba(5, 143, 134, 0.1);
}

.writing-actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.ghost {
  background: #fff;
  color: var(--teal);
}

.save-button {
  min-width: 108px;
  border-color: transparent;
  background: var(--teal);
  color: #fff;
}

#charCount {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

.progress-dock {
  position: fixed;
  right: 22px;
  bottom: 16px;
  left: 22px;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(300px, 1.2fr) auto minmax(240px, 0.8fr);
  gap: 18px;
  align-items: center;
  width: min(980px, calc(100vw - 44px));
  margin: 0 auto;
  padding: 14px 20px;
  border: 1px solid rgba(23, 32, 39, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.91);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.dock-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 36px;
  color: #435154;
  font-weight: 750;
  white-space: nowrap;
}

.dock-item svg {
  color: #59686b;
}

.dock-item strong {
  color: var(--teal);
  font-size: 1.02rem;
}

.dock-bar {
  flex: 1;
  min-width: 132px;
}

.dock-note {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: #61705f;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 1.02rem;
  font-weight: 760;
  white-space: nowrap;
}

.sprout {
  width: 12px;
  height: 15px;
  background: var(--leaf);
}

@keyframes softBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.03);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .tabs {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

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

  .vocab-cards {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding-bottom: 150px;
  }

  .topbar {
    gap: 12px;
    padding: 12px 14px;
  }

  .brand {
    min-width: 0;
  }

  .brand small,
  .profile span:not(.avatar),
  .session-pill {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .tabs {
    gap: 7px;
  }

  .tab {
    min-width: max-content;
    padding: 0 12px;
    font-size: 0.88rem;
  }

  .workspace {
    width: calc(100vw - 24px);
    margin-top: 12px;
    gap: 12px;
  }

  .reading-panel,
  .bridge-panel,
  .vocab-panel,
  .writing-panel {
    padding: 16px;
  }

  .panel-head {
    display: grid;
  }

  .reader-tools {
    justify-content: flex-start;
  }

  .reader-stage {
    min-height: 380px;
    padding: 22px 14px 12px 18px;
  }

  .reading-line {
    grid-template-columns: 28px minmax(0, 1fr);
    width: calc(100% - 12px);
    padding-right: 8px;
  }

  .line-text {
    font-size: 1.28rem;
  }

  .line-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
  }

  .gloss {
    display: none;
  }

  .pause-chip {
    width: fit-content;
  }

  .focus-guide {
    left: -7px;
  }

  .line-counter {
    position: static;
    width: fit-content;
    margin: 8px 0 0 auto;
  }

  .reader-controls {
    gap: 9px 12px;
  }

  .step-buttons {
    width: 100%;
    margin-left: 0;
  }

  .step-buttons .icon-button {
    flex: 1;
    width: auto;
  }

  .comparison-card,
  .compare-row {
    grid-template-columns: 1fr;
  }

  .bridge-swap {
    top: 50%;
    transform: translate(-50%, -50%) rotate(90deg);
  }

  .language-side {
    min-height: 142px;
    padding: 20px;
  }

  .vocab-cards {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .writing-actions {
    grid-template-columns: 1fr auto;
  }

  #charCount {
    order: -1;
    grid-column: 1 / -1;
    text-align: left;
  }

  .progress-dock {
    right: 12px;
    bottom: 10px;
    left: 12px;
    grid-template-columns: 1fr;
    width: auto;
    gap: 8px;
    padding: 12px;
  }

  .dock-note {
    justify-content: flex-start;
  }
}
