/* read. — design tokens and components */

:root {
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-read: 'Inter', system-ui, -apple-system, sans-serif;
}

:root,
[data-theme="light"] {
  --bg: #ffffff;
  --page: #f1f1f1;
  --sur: #f1f1f1;
  --bor: #d4d4d4;
  --t1: #0a0a0a;
  --t2: #525252;
  --t3: #8a8a8a;
  --ac: #b5604a;
  --err: #dc2626;
  --score-high: #2d8a5e;
  --score-mid: #b8860b;
  color-scheme: light;
}

[data-theme="warm"] {
  --bg: #faf6ef;
  --page: #faf6ef;
  --sur: #f4ede2;
  --bor: #e9dfcf;
  --t1: #2a1f17;
  --t2: #5c473a;
  --t3: #a08878;
  --ac: #a55a3e;
  --err: #b33a3a;
  --score-high: #2d8a5e;
  --score-mid: #b8860b;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #110f0d;
  --page: #110f0d;
  --sur: #1c1816;
  --bor: #2d2823;
  --t1: #f3ede5;
  --t2: #d4c4b0;
  --t3: #a89684;
  --ac: #d99a85;
  --err: #e07070;
  --score-high: #5cb88a;
  --score-mid: #d4a84a;
  color-scheme: dark;
}

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

html, body {
  height: 100%;
}

body {
  background: var(--page);
  color: var(--t1);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a {
  color: var(--ac);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: var(--font-ui);
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* App shell */
.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--bor);
  border-right: 1px solid var(--bor);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 0;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 500;
  color: var(--t1);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.logo-dot {
  color: var(--ac);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
}

.nav-links a {
  color: var(--t3);
  text-decoration: none;
  transition: color 0.12s;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--t1);
  text-decoration: none;
}

.nav-links a[aria-current="page"] {
  font-weight: 500;
}

.app-main {
  padding: 28px 32px 48px;
  animation: fadeUp 0.18s ease;
}

.app-main-home {
  padding: 0 0 32px;
}

.app-main-flush {
  padding: 0 0 48px;
}

.app-header-auth {
  padding-bottom: 0;
}

.app-top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--bor);
}

.app-header-auth.app-top-header {
  border-bottom: none;
  padding-bottom: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.locale-switch-form {
  margin: 0;
  margin-right: 4px;
  padding-right: 6px;
  border-right: 1px solid var(--bor);
}

.locale-select-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.locale-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 5px 28px 5px 8px;
  border: none;
  border-radius: 6px;
  background: var(--sur) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--t1);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.locale-select:hover {
  background-color: var(--sur);
  color: var(--t1);
}

.locale-select:focus {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

.locale-select option {
  font-size: 13px;
  font-weight: 500;
}

.header-actions .ic {
  text-decoration: none;
}

.header-actions .ic[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.header-actions .ic[disabled]:hover {
  background: none;
  color: var(--t3);
}

.subpage-header {
  padding: 20px 32px 0;
}

.subpage-header + .page-title,
.subpage-header + h1.page-title {
  padding: 0 32px;
}

.subpage-header ~ .page-subtitle,
.subpage-header ~ .panel,
.subpage-header ~ .table-wrap {
  margin-left: 32px;
  margin-right: 32px;
}

.subpage-header ~ .page-title {
  margin-top: 0;
}

/* Topics home */
.topics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 0;
}

/* legacy alias — header unificado em .app-top-header */

.topics-body {
  padding: 28px 32px 0;
}

.greeting {
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  color: var(--t1);
}

.greeting-sub {
  font-size: 13px;
  color: var(--t3);
  margin-bottom: 26px;
}

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

.topic-card {
  background: var(--bg);
  border: 1px solid var(--bor);
  border-radius: var(--radius-lg);
  padding: 14px 16px 13px;
  cursor: pointer;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.topic-card:hover {
  background: var(--sur);
  border-color: var(--ac);
  text-decoration: none;
}

.topic-card.has-new::after {
  content: "";
  position: absolute;
  top: 13px;
  right: 13px;
  width: 7px;
  height: 7px;
  background: var(--ac);
  border-radius: 50%;
}

.topic-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--t1);
  margin-bottom: 4px;
}

