/* AstraOS News PWA — mobile-first companion shell.
   Palette mirrored from web/landing + app tokens (#080808 · bone #8a7760 · text #e3e3e3). */

:root {
  --ff-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ff-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --bone-white: #e8e1d5;
  --bone: #8a7760;
  --bg: #080808;
  --surface: #0e0e0e;
  --border: #262626;
  --text: #e3e3e3;
  --muted: #ababab;
  --dim: #7d7d7d;
  --danger: #c96a6a;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-h: 52px;
  --composer-h: 64px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  overscroll-behavior: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 12px 0 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 8, 8, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
}

.topbar-main {
  flex: 1;
  min-width: 0;
}

.lockup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--bone-white);
}

.wordmark {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:active {
  background: #1a1a1a;
}

.banner {
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}

.banner-offline {
  background: #1a1410;
  color: #d4b896;
}

.main {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(var(--composer-h) + var(--safe-bottom) + 16px);
}

.app[data-view="pair"] .main,
.app[data-view="topics"] .main {
  padding-bottom: calc(var(--safe-bottom) + 16px);
}

.view[hidden] {
  display: none !important;
}

.hero {
  text-align: center;
  margin: 12px 0 24px;
}

.hero-mark {
  display: block;
  margin: 0 auto 14px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 auto;
  max-width: 36ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 16px;
}

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid #333;
  border-radius: 8px;
  background: #111;
  color: var(--text);
  font: 15px/1.35 var(--ff-ui);
  padding: 11px 12px;
}

.field input:focus,
.field textarea:focus,
.composer textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--bone) 55%, transparent);
  outline-offset: 1px;
}

.hint {
  font-size: 11.5px;
  color: var(--dim);
  line-height: 1.45;
}

.hint code {
  font: 500 11px/1 var(--ff-mono);
  color: #9a9a9a;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  font: 600 14px/1 var(--ff-ui);
  padding: 12px 16px;
  cursor: pointer;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--bone);
  color: #0d0d0c;
}

.btn.ghost {
  background: transparent;
  border: 1px solid #333;
  color: var(--muted);
}

.btn.sm {
  padding: 8px 12px;
  font-size: 13px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.empty {
  color: var(--dim);
  font-size: 14px;
  text-align: center;
  padding: 32px 12px;
}

.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.topic-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.topic-item:active {
  background: #141414;
}

.topic-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.topic-item p {
  margin: 0;
  font-size: 12.5px;
  color: var(--dim);
  line-height: 1.4;
}

.topic-item .badge {
  display: inline-block;
  margin-top: 8px;
  font: 600 10px/1 var(--ff-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bone);
  border: 1px solid #3a3228;
  border-radius: 999px;
  padding: 4px 8px;
}

.topic-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.run-status {
  font-size: 12px;
  color: var(--dim);
}

.digest {
  margin-bottom: 18px;
}

.digest-empty {
  margin: 0;
  padding: 20px 12px;
  text-align: center;
  color: var(--dim);
  font-size: 14px;
  border: 1px dashed #333;
  border-radius: 10px;
}

.digest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.pill {
  font: 600 10px/1 var(--ff-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 5px 8px;
  border: 1px solid #333;
  color: var(--muted);
}

.pill.complete {
  border-color: #2a3d2a;
  color: #9bc49b;
}

.pill.partial {
  border-color: #3d3520;
  color: #d4b896;
}

.pill.failed {
  border-color: #3d2424;
  color: var(--danger);
}

.digest-summary {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.55;
  color: #d8d8d8;
  white-space: pre-wrap;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.news-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px;
}

.news-card a {
  color: var(--bone-white);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
}

.news-card a:active {
  color: var(--bone);
}

.news-card .why {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.news-card .meta {
  margin-top: 8px;
  font: 500 10px/1 var(--ff-mono);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.chat-log {
  display: grid;
  gap: 10px;
}

.bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.user {
  justify-self: end;
  background: #1c1814;
  border: 1px solid #3a3228;
}

.bubble.assistant {
  justify-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
}

.bubble.error {
  justify-self: stretch;
  background: #1a1010;
  border: 1px solid #402020;
  color: #e8b4b4;
  font-size: 13px;
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  border-top: 1px solid var(--border);
  background: rgba(8, 8, 8, 0.96);
  backdrop-filter: blur(12px);
  padding: 10px 12px calc(10px + var(--safe-bottom));
}

.composer-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  border: 1px solid #333;
  border-radius: 10px;
  background: #111;
  color: var(--text);
  font: 15px/1.35 var(--ff-ui);
  padding: 10px 12px;
}

.composer .send {
  flex-shrink: 0;
  min-width: 64px;
  padding: 11px 14px;
}

.sheet {
  border: none;
  border-radius: 14px 14px 0 0;
  padding: 0;
  margin: auto 0 0;
  width: 100%;
  max-width: 520px;
  background: #111;
  color: var(--text);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.sheet-inner {
  padding: 18px 16px calc(16px + var(--safe-bottom));
}

.sheet h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.settings-dl {
  margin: 0 0 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

.settings-dl dt {
  color: var(--dim);
}

.settings-dl dd {
  margin: 0;
  word-break: break-all;
}

.mono {
  font-family: var(--ff-mono);
  font-size: 12px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@media (min-width: 600px) {
  .main,
  .composer {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
  }

  .composer {
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
  }
}
