:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #66727f;
  --line: #d9e1e7;
  --accent: #d94635;
  --accent-strong: #b83224;
  --teal: #0f766e;
  --amber: #b7791f;
  --blue: #2563eb;
  --shadow: 0 16px 42px rgba(29, 41, 57, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC",
    Arial, sans-serif;
  min-width: 320px;
}

body:not([data-auth="app"]) .app-shell {
  display: none;
}

body[data-auth="app"] .auth-screen {
  display: none;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1420px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 22px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  min-height: auto;
  font-weight: 750;
}

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

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-weight: 700;
}

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

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.12;
  letter-spacing: 0;
}

.brand p,
.section-heading span,
.meta,
.comment-meta,
.status-grid span,
.select-field span,
.range-field span {
  color: var(--muted);
}

.brand p {
  margin-top: 4px;
  font-size: 14px;
}

.top-actions,
.player-controls,
.voice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-button,
.primary-action,
.ghost-action,
.tab {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 42px;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.icon-button {
  width: 44px;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 2px 10px rgba(29, 41, 57, 0.06);
}

.primary-action {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding: 0 18px;
  font-weight: 750;
}

.ghost-action {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  padding: 0 16px;
}

.icon-button:hover,
.primary-action:hover,
.ghost-action:hover,
.tab:hover {
  transform: translateY(-1px);
}

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

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.status-grid div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
}

.status-grid span,
.status-grid strong {
  display: block;
}