.topic-meta {
  font-size: 11px;
  color: var(--t3);
}

.topics-divider {
  margin: 0 32px 18px;
}

.topics-footer {
  padding: 0 32px 32px;
}

.add-topic-btn {
  background: none;
  border: 1px solid var(--bor);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-size: 12px;
  color: var(--t3);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: border-color 0.12s, color 0.12s;
  text-decoration: none;
}

.add-topic-btn:hover {
  border-color: var(--ac);
  color: var(--ac);
  text-decoration: none;
}

.add-topic-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Topic articles header */
.articles-header {
  padding: 14px 32px 0;
  border-bottom: 1px solid var(--bor);
}

.articles-topic-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--t1);
  margin: 7px 0 3px;
}

.articles-meta {
  font-size: 12px;
  color: var(--t3);
  padding-bottom: 10px;
}

.articles-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding-bottom: 14px;
}

.articles-filter-link {
  font-size: 12px;
  color: var(--t3);
  text-decoration: none;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
}

.articles-filter-link:hover {
  color: var(--t1);
}

.articles-filter-link.is-active {
  color: var(--t1);
  border-bottom-color: var(--ac);
}

.articles-empty {
  padding: 24px 32px;
}

.app-main-flush .reading-bar,
.app-main-flush .reading-toolbar,
.app-main-flush .reading-body {
  padding-left: 32px;
  padding-right: 32px;
}

.reading-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--bor);
}

.reading-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.reading-action-form {
  margin: 0;
}

.reading-action-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reading-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  color: var(--t2);
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: border-color 0.12s, color 0.12s, background 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.reading-action-btn:hover {
  border-color: var(--ac);
  color: var(--ac);
  background: var(--bg);
  text-decoration: none;
}

.reading-action-btn:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

.reading-action-btn--secondary {
  color: var(--t3);
  background: var(--bg);
}

.reading-action-btn--secondary:hover {
  color: var(--t1);
  border-color: var(--t3);
}

.reading-action-btn--link {
  color: var(--t3);
  background: var(--bg);
}

.reading-action-btn--link:hover {
  color: var(--ac);
}

.app-main-flush .reading-progress {
  margin: 0;
}

/* Settings hub */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px 16px;
  border-bottom: 1px solid var(--bor);
}

.settings-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--t1);
}

.settings-header-spacer {
  width: 48px;
}

.settings-section {
  margin: 24px 32px 0;
}

.settings-section-body {
  margin-bottom: 32px;
}

.settings-section-label {
  font-size: 11px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  font-weight: 500;
}

.settings-group {
  border: 1px solid var(--bor);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--bor);
  text-decoration: none;
  color: var(--t1);
  transition: background 0.12s;
  cursor: pointer;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row:hover {
  background: var(--sur);
  text-decoration: none;
}

.settings-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-row-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--sur);
  border: 1px solid var(--bor);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-row-icon svg {
  width: 15px;
  height: 15px;
  stroke: var(--t2);
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-row-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--t1);
}

.settings-row-desc {
  font-size: 12px;
  color: var(--t3);
  margin-top: 1px;
}

