:root {
  --paper: #fff;
  --ink: #242424;
  --slate: #6b6b6b;
  --faint: #f2f2f2;
  --faint-2: #f9f9f9;
  --rule: #e6e6e6;
  --rule-soft: #f2f2f2;
  --code: #f5f5f5;
  --accent: #1a8917;
  --accent-dark: #156d12;
  --danger: #c94a3a;
  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  --body: "Newsreader", "Charter", Georgia, serif;
  --ui: "Figtree", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", ui-monospace, monospace;
  --read: 42.5rem;
  --wide: 78rem;
  --pad: 1.5rem;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.08);
  --radius: 4px;
}

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

html {
  overflow-x: clip;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.has-drawer,
body.has-modal {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 2px;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

svg {
  display: block;
  flex: none;
}

.dot {
  color: var(--slate);
  margin: 0 0.35rem;
}

/* ---------- carregamento ---------- */

.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  height: 2px;
  width: 0;
  background: var(--ink);
  pointer-events: none;
  opacity: 0;
  transition: width 0.35s ease, opacity 0.2s ease;
}

.progress.is-on {
  opacity: 1;
  width: 70%;
}

.progress.is-done {
  width: 100%;
  opacity: 0;
  transition: width 0.15s ease, opacity 0.25s ease 0.1s;
}

main.shell.is-loading {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #fff;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  z-index: 1100;
  opacity: 0;
  max-width: calc(100vw - 2rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: var(--shadow);
}

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

/* ---------- cabeçalho ---------- */

.top {
  border-bottom: 1px solid var(--rule-soft);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-inner {
  width: min(100%, var(--wide));
  margin: 0 auto;
  min-height: 3.6rem;
  padding: 0 var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.mark {
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  color: var(--ink);
  line-height: 1;
}

.draft-of {
  color: var(--slate);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-state {
  color: var(--slate);
  font-size: 0.82rem;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
  flex: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--slate);
  padding: 0;
  list-style: none;
}

.icon-btn:hover {
  color: var(--ink);
  background: var(--faint);
}

.icon-btn.is-fav {
  color: var(--accent);
}

summary.icon-btn::-webkit-details-marker {
  display: none;
}

.write-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--slate);
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
}

.write-link:hover {
  color: var(--ink);
}

button.write-link {
  border: 0;
  background: transparent;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  border: 0;
  padding: 0;
  flex: none;
}

button.avatar:hover {
  opacity: 0.85;
}

.avatar-sm {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.7rem;
}

.avatar-lg {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.1rem;
}

.avatar-menu,
.publish,
details.menu {
  position: relative;
}

.menu-pop {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 14rem;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.5rem;
  z-index: 60;
  animation: pop 0.14s ease;
}

.menu-pop-right {
  left: auto;
  right: 0;
}

.menu-pop-wide {
  min-width: 18rem;
  width: max-content;
  max-width: min(22rem, calc(100vw - 2rem));
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.menu-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.6rem 0.75rem;
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 0.35rem;
}

.menu-user p {
  margin: 0;
}

.menu-user-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.menu-user-sub {
  color: var(--slate);
  font-size: 0.8rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius);
  color: var(--slate);
  font-size: 0.92rem;
}

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

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: #fdf0ee;
  color: var(--danger);
}

.menu-label {
  margin: 0.55rem 0.6rem 0.3rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  font-weight: 600;
}

.menu-label:first-child {
  margin-top: 0.25rem;
}

.menu-note {
  margin: 0 0.6rem 0.5rem;
  font-size: 0.85rem;
  color: var(--slate);
}

.menu-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0 0.35rem 0.35rem;
  margin: 0;
}

.menu-form > input[type="text"],
.menu-form > .cbox {
  flex: 1 1 8rem;
  min-width: 0;
  width: 100%;
}

.menu-form + .menu-form {
  border-top: 1px solid var(--rule-soft);
  padding-top: 0.5rem;
  margin-top: 0.35rem;
}

.menu-confirm {
  margin: 0.6rem 0.35rem 0.25rem;
  width: calc(100% - 0.7rem);
}

details.menu > summary {
  cursor: pointer;
}

details.menu > .menu-pop {
  top: calc(100% + 0.35rem);
}

/* ---------- shell ---------- */

