:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-muted: #eef3ef;
  --text: #15201d;
  --muted: #64706b;
  --line: #d8e0dc;
  --accent: #0f7b67;
  --accent-strong: #075f52;
  --accent-soft: #d8eee8;
  --danger: #a64242;
  --shadow: 0 18px 48px rgba(21, 32, 29, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(15, 123, 103, 0.12), rgba(245, 247, 244, 0) 260px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 123, 103, 0.22);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

.icon-button,
.transport button,
.small-icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
}

.icon-button.is-active {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-action svg path,
.transport rect,
.small-icon-button path {
  fill: currentColor;
  stroke: none;
}

.control-panel,
.settings-strip,
.notice,
.article-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 14px;
}

.listen-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: center;
  min-height: 96px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.meter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  color: white;
  background: var(--accent);
}

.meter span {
  display: block;
  width: 5px;
  height: 14px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.82;
}

.meter span:nth-child(2) {
  height: 28px;
}

.meter span:nth-child(3) {
  height: 20px;
}

.meter span:nth-child(4) {
  height: 34px;
}

.is-speaking .meter span {
  animation: pulse 0.88s ease-in-out infinite alternate;
}

.is-speaking .meter span:nth-child(2) {
  animation-delay: 0.1s;
}

.is-speaking .meter span:nth-child(3) {
  animation-delay: 0.2s;
}

.is-speaking .meter span:nth-child(4) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  from {
    transform: scaleY(0.55);
  }
  to {
    transform: scaleY(1.15);
  }
}

.listen-copy {
  min-width: 0;
}

.status-label {
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.listen-copy h2 {
  display: -webkit-box;
  overflow: hidden;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.primary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  font-weight: 800;
}

.primary-action:disabled,
.transport button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.primary-action svg {
  margin-right: 8px;
}

.transport {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.transport button {
  width: 100%;
  border-radius: 8px;
}

.settings-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
}

.topic-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.topic-group legend,
.setting-field label {
  width: 100%;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topic-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
}

.topic-group input {
  accent-color: var(--accent);
}

.setting-field {
  display: grid;
  gap: 7px;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
}

input[type="range"] {
  accent-color: var(--accent);
}

.notice {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding: 12px 14px;
  color: #704b11;
  background: #fff6df;
  box-shadow: none;
}

.notice[hidden] {
  display: none;
}

.notice span {
  color: #816a3b;
  font-size: 14px;
}

.article-section {
  margin-top: 14px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.edit-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f7faf8;
}

.edit-panel[hidden] {
  display: none;
}

.edit-panel span {
  flex: 1 1 160px;
  color: var(--muted);
  font-size: 14px;
}

.edit-panel button,
.article-order-controls button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-weight: 700;
}

.edit-panel button:disabled,
.article-order-controls button:disabled {
  opacity: 0.42;
}

.section-heading h2 {
  font-size: 17px;
}

.section-heading span {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.article-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.article-card {
  display: grid;
  gap: 8px;
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
}

.article-card:last-child {
  border-bottom: 0;
}

.article-card.is-current {
  background: var(--accent-soft);
}

.article-card.is-selected {
  background: #fff6df;
}

.article-topline {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.article-number,
.article-select span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(15, 123, 103, 0.12);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.article-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.article-select input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.small-icon-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  box-shadow: none;
}

.small-icon-button svg {
  width: 18px;
  height: 18px;
}

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

.topic-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(15, 123, 103, 0.12);
  font-weight: 800;
}

.article-title {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.32;
  text-decoration: none;
}

.article-title:focus,
.article-title:hover {
  text-decoration: underline;
}

.article-summary {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.48;
}

.article-order-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.empty {
  padding: 40px 16px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 28px;
  }

  .settings-strip {
    grid-template-columns: 1.6fr 0.9fr 1fr 0.8fr;
    align-items: end;
  }

  .listen-card {
    grid-template-columns: 70px 1fr;
  }

  .meter {
    width: 70px;
    height: 70px;
  }
}