.settings-row-chevron {
  width: 14px;
  height: 14px;
  stroke: var(--t3);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.settings-history-title {
  margin-top: 24px;
}

.settings-logout {
  margin-top: 24px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shared */
.ic {
  background: none;
  border: none;
  color: var(--t3);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.ic:hover {
  background: var(--sur);
  color: var(--t1);
}

.ic svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back-btn {
  background: none;
  border: none;
  color: var(--t3);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  transition: color 0.12s;
  text-decoration: none;
}

.back-btn:hover {
  color: var(--t1);
  text-decoration: none;
}

.back-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.divider {
  border: none;
  border-top: 1px solid var(--bor);
  margin: 24px 0;
}

.page-title {
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  color: var(--t1);
}

.page-subtitle {
  font-size: 13px;
  color: var(--t3);
  margin-bottom: 26px;
}

.muted {
  color: var(--t3);
  font-size: 0.9rem;
}

.error-msg {
  color: var(--err);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--sur);
  border: 1px solid var(--bor);
  font-size: 0.75rem;
  color: var(--t3);
  font-weight: 500;
}

.score-high { color: var(--score-high); }
.score-mid { color: var(--score-mid); }
.score-low { color: var(--t3); }

mark {
  background: var(--sur);
  color: var(--ac);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* Category sections */
.category-heading {
  font-size: 14px;
  font-weight: 500;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 28px 0 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bor);
}

.category-heading:first-of-type {
  margin-top: 0;
}

.article-list {
  margin: 0;
}

/* Article list items */
.article-item-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--bor);
  transition: background 0.1s;
}

.article-item-row:last-child {
  border-bottom: none;
}

.article-item-row:hover {
  background: var(--sur);
}

.article-item {
  flex: 1;
  min-width: 0;
  padding: 17px 12px 17px 32px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.article-item:hover {
  text-decoration: none;
}

.article-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 20px 0 4px;
  flex-shrink: 0;
}

.article-action-form {
  margin: 0;
}

.article-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--bor);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--t3);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.article-action-btn:hover {
  border-color: var(--ac);
  color: var(--ac);
  background: var(--sur);
}

.article-action-btn:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

.article-action-btn--accent {
  color: var(--ac);
  border-color: color-mix(in srgb, var(--ac) 35%, var(--bor));
}

.article-action-btn--accent:hover {
  background: color-mix(in srgb, var(--ac) 8%, var(--bg));
}

.article-action-btn .reading-action-icon {
  width: 15px;
  height: 15px;
}

.unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ac);
  flex-shrink: 0;
  margin-top: 6px;
  opacity: 0;
}

.article-item-row.unread .unread-dot {
  opacity: 1;
}

.article-content {
  flex: 1;
  min-width: 0;
}

.article-source {
  font-size: 10px;
  color: var(--ac);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 3px;
}

.article-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--t1);
  line-height: 1.4;
  margin-bottom: 5px;
}

.article-excerpt {
  font-size: 13px;
  color: var(--t3);
  line-height: 1.55;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--t3);
}

/* Reading view */
.reading-progress {
  height: 2px;
  background: var(--bor);
  margin: 0 -32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.reading-progress-fill {
  height: 100%;
  background: var(--ac);
  width: 0%;
  transition: width 0.15s ease-out;
}

.reading-bar {
  padding: 13px 0 11px;
  border-bottom: 1px solid var(--bor);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.reading-stats {
  font-size: 12px;
  color: var(--t3);
  display: flex;
  gap: 8px;
  align-items: center;
}

.reading-stats-sep {
  color: var(--bor);
}

.read-original {
  display: inline-block;
  font-size: 12px;
  color: var(--t3);
  margin-bottom: 20px;
}

.read-original:hover {
  color: var(--ac);
}

.reading-body {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 0 72px;
}

.reading-title {
  font-family: var(--font-read);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--t1);
  margin-bottom: 18px;
}

.reading-lead {
  font-family: var(--font-read);
  font-size: 17px;
  font-style: italic;
  color: var(--t2);
  line-height: 1.72;
  margin-bottom: 24px;
}

.reading-text {
  font-size: 16px;
  line-height: 1.85;
  color: var(--t2);
}

.reading-text p {
  margin-bottom: 18px;
}

.reading-text p:last-child {
  margin-bottom: 0;
}

.reading-text h2,
.reading-text h3,
.reading-text h4 {
  font-family: var(--font-read);
  color: var(--t1);
  margin: 1.5em 0 0.6em;
  line-height: 1.3;
}

.reading-text h2 { font-size: 1.35rem; }
.reading-text h3 { font-size: 1.15rem; }

.reading-text a {
  color: var(--ac);
}

.reading-text img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 1em 0;
}

.reading-text pre {
  overflow-x: auto;
  padding: 0.75rem 1rem;
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 18px;
}