.shell {
  width: min(100%, var(--wide));
  margin: 0 auto;
  padding: 2rem var(--pad) 5rem;
}

.is-editor .shell {
  width: 100%;
  padding: 0;
}

/* ---------- botões e campos ---------- */

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 0.45rem 1.05rem;
  border-radius: 999px;
  white-space: nowrap;
}

.pill-btn:hover {
  background: var(--faint);
}

.pill-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pill-btn.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.pill-btn.ghost {
  border-color: transparent;
  color: var(--slate);
}

.pill-btn.ghost:hover {
  color: var(--ink);
  background: var(--faint);
}

.pill-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

input[type="text"],
input[type="password"],
input[type="url"],
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="url"]:focus {
  border-color: var(--ink);
  outline: none;
}

/* ---------- select customizado ---------- */

.cbox {
  position: relative;
  display: inline-block;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  font-size: 0.92rem;
}

.cbox-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  margin: 0;
  padding: 0;
  border: 0;
}

.cbox-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem 0.5rem 0.75rem;
  text-align: left;
  color: var(--ink);
}

.cbox-btn:hover {
  border-color: var(--slate);
}

.cbox.is-open .cbox-btn {
  border-color: var(--ink);
}

.cbox-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cbox-btn svg {
  color: var(--slate);
  transition: transform 0.15s ease;
}

.cbox.is-open .cbox-btn svg {
  transform: rotate(180deg);
}

.cbox-pop {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  right: 0;
  min-width: 100%;
  width: auto;
  max-width: min(22rem, calc(100vw - 2rem));
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 80;
  padding: 0.4rem;
  animation: pop 0.14s ease;
}

.cbox.is-up .cbox-pop {
  top: auto;
  bottom: calc(100% + 0.3rem);
}

.cbox-search {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--rule-soft);
  border-radius: 0;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  background: transparent;
}

.cbox-search:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.cbox-list {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  max-height: 15rem;
  overflow-y: auto;
}

.cbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink);
  white-space: normal;
  overflow-wrap: anywhere;
}

.cbox-item:hover,
.cbox-item.is-active {
  background: var(--faint);
}

.cbox-item.is-disabled {
  color: var(--slate);
  cursor: default;
  opacity: 0.6;
}

.cbox-check {
  visibility: hidden;
  color: var(--accent);
}

.cbox-item.is-selected .cbox-check {
  visibility: visible;
}

.cbox-empty {
  padding: 0.6rem;
  color: var(--slate);
  font-size: 0.88rem;
}

/* ---------- gaveta lateral ---------- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(24rem, 100%);
  max-width: 100vw;
  background: var(--paper);
  box-shadow: var(--shadow);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}

.drawer.is-open .drawer-backdrop {
  opacity: 1;
}

.drawer.is-open .drawer-panel {
  transform: none;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border-bottom: 1px solid var(--rule-soft);
}

.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--faint);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  color: var(--slate);
}

.search-field input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.search-field input:focus {
  outline: none;
}

.drawer-body {
  overflow-y: auto;
  padding: 0.75rem 1rem 2rem;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results a {
  display: block;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule-soft);
}

.search-results a:hover .search-nome {
  color: var(--accent);
}

.search-nome {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.search-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--slate);
  margin-top: 0.25rem;
}

.search-empty {
  color: var(--slate);
  font-size: 0.9rem;
  padding: 0.75rem 0;
}

.search-group {
  margin: 0.85rem 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate);
  font-weight: 600;
}

.search-group:first-child {
  margin-top: 0.15rem;
}

.drawer-tree .eyebrow {
  margin: 0.75rem 0 0.5rem;
}

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

.tree .tree {
  padding-left: 0.9rem;
  border-left: 1px solid var(--rule-soft);
  margin-left: 0.35rem;
}

.tree a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.4rem;
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 0.95rem;
}

.tree a:hover {
  background: var(--faint);
}

.tree-count {
  color: var(--slate);
  font-size: 0.75rem;
}

/* ---------- modal CLI ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-card {
  position: relative;
  width: min(32rem, 100%);
  max-height: min(36rem, calc(100vh - 2.5rem));
  overflow: auto;
  background: var(--paper);
  box-shadow: var(--shadow);
  border-radius: 10px;
  transform: translateY(10px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal.is-open .modal-backdrop {
  opacity: 1;
}

.modal.is-open .modal-card {
  transform: none;
  opacity: 1;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--rule-soft);
}

.modal-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.modal-body {
  padding: 1.1rem 1.15rem 1.35rem;
}

.modal-body p {
  margin: 0 0 1rem;
  color: var(--slate);
  font-size: 0.95rem;
}

.modal-body .pill-btn {
  margin-bottom: 1.15rem;
}

.cli-steps {
  margin: 0;
  padding: 0 0 0 1.15rem;
  display: grid;
  gap: 0.85rem;
  color: var(--ink);
  font-size: 0.92rem;
}

.cli-steps pre {
  margin: 0.45rem 0 0;
  padding: 0.7rem 0.8rem;
  background: var(--faint);
  border-radius: var(--radius);
  overflow-x: auto;
}

.cli-steps code,
.modal-body p code {
  font-family: var(--mono);
  font-size: 0.82em;
}

.cli-steps pre code {
  font-size: 0.8rem;
}

/* ---------- tipografia ---------- */

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate);
  font-weight: 600;
}

