:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --text: #1e2a24;
  --muted: #627069;
  --border: #d9e0db;
  --accent: #29745c;
  --accent-strong: #14513d;
  --tap: rgba(255, 205, 64, 0.24);
  --tap-border: rgba(231, 162, 23, 0.7);
  --shadow: 0 18px 40px rgba(24, 38, 31, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 800;
}

.brand p,
.status-card p {
  margin: 3px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.controls,
.voice-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  min-width: 112px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

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

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

.icon-button svg,
.action-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-button svg {
  fill: currentColor;
  stroke: none;
}

.page-select {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.page-select select {
  height: 38px;
  min-width: 110px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.voice-tabs {
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #eef3ef;
}

.voice-tab {
  min-width: 58px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.voice-tab.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.reader-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  padding: 18px;
}

.reader-stage {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.page-frame {
  position: relative;
  width: min(100%, 920px);
  box-shadow: var(--shadow);
  background: white;
  line-height: 0;
}

.page-frame img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  line-height: normal;
}

.hotspot {
  position: absolute;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot.is-playing {
  border-color: var(--tap-border);
  background: var(--tap);
  outline: none;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.status-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.status-card.compact p {
  font-size: 13px;
}

.status-label {
  display: block;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

#currentText {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .controls,
  .voice-tabs {
    justify-content: space-between;
  }

  .reader-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .side-panel {
    order: -1;
  }
}

@media (min-width: 861px) and (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(180px, 1fr) auto auto;
    gap: 12px;
  }

  .controls,
  .voice-tabs {
    justify-content: center;
  }

  .reader-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (pointer: coarse) {
  .icon-button {
    width: 46px;
    height: 46px;
  }

  .action-button,
  .page-select select {
    height: 46px;
  }

  .voice-tab {
    height: 40px;
    min-width: 72px;
  }

  .hotspot {
    min-width: 42px;
    min-height: 34px;
  }
}
