:root {
  --background: #f7f5f2;
  --surface: #ffffff;
  --text-primary: #16150f;
  --text-secondary: #8a877e;
  --border: #eceae4;
  --shadow: 0 1px 2px rgba(20, 18, 10, 0.05), 0 6px 20px rgba(20, 18, 10, 0.06);
  --shadow-hover: 0 2px 4px rgba(20, 18, 10, 0.08), 0 14px 34px rgba(20, 18, 10, 0.12);
  --radius: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--background);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 28px 60px;
}

/* ---------- Top bar ---------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 6px 0 18px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: radial-gradient(circle at 30% 30%, #4a4a4a, #111);
}

.topbar-nav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow);
}

.nav-pill {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-primary);
}

.nav-pill.active {
  background: #111;
  color: #fff;
}

.topbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  box-shadow: var(--shadow);
}

.search-box input {
  border: 0;
  outline: none;
  font: inherit;
  font-size: 13px;
  width: 130px;
  background: transparent;
}

.search-icon {
  color: var(--text-secondary);
  font-size: 15px;
}

.search-box kbd {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--background);
  border-radius: 5px;
  padding: 2px 5px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 15px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

/* ---------- Toolbars ---------- */

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 20px;
}

.filter-tabs {
  display: flex;
  gap: 22px;
}

.filter-tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}

.filter-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

.tab-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--text-primary);
  color: var(--surface, #fff);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  vertical-align: 1px;
}

.toolbar-right {
  display: flex;
  gap: 10px;
}

.pill-select {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

.pill-select.danger {
  color: #b3261e;
}

.detail-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

#detail-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Sync panel ---------- */

.sync-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 22px;
}

.sync-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.sync-panel h2 {
  font-size: 15px;
}

.sync-panel-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.enrich-status {
  font-size: 12px;
  color: var(--text-secondary);
  margin: -4px 0 10px;
}

.connection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.connection-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.connection-card.connected {
  border-color: #d7e3d9;
  background: #f7faf8;
}

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

.connection-glyph {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--background);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.connection-card.connected .connection-glyph {
  background: #1d6f42;
  border-color: #1d6f42;
  color: #fff;
}

.connection-meta {
  min-width: 0;
}

.connection-name {
  font-size: 14px;
  font-weight: 600;
  display: block;
}