h1 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin: 0;
  font-size: clamp(1.75rem, 3.6vw, 2.35rem);
  overflow-wrap: anywhere;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--slate);
}

.crumbs a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.sep {
  opacity: 0.5;
}

.star {
  color: var(--accent);
}

.token {
  font-family: var(--mono);
  font-size: 0.78em;
  background: var(--faint);
  padding: 0.12em 0.4em;
  border-radius: 3px;
}

.status {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--faint);
  color: var(--slate);
}

.status-active {
  color: var(--accent);
  background: #e9f4e8;
}

.status-inactive {
  color: var(--danger);
  background: #fdf0ee;
}

/* ---------- biblioteca ---------- */

.home {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 1.5rem;
}

.chips-sub {
  border-bottom: 0;
  padding-bottom: 0;
  margin: 0 0 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  font-size: 0.86rem;
  color: var(--slate);
  background: var(--faint);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  border: 1px solid transparent;
}

.chip:hover {
  color: var(--ink);
}

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

.chip-create {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
  margin: 0;
  padding: 0.15rem 0.2rem 0.15rem 0.85rem;
  border: 1px dashed var(--rule);
  border-radius: 999px;
  background: var(--paper);
}

.chip-create input[type="text"] {
  border: 0;
  background: transparent;
  padding: 0.3rem 0;
  min-width: 8.5rem;
  width: 8.5rem;
  font-size: 0.86rem;
}

.chip-create input[type="text"]:focus {
  outline: none;
}

.chip-create .pill-btn {
  padding: 0.32rem 0.85rem;
  font-size: 0.82rem;
}

.chip-count {
  font-size: 0.75rem;
  opacity: 0.7;
}

.dir-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.dir-title {
  min-width: 0;
  flex: 1 1 12rem;
}

.dir-title h1,
.dir-title .crumbs {
  overflow-wrap: anywhere;
}

.dir-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}

details.menu > summary.pill-btn {
  list-style: none;
}

details.menu > summary.pill-btn::-webkit-details-marker {
  display: none;
}

.dir-title h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

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

.story + .story {
  border-top: 1px solid var(--rule-soft);
}

.story-link {
  display: block;
  padding: 1.6rem 0;
}

.story-by {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: var(--ink);
}

.story-in {
  color: var(--slate);
}

.story-in strong {
  color: var(--ink);
  font-weight: 500;
}

.story-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.25rem, 2.4vw, 1.5rem);
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 0 0 0.4rem;
  overflow-wrap: anywhere;
}

