:root {
  color-scheme: light;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #1b1f23;
  background: #f4f5f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f4f5f7;
}

button {
  min-height: 40px;
  border: 1px solid #b6beca;
  border-radius: 6px;
  padding: 0 14px;
  color: #1b1f23;
  background: #ffffff;
  font: inherit;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #eef2f7;
}

button:disabled {
  color: #8b949e;
  cursor: not-allowed;
  background: #e9edf2;
}

.app {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  background: #f4f5f7;
}

.rate-control {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  margin-left: auto;
  color: #24292f;
  font-size: 14px;
  white-space: nowrap;
}

.voice-control {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  color: #24292f;
  font-size: 14px;
  white-space: nowrap;
}

.voice-control select {
  min-height: 40px;
  border: 1px solid #b6beca;
  border-radius: 6px;
  padding: 0 10px;
  color: #1b1f23;
  background: #ffffff;
  font: inherit;
}

.rate-control input {
  width: 150px;
  accent-color: #1f6feb;
}

.rate-control output {
  min-width: 38px;
  color: #57606a;
  text-align: right;
}

.primary-button {
  border-color: #1f6feb;
  color: #ffffff;
  background: #1f6feb;
}

.primary-button:hover:not(:disabled) {
  background: #1557b8;
}

.status-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin: 8px 0 18px;
  color: #57606a;
  font-size: 14px;
}

.rate-label {
  white-space: nowrap;
}

.article {
  padding: 28px 0 48px;
  border-top: 1px solid #d8dee4;
}

.source-link {
  display: inline-flex;
  margin: 0 0 10px;
  color: #57606a;
  font-size: 14px;
  text-decoration: none;
}

.source-link:hover {
  color: #0969da;
  text-decoration: underline;
}

.article-image {
  display: block;
  width: 100%;
  max-height: 460px;
  margin: 0 0 22px;
  border-radius: 6px;
  object-fit: cover;
  background: #d8dee4;
}

.article-image[hidden] {
  display: none;
}

.article h1 {
  margin: 0 0 18px;
  color: #111827;
  font-size: 32px;
  line-height: 1.25;
  letter-spacing: 0;
}

.article p {
  margin: 0 0 20px;
  font-size: 18px;
  line-height: 1.9;
  white-space: pre-wrap;
}

.reading-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin: 0 0 20px;
}

.reading-pane {
  min-width: 0;
}

.speech-highlight {
  border-radius: 3px;
  background: #fff176;
}

.translation {
  margin: 0;
  padding: 0 0 0 24px;
  border-left: 1px solid #d8dee4;
}

.translation h2 {
  margin: 0 0 12px;
  color: #24292f;
  font-size: 20px;
  line-height: 1.4;
  letter-spacing: 0;
}

.translation p {
  color: #30363d;
}

.article a {
  color: #0969da;
}

@media (max-width: 640px) {
  .app {
    padding: 12px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  button {
    flex: 1 1 calc(50% - 8px);
  }

  .rate-control {
    flex: 1 1 100%;
    margin-left: 0;
  }

  .voice-control {
    flex: 1 1 calc(50% - 8px);
  }

  .voice-control select {
    flex: 1;
  }

  .rate-control input {
    flex: 1;
    width: auto;
  }

  .status-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .article h1 {
    font-size: 26px;
  }

  .article {
    padding: 18px 0 32px;
  }

  .article-image {
    max-height: 220px;
    margin-bottom: 14px;
  }

  .reading-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    height: min(62vh, 560px);
    min-height: 360px;
  }

  .reading-pane {
    min-height: 0;
    overflow: auto;
    border: 1px solid #d8dee4;
    border-radius: 6px;
    padding: 12px;
    background: #ffffff;
  }

  .reading-pane-english {
    height: 34vh;
    min-height: 170px;
  }

  .translation {
    height: 28vh;
    min-height: 150px;
    margin: 0;
    padding: 12px;
    border-left: 1px solid #d8dee4;
  }

  .article p {
    margin-bottom: 0;
    font-size: 16px;
    line-height: 1.75;
  }

  .translation h2 {
    position: sticky;
    top: -12px;
    margin: -12px -12px 8px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid #d8dee4;
    background: #ffffff;
    font-size: 16px;
  }
}