.reading-text code {
  font-size: 0.9em;
  background: var(--sur);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

.reading-text pre code {
  background: none;
  padding: 0;
}

.reading-text blockquote {
  border-left: 3px solid var(--bor);
  padding-left: 1rem;
  margin: 0 0 18px;
  color: var(--t3);
  font-style: italic;
}

.reading-text ul,
.reading-text ol {
  margin: 0 0 18px 1.25rem;
}

.reading-text table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  margin-bottom: 18px;
  border-collapse: collapse;
}

.reading-text th,
.reading-text td {
  border: 1px solid var(--bor);
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

.reading-empty {
  font-size: 15px;
  color: var(--t3);
  line-height: 1.6;
}

/* Forms */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--bor);
}

.compact-form {
  display: grid;
  gap: 14px;
}

@media (min-width: 640px) {
  .compact-form.two-col {
    grid-template-columns: 1fr 1fr;
  }

  .compact-form.two-col .span-full {
    grid-column: 1 / -1;
  }
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--t3);
  font-weight: 500;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--t1);
  background: var(--bg);
  border: 1px solid var(--bor);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  transition: border-color 0.12s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ac);
}

textarea {
  resize: vertical;
  min-height: 4rem;
}

label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--t2);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--ac);
  flex-shrink: 0;
}

input[type="range"] {
  width: 100%;
  height: 1.25rem;
  accent-color: var(--ac);
  cursor: pointer;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--bor);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--ac);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--bor);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--bor);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--ac);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ac);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--bor);
}

.btn-primary {
  background: var(--ac);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.12s;
}

.btn-primary:hover {
  opacity: 0.9;
  text-decoration: none;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--bor);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-size: 12px;
  color: var(--t3);
  transition: border-color 0.12s, color 0.12s;
}

.btn-ghost:hover {
  border-color: var(--ac);
  color: var(--ac);
}

.btn-danger {
  background: none;
  border: 1px solid var(--bor);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--t3);
}

.btn-danger:hover {
  border-color: var(--err);
  color: var(--err);
}

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

.form-separator {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--bor);
}

/* Panels / cards */
.panel {
  border: 1px solid var(--bor);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  background: var(--bg);
}

.panel-header {
  font-size: 14px;
  font-weight: 500;
  color: var(--t1);
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 16px;
  font-weight: 500;
  margin: 28px 0 12px;
  color: var(--t1);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border: 1px solid var(--bor);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 500;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--sur);
  border-bottom: 1px solid var(--bor);
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bor);
  color: var(--t2);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

.cell-truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-break {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.actions form {
  margin: 0;
}

.empty-state {
  padding: 24px 0;
  color: var(--t3);
  font-size: 14px;
}

/* Auth */
.auth-card {
  max-width: 22rem;
  margin: 2rem auto 0;
}

.auth-card .page-title {
  margin-bottom: 20px;
}

.logout-form {
  display: inline;
}

.logout-form button {
  background: none;
  border: none;
  color: var(--t3);
  font-size: 13px;
  padding: 0;
}

.logout-form button:hover {
  color: var(--t1);
}

@media (max-width: 480px) {
  .app-header,
  .app-main,
  .app-top-header,
  .topics-header,
  .topics-body,
  .topics-footer,
  .topics-divider,
  .articles-header,
  .settings-header,
  .settings-section,
  .subpage-header {
    padding-left: 20px;
    padding-right: 20px;
  }

  .topics-divider {
    margin-left: 20px;
    margin-right: 20px;
  }

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

  .subpage-header ~ .page-subtitle,
  .subpage-header ~ .panel,
  .subpage-header ~ .table-wrap,
  .subpage-header + .page-title,
  .subpage-header + h1.page-title {
    margin-left: 20px;
    margin-right: 20px;
  }

  .app-main-flush .reading-bar,
  .app-main-flush .reading-toolbar,
  .app-main-flush .reading-body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .reading-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .reading-toolbar-group {
    width: 100%;
  }

  .reading-action-btn--link {
    justify-content: center;
    width: 100%;
  }

  .article-item {
    padding-left: 20px;
    padding-right: 8px;
  }

  .article-item-actions {
    padding-right: 12px;
    gap: 4px;
  }

  .article-action-btn {
    width: 32px;
    height: 32px;
  }

  .reading-progress {
    margin: 0 -20px;
  }
}

/* ============================================================
   Annotations panel, chips, highlights — feat/annotations
   ============================================================ */
.annotations-toggle {
  margin-left: auto;
}

.annotations-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  background: var(--bg);
  border-left: 1px solid var(--bor);
  padding: 56px 20px 24px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 180ms ease;
  z-index: 50;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.04);
}
.annotations-panel.is-open {
  transform: translateX(0);
}
.annotations-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--t2);
  padding: 4px 8px;
}
.annotations-panel-close:hover { color: var(--t1); }