.story-link:hover .story-title {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.story-excerpt {
  font-family: var(--body);
  font-size: 1.05rem;
  color: var(--slate);
  margin: 0 0 0.75rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  font-size: 0.82rem;
  color: var(--slate);
}

.story-meta .star {
  margin-right: 0.4rem;
}

.empty {
  padding: 3rem 0;
  text-align: center;
  color: var(--slate);
  display: grid;
  gap: 1rem;
  justify-items: center;
}

.empty p {
  margin: 0;
  font-family: var(--body);
  font-size: 1.15rem;
}

.home-side {
  display: none;
}

.side-block + .side-block {
  margin-top: 2rem;
}

.side-title {
  font-family: var(--ui);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.side-empty {
  color: var(--slate);
  font-size: 0.88rem;
  margin: 0;
}

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

.side-list li + li {
  margin-top: 0.6rem;
}

.side-list a {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.side-list a:hover {
  text-decoration: underline;
}

.side-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- leitura ---------- */

.reading {
  width: min(100%, var(--read));
  margin: 0 auto;
  min-width: 0;
}

.reading-head {
  margin-bottom: 2rem;
}

.reading-head h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin: 0.25rem 0 1.25rem;
}

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

.byline p {
  margin: 0;
}

.by-name {
  font-weight: 500;
  font-size: 0.95rem;
}

.by-meta {
  color: var(--slate);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.story-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 1.25rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
}

.story-bar .inline {
  display: inline-flex;
  margin: 0;
}

.story-bar details.menu {
  margin-left: auto;
}

.reading-foot {
  display: flex;
  gap: 0.6rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule-soft);
}

/* ---------- prosa ---------- */

.prose {
  font-family: var(--body);
  font-size: 1.3rem;
  line-height: 1.68;
  letter-spacing: -0.003em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--ui);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 2em 0 0.5em;
}

.prose h1 {
  font-size: 1.75rem;
}

.prose h2 {
  font-size: 1.45rem;
}

.prose h3 {
  font-size: 1.2rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.5rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.prose pre {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.55;
  background: var(--code);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  max-width: 100%;
  margin: 0 0 1.75rem;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--code);
  padding: 0.12em 0.32em;
  border-radius: 3px;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.prose blockquote {
  margin: 0 0 1.75rem;
  padding: 0 0 0 1.25rem;
  border-left: 3px solid var(--ink);
  font-style: italic;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose hr {
  border: 0;
  text-align: center;
  margin: 2.5rem 0;
}

.prose hr::before {
  content: "· · ·";
  letter-spacing: 0.6em;
  color: var(--slate);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  font-family: var(--ui);
  margin: 0 0 1.75rem;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--rule);
  text-align: left;
  padding: 0.55rem 0.65rem;
  vertical-align: top;
}

.prose th {
  font-weight: 600;
}

.prose img {
  max-width: 100%;
}

.prose .math-block {
  overflow-x: auto;
  margin: 0 0 1.75rem;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in {
  color: var(--accent-dark);
}

.hljs-string,
.hljs-attr {
  color: #2f6f4e;
}

.hljs-number,
.hljs-literal {
  color: var(--danger);
}

.hljs-comment {
  color: var(--slate);
  font-style: italic;
}

/* ---------- login / páginas estreitas ---------- */

.is-auth .shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem var(--pad);
}

.auth {
  width: min(100%, 22rem);
  max-width: 100%;
  text-align: center;
}

.auth-mark {
  font-size: 3rem;
  margin-bottom: 2rem;
}

.auth-form {
  display: grid;
  gap: 1rem;
  text-align: left;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--slate);
}

.auth-form input {
  padding: 0.7rem 0.85rem;
}

.auth-form .pill-btn {
  margin-top: 0.5rem;
  padding: 0.65rem 1rem;
}

.flash {
  background: #fdf0ee;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.narrow {
  width: min(100%, 30rem);
  margin: 4rem auto 0;
  display: grid;
  gap: 1rem;
  justify-items: start;
  max-width: 100%;
}

/* ---------- editor ---------- */

.top-editor {
  position: sticky;
  border-bottom-color: transparent;
}

.editor {
  padding: 2.5rem 0 8rem;
}

.editor-inner {
  width: min(100%, var(--read));
  margin: 0 auto;
  padding: 0 var(--pad);
  min-width: 0;
}

.ed-title,
.ed-body {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  resize: none;
  overflow: hidden;
  color: var(--ink);
}

.ed-title:focus,
.ed-body:focus {
  outline: none;
}