.status-grid strong {
  margin-top: 6px;
  font-size: 20px;
  line-height: 1.2;
  word-break: break-word;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  padding: 0 18px;
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.workspace {
  display: grid;
  gap: 16px;
  align-items: start;
}

.app-shell[data-view="feed"] .workspace {
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
}

.app-shell[data-view="listen"] .workspace,
.app-shell[data-view="settings"] .workspace,
.app-shell[data-view="admin"] .workspace {
  grid-template-columns: minmax(0, 900px);
  justify-content: center;
}

.app-shell[data-view="feed"] [data-panel="listen"],
.app-shell[data-view="feed"] [data-panel="settings"],
.app-shell[data-view="feed"] [data-panel="admin"],
.app-shell[data-view="listen"] [data-panel="feed"],
.app-shell[data-view="listen"] [data-panel="settings"],
.app-shell[data-view="listen"] [data-panel="admin"],
.app-shell[data-view="settings"] [data-panel="feed"],
.app-shell[data-view="settings"] [data-panel="listen"],
.app-shell[data-view="settings"] [data-panel="admin"],
.app-shell[data-view="admin"] [data-panel="feed"],
.app-shell[data-view="admin"] [data-panel="listen"],
.app-shell[data-view="admin"] [data-panel="settings"] {
  display: none;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2,
.listen-stage h2,
.settings-block h2 {
  font-size: 22px;
  line-height: 1.2;
}

.article-list {
  display: grid;
  gap: 10px;
}

.article-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 6px 20px rgba(29, 41, 57, 0.05);
}

.article-card.is-active {
  border-left-color: var(--accent);
}

.rank {
  width: 48px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef2f4;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
}

.article-main {
  min-width: 0;
}

.article-main h3 {
  margin: 0 0 7px;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0;
}

.article-main .ja {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 8px;
}

.summary-line {
  display: -webkit-box;
  margin-top: 9px;
  color: #3b4754;
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.meta {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #edf7f5;
  color: var(--teal);
  font-weight: 700;
}

.pill.status-error {
  background: #fff1f0;
  color: #b83224;
}

.pill.status-warn {
  background: #fff7e6;
  color: #9a5b13;
}

.pill.status-neutral {
  background: #eef2f6;
  color: #526171;
}

.rank-change {
  min-width: 48px;
  color: var(--muted);
  text-align: right;
  font-weight: 800;
}

.rank-change.up {
  color: var(--accent);
}

.rank-change.down {
  color: var(--blue);
}

.detail-column,
.listen-column,
.settings-column {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.detail-header {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-header h2 {
  font-size: 24px;
  line-height: 1.28;
}

.summary {
  font-size: 16px;
  line-height: 1.75;
  color: #273241;
  margin-bottom: 16px;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.notice {
  border: 1px solid #f1c4bd;
  border-radius: 8px;
  background: #fff4f2;
  color: #8f2e22;
  padding: 11px 12px;
  line-height: 1.55;
  margin-bottom: 14px;
  display: grid;
  gap: 8px;
}

.inline-action {
  justify-self: start;
}

.zh-empty {
  margin-bottom: 12px;
}

.article-image {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
  background: #eef2f4;
}

.body-text {
  display: grid;
  gap: 13px;
  color: #273241;
  font-size: 16px;
  line-height: 1.85;
}

.body-text p {
  margin: 0;
}

.original-block {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.original-block summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 750;
  margin-bottom: 10px;
}

.ja-body {
  color: var(--muted);
}

.key-points,
.viewpoints,
.comments {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.key-point,
.viewpoint,
.comment-item,
.script-item {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.key-point {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-point::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--amber);
  flex: 0 0 auto;
}

.viewpoint {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 8px;
  margin-top: 7px;
  border-radius: 999px;
  background: #e7edf2;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: var(--share);
  background: var(--teal);
}

.comment-item p {
  line-height: 1.65;
}

.comment-meta {
  margin-top: 7px;
  font-size: 13px;
}

.source-link {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.listen-column {
  display: grid;
  gap: 18px;
}

.drive-exit-button {
  display: none;
}

.listen-stage {
  display: flex;
  align-items: center;
  gap: 14px;
}

.anchor {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
  flex: 0 0 auto;
  border: 5px solid #f4c8c1;
}

.anchor.is-speaking {
  box-shadow: 0 0 0 8px rgba(217, 70, 53, 0.16);
}

.listen-stage p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.large {
  min-height: 56px;
  font-size: 20px;
}

.large-square {
  width: 56px;
  height: 56px;
}

.progress-panel {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafb;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: #e5ebf0;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.select-field,
.range-field {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.select-field select,
.range-field input {
  min-height: 42px;
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 0 10px;
}

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

.script-list {
  display: grid;
  gap: 12px;
}

.script-item {
  line-height: 1.7;
  color: #303b48;
}

.script-item.is-active {
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 650;
}

.settings-column {
  display: grid;
  gap: 16px;
}

.settings-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field span,
.form-note {
  color: var(--muted);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.form-note {
  margin: 0;
  line-height: 1.5;
}

.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.danger {
  color: var(--accent-strong);
  border-color: #f1c4bd;
}

.user-list-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.list-summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.user-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.user-row strong,
.user-row span,
.user-row small {
  display: block;
}

.user-row span {
  color: #3b4754;
  margin-top: 4px;
}

.user-row small {
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.35;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.user-pager {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.automation-status {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafb;
}

.automation-status strong {
  color: var(--ink);
}

.automation-status span {
  color: var(--muted);
  line-height: 1.45;
}

.settings-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.settings-block:first-child {
  border-top: 0;
  padding-top: 0;
}

dl {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

dl div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

.plain-list {
  margin: 12px 0 0;
  padding-left: 20px;
  line-height: 1.8;
  color: #303b48;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.64);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(18px);
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  max-width: min(560px, calc(100% - 32px));
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.drive-mode {
  background: #101820;
}

body.drive-mode .app-shell {
  width: min(1120px, calc(100% - 24px));
}

body.drive-mode .topbar,
body.drive-mode .status-grid,
body.drive-mode .tabs {
  display: none;
}

body.drive-mode .listen-column {
  margin-top: 16px;
  min-height: calc(100vh - 32px);
}

body.drive-mode .drive-exit-button {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 850;
  box-shadow: var(--shadow);
  cursor: pointer;
}

body.drive-mode .drive-exit-button:hover {
  background: #fff;
}

body.drive-mode .listen-stage h2 {
  font-size: clamp(32px, 5vw, 54px);
}

body.drive-mode .listen-stage p,
body.drive-mode .script-item {
  font-size: clamp(20px, 2.6vw, 30px);
}

body.drive-mode .primary-action.large,
body.drive-mode .large-square {
  min-height: 72px;
  font-size: 28px;
}

@media (max-width: 980px) {
  .app-shell[data-view="feed"] .workspace {
    grid-template-columns: 1fr;
  }

  .detail-column {
    order: -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .primary-action,
  .top-actions .ghost-action {
    flex: 1 1 auto;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .article-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .rank-change {
    grid-column: 2;
    text-align: left;
  }

  .detail-column,
  .listen-column,
  .settings-column {
    padding: 14px;
  }

  .player-controls,
  .voice-row {
    align-items: stretch;
  }

  .player-controls .primary-action,
  .select-field,
  .range-field {
    flex: 1 1 180px;
  }

  .user-row {
    grid-template-columns: 1fr;
  }

  .user-actions {
    justify-content: flex-start;
  }

  .user-list-tools {
    grid-template-columns: 1fr;
  }

  .user-pager {
    justify-content: stretch;
  }

  .user-pager button {
    flex: 1;
  }
}

@media (max-width: 460px) {
  .brand-mark {
    width: 42px;
    height: 42px;
  }

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

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .tab {
    padding: 0 8px;
  }

  .listen-stage {
    align-items: flex-start;
  }

  .anchor {
    width: 68px;
    height: 68px;
    border-width: 4px;
  }
}