.connection-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.connection-badge {
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.connection-badge.muted {
  background: #f4f1ea;
  color: var(--text-secondary);
}

.connection-badge.extension {
  background: #eef4ff;
  color: #3b62c4;
}

.sync-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.sync-now {
  border: 1px solid var(--border);
  background: #111;
  color: #fff;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  padding: 6px 13px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.sync-now:disabled {
  opacity: 0.6;
  cursor: default;
}

.sync-disconnect {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
}

.sync-disconnect:hover {
  color: #b3261e;
}

/* ---------- Masonry grid ---------- */

.grid {
  column-count: 4;
  column-gap: 18px;
}

@media (max-width: 1100px) { .grid { column-count: 3; } }
@media (max-width: 820px)  { .grid { column-count: 2; } }
@media (max-width: 540px)  { .grid { column-count: 1; } }

.card {
  position: relative;
  display: inline-block;
  width: 100%;
  margin-bottom: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  break-inside: avoid;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.card-media {
  position: relative;
}

.card-media img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 60px;
  background: #f0ede7;
}

.card-body {
  padding: 16px 18px;
}

.card.media-only .card-body {
  display: none;
}

.card.media-failed .card-media {
  display: none;
}

.card.media-failed .card-body {
  display: block;
}

.card-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.author-names {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.author-name {
  font-size: 13px;
  font-weight: 600;
}

.author-handle {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
}

.card-content {
  font-size: 13px;
  line-height: 1.55;
  color: #3c3a33;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* A page's own description reads quieter than content the user saved. */
.card-content.is-description {
  color: var(--text-secondary);
  -webkit-line-clamp: 3;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 0;
}

.card-favicon {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.card-site {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-reading {
  white-space: nowrap;
  flex-shrink: 0;
}

.card-reading::before {
  content: "·";
  margin-right: 6px;
}

.platform-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 7px;
  padding: 2px 7px;
}

.card.media-only .platform-badge {
  top: auto;
  bottom: 10px;
  left: 12px;
  right: auto;
}

.card-actions {
  position: absolute;
  top: 8px;
  left: 10px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.card:hover .card-actions {
  opacity: 1;
}

.card-actions a,
.card-actions button {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  background: rgba(20, 18, 10, 0.75);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}

.card-actions .action-done {
  background: rgba(5, 150, 105, 0.9);
}

/* ---------- Space tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.tile:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.tile-name {
  font-size: 14px;
  font-weight: 600;
}

.tile-meta {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

.tile-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 2px;
}

.rule-chip {
  font-size: 11px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--text-secondary);
}

.tile.new-tile {
  border-style: dashed;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  font-size: 14px;
  background: transparent;
  box-shadow: none;
}

.tile.new-tile:hover {
  color: var(--text-primary);
  transform: none;
}

/* Suggested spaces render as ghost tiles: same shape, dashed and quiet,
   so proposals read as drafts next to the user's real spaces. */
.tile.ghost-tile {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.tile.ghost-tile:hover {
  transform: none;
  box-shadow: none;
}

.ghost-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ghost-actions button {
  font: inherit;
  font-size: 12px;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.ghost-accept {
  background: var(--text-primary);
  color: var(--surface);
  border: 1px solid var(--text-primary);
}

.ghost-accept:hover {
  opacity: 0.85;
}

.ghost-dismiss {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.ghost-dismiss:hover {
  color: var(--text-primary);
}

/* ---------- Popover & dialog ---------- */

.popover {
  position: absolute;
  z-index: 100;
  width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  padding: 12px;
}

.popover h3 {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 8px;
}

.popover ul {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.popover li button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popover li button:hover {
  background: var(--background);
}

.popover li button .check {
  color: #1d6f42;
  font-weight: 700;
}

.popover form {
  display: flex;
  gap: 6px;
}

.popover input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  padding: 6px 9px;
  outline: none;
}

.popover form button {
  border: 0;
  border-radius: 8px;
  background: #111;
  color: #fff;
  width: 30px;
  cursor: pointer;
}

dialog {
  border: 0;
  border-radius: 16px;
  box-shadow: var(--shadow-hover);
  padding: 22px;
  width: 340px;
  /* Restore the centering the universal `* { margin: 0 }` reset removes —
     a modal dialog centers via margin: auto. */
  margin: auto;
}

dialog::backdrop {
  background: rgba(20, 18, 10, 0.35);
}

dialog h3 {
  font-size: 15px;
  margin-bottom: 14px;
}

dialog label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

dialog input,
dialog select {
  display: block;
  width: 100%;
  margin-top: 5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  color: var(--text-primary);
  background: var(--surface);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.dialog-actions button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
}

.dialog-actions button.primary {
  background: #111;
  border-color: #111;
  color: #fff;
}

.guide-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: min(85vh, 720px);
  overflow: hidden;
  padding: 0;
}

.guide-form {
  display: flex;
  flex-direction: column;
  max-height: min(85vh, 720px);
  padding: 22px;
}

.guide-form h3,
.guide-form .dialog-intro,
.guide-form .dialog-actions {
  flex-shrink: 0;
}

.guide-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 -4px;
  padding: 0 4px 8px;
}

.guide-section {
  margin-bottom: 22px;
}

.guide-section h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.guide-section p,
.guide-section li {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.guide-section ul,
.guide-section ol {
  margin: 0 0 0 18px;
  padding: 0;
}

.guide-section li + li {
  margin-top: 6px;
}

.guide-section li strong {
  color: var(--text-primary);
  font-weight: 600;
}

.guide-callout {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--background);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.guide-callout code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
}

.guide-link-row {
  margin-top: 10px;
}

.guide-link-row a {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
}

.guide-link-row a:hover {
  text-decoration: underline;
}

/* ---------- Explore ---------- */

.explore-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.explore-header h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.explore-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

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

.lucky-button {
  border: 0;
  background: #111;
  color: #fff;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lucky-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.explore-section {
  margin-bottom: 34px;
}

.explore-section h3 {
  font-size: 15px;
  margin-bottom: 2px;
}

.explore-section .explore-sub {
  margin-bottom: 12px;
}

.lucky-dialog {
  width: 380px;
}

.lucky-dialog .card {
  margin-bottom: 14px;
}

/* ---------- Misc ---------- */

/* ---------- Auth & account ---------- */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-hover);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 20px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--background);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 0;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-secondary);
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

.auth-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.auth-card input {
  display: block;
  width: 100%;
  margin-top: 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}

.auth-card input:focus {
  border-color: #111;
}

.auth-submit {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 0;
  cursor: pointer;
  margin-top: 4px;
}

.auth-error {
  color: #b3261e;
  font-size: 12px;
  margin-top: 10px;
  min-height: 15px;
}

.auth-error.success {
  color: #1d6f42;
}

.auth-invite-banner {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef6f0;
  color: #1d6f42;
  font-size: 13px;
  line-height: 1.4;
}

.auth-link {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: 8px;
  text-align: center;
}

.auth-link:hover {
  color: var(--text-primary);
}

.auth-reset-intro {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.account-button {
  font-weight: 700;
  font-size: 13px;
  background: #111;
  color: #fff;
  border-color: #111;
}

.account-menu {
  position: absolute;
  top: 62px;
  right: 28px;
  z-index: 200;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-hover);
  padding: 14px;
}

.account-email {
  font-size: 13px;
  font-weight: 600;
}

.account-plan {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 3px 0 12px;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  padding: 8px 11px;
  cursor: pointer;
  margin-bottom: 6px;
}

.menu-item:hover {
  background: var(--background);
}

.menu-item.primary {
  background: #111;
  border-color: #111;
  color: #fff;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 80px 0;
  font-size: 14px;
}

.empty-cta {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.load-more-row {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

/* ---------- Tags ---------- */

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.card-tag {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  cursor: pointer;
  font-family: inherit;
}

.card-tag:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.card-tag::before {
  content: "#";
  opacity: 0.5;
}

.tag-filter-chip {
  border: 1px solid var(--text-primary);
  background: var(--surface);
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.tag-filter-chip::after {
  content: " ✕";
  color: var(--text-secondary);
}

.dialog-intro {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ---------- Ingest progress pill ---------- */

.ingest-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.ingest-spinner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--text-primary);
  animation: ingest-spin 0.9s linear infinite;
  flex-shrink: 0;
}

@keyframes ingest-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: #16150f;
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-hover);
  animation: toast-in 0.16s ease;
  max-width: 90vw;
}

.toast.error {
  background: #b3261e;
}

.toast.success {
  background: #1d6f42;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- API tokens dialog ---------- */

.tokens-list {
  list-style: none;
  margin-bottom: 14px;
  max-height: 180px;
  overflow-y: auto;
}

.tokens-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.tokens-list li span:first-child {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-created {
  color: var(--text-secondary);
  font-size: 11px;
}

.token-revoke {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}

.token-revoke:hover {
  color: #b3261e;
}

.tokens-empty {
  color: var(--text-secondary);
}

.token-reveal {
  font-size: 12px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  margin-bottom: 14px;
  word-break: break-all;
  user-select: all;
}

/* ---------- Touch devices ---------- */

/* Touch has no hover: card actions must be visible and comfortably
   tappable, and hover-only affordances need resting states. */
@media (hover: none) {
  .card-actions {
    opacity: 1;
  }

  .card-actions a,
  .card-actions button {
    width: 34px;
    height: 34px;
    font-size: 14px;
    background: rgba(20, 18, 10, 0.55);
  }

  .card:hover {
    transform: none;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
  .app {
    padding: 14px 14px 40px;
  }

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

  .topbar-left {
    flex: 1;
  }

  /* Views move below the brand row; search stretches full width. */
  .topbar-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .topbar-right {
    flex: none;
  }

  .search-box {
    order: 4;
    width: 100%;
  }

  .search-box input {
    flex: 1;
    width: auto;
  }

  .search-box kbd {
    display: none;
  }

  .toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .filter-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    scrollbar-width: none;
  }

  .filter-tabs::-webkit-scrollbar {
    display: none;
  }

  .filter-tab {
    white-space: nowrap;
    padding: 8px 2px;
  }

  .account-menu {
    right: 14px;
  }
}

.hidden {
  display: none !important;
}