.ed-title {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.ed-title::placeholder,
.ed-body::placeholder {
  color: #b3b3b1;
}

.ed-body-wrap {
  position: relative;
  padding-left: 2.85rem;
}

.ed-body {
  font-family: var(--body);
  font-size: 1.3rem;
  line-height: 1.68;
  min-height: 50vh;
}

.ed-preview {
  min-height: 50vh;
}

.editor.is-previewing .ed-title {
  pointer-events: none;
}

.ed-mirror {
  position: absolute;
  top: 0;
  left: -9999px;
  visibility: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  pointer-events: none;
}

.plus {
  position: absolute;
  left: 0;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid #b3b3b1;
  background: var(--paper);
  color: #6b6b6b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.plus:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.plus.is-open {
  transform: rotate(45deg);
  color: var(--ink);
  border-color: var(--ink);
}

.plus-menu {
  position: absolute;
  left: 2.75rem;
  display: flex;
  gap: 0.35rem;
  background: var(--paper);
  padding: 0.35rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 30;
  animation: pop 0.14s ease;
  max-width: calc(100% - 2.75rem);
  overflow-x: auto;
  scrollbar-width: none;
}

.plus-menu::-webkit-scrollbar {
  display: none;
}

.plus-menu button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  width: 3.4rem;
  padding: 0.35rem 0.2rem;
  border: 0;
  background: transparent;
  color: var(--slate);
  font-size: 0.62rem;
  border-radius: 1rem;
}

.plus-menu button:hover {
  color: var(--ink);
  background: var(--faint);
}

.pm-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  font-family: var(--ui);
  font-size: 0.85rem;
  font-weight: 600;
}

.bubble {
  position: absolute;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.1rem;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  padding: 0.3rem 0.35rem;
  box-shadow: var(--shadow);
  animation: pop 0.12s ease;
  max-width: calc(100vw - 1.5rem);
  overflow-x: auto;
}

.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--ink);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}

.bubble.is-below::after {
  bottom: auto;
  top: -6px;
}

.bubble > button {
  background: transparent;
  border: 0;
  color: #fff;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 4px;
  font-family: var(--body);
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bubble > button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.bubble-sep {
  width: 1px;
  height: 1.4rem;
  background: rgba(255, 255, 255, 0.3);
  margin: 0 0.3rem;
}

.bub-t {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
}

.bub-t-sm {
  font-size: 0.95rem;
}

.bubble.is-link > button,
.bubble.is-link .bubble-sep {
  display: none;
}

.bubble-link {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.1rem;
}

.bubble-link input {
  background: transparent;
  border: 0;
  color: #fff;
  width: 16rem;
  max-width: 60vw;
  padding: 0.35rem 0.4rem;
  font-size: 0.92rem;
}

.bubble-link input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.bubble-link input:focus {
  outline: none;
}

.bubble-link button {
  background: transparent;
  border: 0;
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
}

.bubble-link button:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ---------- responsivo ---------- */

@media (min-width: 1080px) {
  .home {
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 5rem;
  }

  .home-side {
    display: block;
    border-left: 1px solid var(--rule-soft);
    padding-left: 2.5rem;
    position: sticky;
    top: 5rem;
    align-self: start;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    min-width: 0;
  }
}

@media (max-width: 860px) {
  :root {
    --pad: 1.15rem;
  }

  .top-editor .top-inner {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  .top-editor .top-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .save-state {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --pad: 1rem;
  }

  .write-link span,
  .draft-of {
    display: none;
  }

  .mark {
    font-size: 1.4rem;
  }

  .dir-actions {
    width: 100%;
  }

  .dir-actions .pill-btn {
    width: 100%;
    justify-content: center;
  }

  .editor {
    padding: 1.5rem 0 6rem;
  }

  .ed-body-wrap {
    padding-left: 2.5rem;
  }

  .plus {
    width: 2rem;
    height: 2rem;
  }

  .plus-menu {
    left: 0;
    top: 2.4rem;
    max-width: 100%;
  }

  .prose,
  .ed-body {
    font-size: 1.15rem;
    line-height: 1.6;
  }

  .story-link {
    padding: 1.25rem 0;
  }

  .story-excerpt {
    display: none;
  }

  .reading-head h1 {
    font-size: clamp(1.65rem, 8vw, 2.2rem);
  }

  .reading-foot {
    flex-wrap: wrap;
  }

  .menu-pop,
  .menu-pop-wide {
    max-width: calc(100vw - 2rem);
  }

  .auth-mark {
    font-size: 2.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
