* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #f5f6f8;
  color: #333;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶部标题 ---------- */
.header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 24px 12px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo .logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}

.header h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge {
  position: absolute;
  right: 24px;
  top: 32px;
  font-size: 12px;
  color: #999;
  padding: 2px 10px;
  border: 1px solid #e5e5e5;
  border-radius: 20px;
  background: #fff;
}
.badge.live { color: #18a058; border-color: #c9ecd8; }
.badge.err { color: #e03e3e; border-color: #f5cccc; }

/* ---------- 主面板 ---------- */
.panel {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto 20px;
  padding: 18px 28px 20px;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  flex: 1;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 17px;
  font-weight: 700;
  color: #222;
}

textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-family: inherit;
  font-size: 17px;
  line-height: 1.7;
  color: #333;
  resize: vertical;
  outline: none;
  background: #fff;
}
textarea:focus { border-color: #1677ff; box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.08); }
textarea::placeholder {
  color: #000;
  opacity: 1;
}

.field { margin-top: 12px; }

/* ---------- 下拉选择 ---------- */
.row2 {
  display: flex;
  gap: 20px;
}
.row2 .col {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.row2 .col .field-label {
  margin-bottom: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}
.select-control {
  position: relative;
  flex: 1;
  min-width: 0;
}
.select-control > select { width: 100%; min-width: 0; }
.mobile-select-trigger,
.mobile-select-menu { display: none; }

select {
  display: block;
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
  font-size: 16px;
  color: #333;
  outline: none;
  cursor: pointer;
}
select:focus { border-color: #1677ff; box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.08); }

/* ---------- 语速 ---------- */
.speed-val {
  font-size: 15px;
  font-weight: 400;
  color: #888;
  margin-left: 6px;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: #e8e8e8;
  outline: none;
  margin: 10px 0 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #1677ff;
  cursor: pointer;
}

/* ---------- 按钮 ---------- */
.center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

button {
  font-family: inherit;
  font-size: 16px;
  border: none;
  cursor: pointer;
}

button.primary {
  min-width: 170px;
  padding: 11px 30px;
  background: #1677ff;
  color: #fff;
  border-radius: 4px;
}
button.primary:hover { background: #4096ff; }
button.primary:disabled { background: #a8c7fa; cursor: default; }

.status {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: #999;
  min-height: 20px;
}

.mini-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 2px;
}
button.link {
  padding: 0;
  background: none;
  color: #9aa0a6;
  font-size: 14px;
  text-decoration: underline;
}
button.link:hover { color: #1677ff; }
#stop { margin: 0; }
#stop[hidden] { display: none; }

/* ---------- 跟读高亮 ---------- */
.reader {
  margin-top: 12px;
  padding: 10px 16px 12px;
  min-height: 150px;
  max-height: 460px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid #ededed;
  border-radius: 4px;
  background: #fcfcfd;
  font-size: 20px;
  line-height: 2;
}

/* 普通话 / 方言 逐句对照 */
.reader .pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 18px;
  min-width: 0;
  padding: 5px 0;
  border-bottom: 1px dashed #f0f0f0;
}
.reader .pair:last-child { border-bottom: none; }
.reader .pair.single { grid-template-columns: 1fr; }

.reader .cell {
  display: block;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: #b9bec5;
  overflow-wrap: anywhere;
  word-break: normal;
  transition: color 0.15s linear;
}
.reader .cell .tag {
  display: inline-block;
  margin-right: 6px;
  padding: 0 4px;
  border: 1px solid #ececec;
  border-radius: 3px;
  font-size: 13px;
  color: #a0a6ad;
  vertical-align: 1px;
}
.reader .cell .ch { display: inline; }
.reader .ch.cur { color: #111; text-decoration: underline; text-decoration-color: #e63946; text-decoration-thickness: 2px; text-underline-offset: 3px; }
/* 已读过的红线下划线保留，不消失 */
.reader .ch.read { color: #333; text-decoration: underline; text-decoration-color: #e63946; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.reader .placeholder {
  margin: 0;
  color: #b5b9bf;
  font-size: 18px;
}

/* ---------- 快捷跳转 ---------- */
.quick-links {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-top: 24px;
  padding: 16px 0 6px;
  border-top: 1px solid #f0f0f0;
  font-size: 19px;
}
.quick-links a {
  color: #2f7de1;
  text-decoration: none;
}
.quick-links a:hover { text-decoration: underline; }
.quick-links .current {
  color: #2f7de1;
  font-weight: 600;
}
.quick-links a.current {
  color: #2f7de1;
  font-weight: 600;
}

/* ---------- 页脚 ---------- */
.footer {
  margin-top: auto;
  padding: 14px 20px 16px;
  background: #1a6dff;
  color: #fff;
  text-align: center;
  font-size: 14px;
  line-height: 1.85;
}
.footer .footer-copy { opacity: 0.8; font-size: 13px; }
.footer .footer-icp a { color: rgba(255,255,255,0.9); text-decoration: none; font-size: 13px; }
.footer .footer-icp a:hover { color: #fff; text-decoration: underline; }

@media (max-width: 640px) {
  body { font-size: 16px; background: #fff; }
  .header { padding: 18px 16px 12px; background: #fff; }
  .header h1 { font-size: 21px; }
  .badge { position: static; margin-left: auto; }
  .panel {
    padding: 18px 16px 24px;
    margin: 0;
    background: #fff;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .radios { gap: 10px 18px; }
  .row2 { flex-direction: row; gap: 10px; }
  .row2 .col { width: auto; min-width: 0; }
  .row2 .select-control { width: 100%; min-width: 0; }
  .row2 .col .field-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .select-control.mobile-ready > select { display: none; }
  .select-control.mobile-ready > .mobile-select-trigger {
    display: flex;
    align-items: center;
    width: 100%;
    height: 42px;
    padding: 0 34px 0 10px;
    overflow: hidden;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 16px;
    line-height: 1.4;
    text-align: left;
    white-space: nowrap;
  }
  .mobile-select-trigger:focus-visible {
    border-color: #1677ff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.08);
    outline: none;
  }
  .mobile-select-trigger:disabled {
    background: #f7f7f7;
    color: #999;
    cursor: default;
  }
  .mobile-select-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-select-chevron {
    position: absolute;
    top: 50%;
    right: 12px;
    width: 8px;
    height: 8px;
    border-right: 1.5px solid #666;
    border-bottom: 1.5px solid #666;
    transform: translateY(-70%) rotate(45deg);
  }
  .select-control.mobile-ready > .mobile-select-menu:not([hidden]) {
    display: flex;
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1000;
    flex-direction: column;
    width: min(360px, calc(100vw - 40px));
    max-width: calc(100vw - 40px);
    max-height: min(72vh, 520px);
    padding: 0;
    overflow: hidden;
    border: 1px solid #e2e2e2;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.24);
    transform: translate(-50%, -50%);
  }
  body.mobile-select-open { overflow: hidden; }
  body.mobile-select-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0, 0, 0, 0.36);
  }
  .mobile-select-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 0 12px 0 18px;
    border-bottom: 1px solid #f0f0f0;
  }
  .mobile-select-title {
    color: #222;
    font-size: 17px;
    font-weight: 700;
  }
  .mobile-select-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: #777;
    font-size: 26px;
    line-height: 1;
  }
  .mobile-select-close:active { background: #f2f2f2; }
  .mobile-select-options {
    min-height: 0;
    padding: 6px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-select-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #333;
    font-size: 16px;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
  }
  .mobile-select-option:focus-visible { outline: 2px solid #1677ff; outline-offset: -2px; }
  .mobile-select-option[aria-selected="true"] { background: #eaf3ff; color: #1677ff; }
  .mobile-select-check {
    flex: 0 0 16px;
    color: #1677ff;
    text-align: center;
  }
  .mobile-select-option > span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .quick-links { flex-wrap: wrap; gap: 10px 18px; }
  .quick-links a,
  .quick-links .current,
  .quick-links a.current { color: #2f7de1; }
  .reader { font-size: 19px; line-height: 2.05; }
  .reader .pair { grid-template-columns: 1fr; gap: 0; }
  .footer {
    margin-top: auto;
    padding: 7px 16px 6px;
    background: #1a6dff;
    color: #fff;
    border-top: 0;
    line-height: 1.4;
  }
  .footer .footer-copy { font-size: 12px; }
  .footer .footer-icp a { color: rgba(255,255,255,0.9); }
}
