:root {
  color-scheme: light;
  --bg: #f8f8f7;
  --bg-soft: #f1f0ee;
  --fg: #222221;
  --muted: #62615d;
  --accent: #823f22;
  --accent-soft: #f2ece7;
  --card: #fdfdfc;
  --border: #dadad7;
  --code-bg: #f1f0ee;
  --shadow: 0 10px 28px rgba(35, 34, 32, 0.1);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #131312;
  --bg-soft: #1b1a19;
  --fg: #e7e6e3;
  --muted: #999995;
  --accent: #cb9050;
  --accent-soft: #27251c;
  --card: #1b1a19;
  --border: #343431;
  --code-bg: #1b1a19;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.container {
  width: min(1000px, calc(100% - 2rem));
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 0.85rem;
}

.site-logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-nav-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  transition: border-color 0.2s, color 0.2s;
}

.site-nav-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Intro */
.intro {
  padding: 0 0 0.5rem;
}

.intro-title {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

/* Filtro por tag */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.tag-filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.tag-filter-control {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tag-filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.tag-filter-trigger:hover,
.tag-filter-trigger:focus,
.tag-filter-trigger[aria-expanded='true'] {
  outline: none;
  border-color: var(--accent);
  color: var(--accent);
}

.tag-filter-arrow {
  width: 12px;
  height: 8px;
  color: var(--muted);
  transition: transform 0.2s, color 0.2s;
}

.tag-filter-trigger:hover .tag-filter-arrow,
.tag-filter-trigger[aria-expanded='true'] .tag-filter-arrow {
  color: var(--accent);
}

.tag-filter-trigger[aria-expanded='true'] .tag-filter-arrow {
  transform: rotate(180deg);
}

.tag-filter-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 20;
  min-width: 100%;
  max-height: 15rem;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.tag-filter-option {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--fg);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.tag-filter-option:hover,
.tag-filter-option:focus {
  outline: none;
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-filter-option[aria-selected='true'] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

/* Layout com submenu lateral */
.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 50rem) minmax(0, 1fr);
  gap: 70px;
  width: 100%;
  max-width: 100rem;
  margin-inline: auto;
  padding-inline: 1.5rem;
  padding-top: 1.75rem;
  align-items: start;
}

.main-col {
  grid-column: 2;
  min-width: 0;
}

.sidebar {
  grid-column: 3;
  justify-self: start;
  width: 9rem;
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  padding: 0.25rem 0;
  align-self: stretch;
}

.sidebar-title {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}

.menu-list a {
  display: block;
  padding: 0.3rem 0.4rem;
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.35;
  transition: background-color 0.15s, color 0.15s;
}

.menu-list a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.menu-list a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.toc-level-3 a {
  padding-left: 0.85rem;
  font-size: 0.78rem;
}

/* Arquivo de artigos */
.archive-group {
  padding-block: 1.5rem;
  scroll-margin-top: 5rem;
}

.archive-group:first-child {
  padding-top: 0.5rem;
}

.archive-group-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.1rem;
  font-size: 1.05rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.archive-group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

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

.article-card {
  margin: 0;
  position: relative;
}

.share {
  margin-top: 2.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.share-label {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.share-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.share-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}

.share-option:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.share-option span {
  white-space: nowrap;
}

.share-option.done {
  border-color: var(--accent);
  color: var(--accent);
}

.share-svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
}

.share-card {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 2;
}

.share-nav {
  position: relative;
  inset: auto;
  display: inline-flex;
}

.share-nav .share-trigger {
  width: 38px;
  height: 38px;
  color: var(--fg);
  background: var(--card);
}

.share-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.share-trigger:hover,
.share-trigger[aria-expanded='true'] {
  color: var(--accent);
  border-color: var(--accent);
}

.share-popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 10;
  display: grid;
  gap: 0.15rem;
  width: 13.5rem;
  padding: 0.4rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.share-popover[hidden] {
  display: none;
}

.share-popover .share-option {
  justify-content: flex-start;
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: none;
  border: none;
  border-radius: 8px;
  text-align: left;
}

.share-popover .share-option:hover {
  background: var(--bg-soft);
  transform: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 50;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: var(--bg);
  background: var(--fg);
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 0.75rem);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.article-card-link {
  display: block;
  padding: 1rem 3rem 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.15s;
}

.article-card-link:hover {
  border-color: var(--accent);
}

.article-title {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
  color: var(--fg);
}

.article-meta {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.article-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.article-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 0;
  padding: 0;
}

.article-tags li {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* Página do artigo */
.post {
  padding: 2rem 0 3rem;
}

.post-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
  margin-bottom: 1.75rem;
}

.post-title {
  margin: 0 0 0.5rem;
  font-size: 2.1rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.post-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
}

.post-tags span {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.post-content {
  font-size: 1.05rem;
}

.post-content h2 {
  margin-top: 2rem;
  font-size: 1.5rem;
  scroll-margin-top: 5rem;
}

.post-content h3 {
  margin-top: 1.75rem;
  font-size: 1.2rem;
  scroll-margin-top: 5rem;
}

.post-content a {
  color: var(--accent);
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.post-content blockquote {
  margin: 1rem 0;
  padding: 0.1rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}

.post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  overflow-x: auto;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-back {
  margin-top: 2.5rem;
}

.post-back a {
  color: var(--accent);
}

/* Página Sobre mim */
.about-header {
  padding-bottom: 1.5rem;
}

.about-header .intro-title {
  margin-bottom: 0.35rem;
}

.about-tagline {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.about-social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.about-social-link {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  transition: filter 0.2s;
}

.about-social-link:hover {
  filter: brightness(1.1);
}

.about-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  scroll-margin-top: 5rem;
}

.about-card h2 {
  margin: 0 0 0.6rem;
  font-size: 1.15rem;
}

.about-card p {
  margin: 0.5rem 0;
  color: var(--fg);
}

.about-card a {
  color: var(--accent);
}

.about-history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.about-history li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--border);
}

.about-history li:last-child {
  border-bottom: none;
}

.about-years {
  flex: 0 0 auto;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.about-tech {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0;
}

.about-tech li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 999px;
  font-size: 0.85rem;
}

.about-tech img {
  width: 18px;
  height: 18px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.5rem;
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 1000px) {
  .page-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    padding-inline: 1rem;
  }

  .main-col,
  .sidebar {
    grid-column: 1;
  }

  .sidebar {
    order: -1;
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
    align-self: auto;
    margin-top: 1rem;
  }

  .menu-list {
    display: flex;
    overflow-x: auto;
  }

  .menu-list li {
    flex: 0 0 auto;
  }
}

@media (max-width: 600px) {
  .intro {
    padding-top: 1.5rem;
  }

  .post-title {
    font-size: 1.6rem;
  }
}