.annotations-section {
  margin-bottom: 24px;
}
.annotations-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t3);
  margin: 0 0 10px;
  font-weight: 600;
}

/* Tag chips */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 24px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: 999px;
  padding: 2px 4px 2px 10px;
  font-size: 13px;
}
.tag-chip-name {
  color: var(--t1);
  text-decoration: none;
}
.tag-chip-name:hover { text-decoration: underline; }
.tag-chip-remove {
  background: transparent;
  border: none;
  color: var(--t3);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}
.tag-chip-remove:hover { color: var(--t1); }

/* Tag autocomplete */
.tag-add-form {
  position: relative;
}
.tag-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--bor);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg);
  color: var(--t1);
  font-size: 14px;
  font-family: inherit;
}
.tag-input:focus {
  outline: 2px solid var(--ac);
  outline-offset: -1px;
}
.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--bor);
  border-radius: var(--radius-sm, 6px);
  margin-top: 4px;
  display: none;
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.tag-suggestions.is-open {
  display: block;
}
.tag-suggestion {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 7px 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--t1);
  font-family: inherit;
}
.tag-suggestion:hover,
.tag-suggestion.is-active {
  background: var(--sur);
}

/* Note */
.article-note-input,
.highlight-note-input {
  width: 100%;
  border: 1px solid var(--bor);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg);
  color: var(--t1);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  line-height: 1.5;
}
.article-note-input:focus,
.highlight-note-input:focus {
  outline: 2px solid var(--ac);
  outline-offset: -1px;
}
.saved-indicator {
  display: inline-block;
  font-size: 11px;
  color: var(--t3);
  margin-top: 4px;
  min-height: 1em;
}

/* Highlights list */
.highlight-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.highlight-item {
  position: relative;
  padding: 10px 28px 12px 0;
  border-bottom: 1px solid var(--bor);
}
.highlight-item:last-child { border-bottom: none; }
.highlight-item.is-orphan .highlight-quote::before {
  content: "⚠ ";
  color: var(--t3);
}
.highlight-quote {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--t2);
  font-style: italic;
  line-height: 1.4;
}
.highlight-remove {
  position: absolute;
  top: 6px;
  right: 0;
  background: transparent;
  border: none;
  color: var(--t3);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
}
.highlight-remove:hover { color: var(--t1); }

/* Mark applied to article body */
.reading-text mark[data-highlight-id] {
  background: #fff3a3;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* Floating "Marcar" button */
.highlight-create-btn {
  z-index: 100;
  padding: 4px 12px;
  background: var(--t1);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm, 4px);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.highlight-create-btn:hover { opacity: 0.92; }

/* Tag index page */
.tag-index-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tag-index-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bor);
}
.tag-index-item a {
  color: var(--t1);
  text-decoration: none;
  flex: 1;
}
.tag-index-item a:hover { text-decoration: underline; }
.tag-index-count {
  color: var(--t3);
  font-size: 13px;
}
.tag-index-remove {
  background: transparent;
  border: none;
  color: var(--t3);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}
.tag-index-remove:hover { color: var(--t1); }

@media (max-width: 768px) {
  .annotations-panel {
    width: 100vw;
    max-width: 100vw;
  }
}
