:root {
  --ink: #161a18;
  --ink-soft: #3a433e;
  --muted: #6b756f;
  --paper: #eef2ef;
  --paper-2: #e2e8e4;
  --surface: #f7faf8;
  --line: #c9d2cc;
  --brand: #1f5c4d;
  --brand-deep: #143d34;
  --brand-soft: #d5e8e1;
  --accent: #c45c26;
  --danger: #a33b2d;
  --radius: 10px;
  --thumb-h: 110px;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Segoe UI", "Source Sans 3", system-ui, sans-serif;
  --shadow-soft: 0 12px 40px rgba(20, 61, 52, 0.08);
}

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

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

html {
  overflow-x: clip;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  overflow-x: clip;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #d8ebe3 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #dde4df 0%, transparent 45%),
    linear-gradient(180deg, #f3f6f4 0%, var(--paper) 40%, #e8eee9 100%);
  background-attachment: fixed;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden { display: none !important; }

a { color: var(--brand); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--brand);
  color: #f5faf8;
  border-color: var(--brand-deep);
}

.btn-primary:hover { background: var(--brand-deep); }

.btn-ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.45);
}

.btn-ghost:hover { background: #fff; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, white);
}

.btn-block { width: 100%; }

.btn-icon {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  flex-shrink: 0;
}

.btn-label {
  white-space: nowrap;
}

.brand-mark {
  width: 1.35rem;
  height: auto;
  aspect-ratio: 664 / 797;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1;
}

/* Auth */
.auth-body {
  min-height: 100vh;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-page .auth-shell {
  flex: 1;
  min-height: 0;
}

.auth-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
}

.auth-panel {
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(247, 250, 248, 0.92);
  border-right: 1px solid var(--line);
}

.auth-brand .brand-name {
  font-size: clamp(2.4rem, 4vw, 3.2rem);
  margin-top: 0.75rem;
  color: var(--brand-deep);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}

.auth-brand .brand-mark {
  width: 3.75rem;
}

.auth-lead {
  color: var(--ink-soft);
  margin: 0.4rem 0 0;
  max-width: 28ch;
}

.auth-form {
  display: grid;
  gap: 0.9rem;
}

.auth-form label,
.stack-form label,
.modal-body label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

/* Color inputs need their own box: shared text padding collapses the swatch to a line. */
input[type="color"] {
  display: block;
  width: 100%;
  height: 2.75rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 5px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 40%, white);
  border-color: var(--brand);
}

.auth-switch {
  margin-top: 1.25rem;
  color: var(--muted);
}

.auth-visual {
  position: relative;
  background:
    linear-gradient(160deg, rgba(20, 61, 52, 0.82), rgba(31, 92, 77, 0.62)),
    url("../img/auth-visual.jpg") center / cover no-repeat,
    #1f5c4d;
  color: #f4faf7;
  display: flex;
  align-items: flex-end;
  padding: 3rem;
  overflow: hidden;
}

/* Soft vignette keeps text readable over the faded photo. */
.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, transparent 0%, rgba(20, 61, 52, 0.24) 100%),
    radial-gradient(ellipse 80% 70% at 12% 8%, rgba(244, 250, 247, 0.12), transparent 55%);
  pointer-events: none;
}

.auth-visual::after {
  content: "";
  position: absolute;
  inset: auto -10% -20% 40%;
  height: 70%;
  z-index: 0;
  background: radial-gradient(circle at center, rgba(196, 92, 38, 0.28), transparent 65%);
  pointer-events: none;
}

.auth-visual-inner {
  position: relative;
  z-index: 1;
  animation: riseIn 0.7s ease both;
}

.auth-visual-brand {
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 5rem);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.03em;
}

.auth-visual-text {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 22ch;
}

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.alert-error {
  background: #f8e8e5;
  color: #7a2c22;
  border: 1px solid #e5c4bd;
}

/* App shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 250, 248, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
  max-width: 100%;
  min-width: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex-shrink: 1;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-link:hover .brand-name {
  color: var(--brand);
}

.topbar-nav-link {
  margin-left: 0.15rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.topbar-nav-link:hover,
.topbar-nav-link.is-active {
  color: var(--brand-deep);
  background: rgba(255, 255, 255, 0.55);
}

.topbar-brand .brand-name {
  font-size: 1.55rem;
  color: var(--brand-deep);
}

.topbar-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 420px;
  min-width: 0;
  min-height: 2.4rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.15rem 0.75rem;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.topbar-search > i {
  color: var(--muted);
  font-size: 1.05rem;
  flex-shrink: 0;
}

.topbar-search:hover {
  background: #fff;
  border-color: color-mix(in srgb, var(--brand) 28%, var(--line));
}

.topbar-search:focus-within {
  background: #fff;
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-soft) 70%, transparent);
}

.topbar-search:focus-within > i {
  color: var(--brand);
}

.topbar-search input {
  border: 0;
  padding: 0.5rem 0;
  background: transparent;
  min-width: 0;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex-shrink: 0;
}

.topbar--doc .topbar-actions,
.topbar:not(.topbar--app) .topbar-actions {
  margin-left: auto;
}

.topbar-view {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: auto;
}

.view-dropdown {
  position: relative;
  min-width: 0;
}

.view-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  max-width: 100%;
  min-height: 2.4rem;
  padding: 0.4rem 0.65rem 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.view-dropdown-trigger:hover {
  background: #fff;
  border-color: color-mix(in srgb, var(--brand) 28%, var(--line));
}

.view-dropdown.is-open .view-dropdown-trigger {
  background: #fff;
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-soft) 70%, transparent);
}

.view-dropdown-icon {
  color: var(--brand);
  font-size: 1.05rem;
  flex-shrink: 0;
}

.view-dropdown-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-dropdown-caret {
  color: var(--muted);
  font-size: 1rem;
  margin-left: 0.1rem;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

.view-dropdown.is-open .view-dropdown-caret {
  transform: rotate(180deg);
}

.view-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 40;
  min-width: 13.5rem;
  padding: 0.35rem;
  border: 1px solid color-mix(in srgb, var(--line) 80%, white);
  border-radius: 12px;
  background: color-mix(in srgb, #fff 88%, var(--brand-soft));
  backdrop-filter: blur(14px);
  box-shadow:
    0 4px 6px rgba(20, 61, 52, 0.04),
    0 18px 40px rgba(20, 61, 52, 0.12);
  animation: dropdownIn 0.16s ease;
}

.view-dropdown-menu[hidden] {
  display: none;
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.view-dropdown-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}

.view-dropdown-option > i:first-child {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 7px;
  background: color-mix(in srgb, var(--brand-soft) 55%, white);
  color: var(--brand-deep);
  font-size: 1rem;
  flex-shrink: 0;
}

.view-dropdown-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
  flex: 1;
}

.view-dropdown-option-title {
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.2;
}

.view-dropdown-option-desc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.25;
}

.view-dropdown-check {
  color: var(--brand);
  font-size: 1.05rem;
  opacity: 0;
  flex-shrink: 0;
}

.view-dropdown-option:hover {
  background: rgba(255, 255, 255, 0.75);
  transform: translateX(1px);
}

.view-dropdown-option.is-selected {
  background: color-mix(in srgb, var(--brand-soft) 45%, white);
}

.view-dropdown-option.is-selected .view-dropdown-check {
  opacity: 1;
}

.view-dropdown-option.is-selected > i:first-child {
  background: var(--brand);
  color: #f5faf8;
}

.user-chip {
  font-size: 0.9rem;
  color: var(--ink-soft);
  padding: 0 0.35rem;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-form { display: inline; margin: 0; }

.category-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  overflow-x: auto;
  max-width: 100%;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  background: color-mix(in srgb, var(--surface) 70%, var(--line));
  border-radius: 2px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  color: var(--ink);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.cat-chip:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--surface) 40%, var(--line));
}

.cat-chip.active {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 600;
}

.cat-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--dot, var(--brand));
}

.cat-count {
  color: var(--muted);
  font-size: 0.8rem;
}

.cat-chip[draggable="true"] {
  cursor: grab;
}

.cat-chip.dragging {
  opacity: 0.45;
}

.cat-add {
  color: var(--brand-deep);
  background: transparent;
  outline: 1px dashed color-mix(in srgb, var(--brand) 45%, var(--line));
  outline-offset: -1px;
}

.cat-add:hover {
  background: var(--brand-soft);
  outline-color: var(--brand);
}

.main-area {
  padding: 1.25rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}

.pin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 1rem;
  min-width: 0;
}

.pin-grid[data-density="small"] {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: 0.65rem;
  --thumb-h: 84px;
}

.pin-grid[data-density="medium"] {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 1rem;
  --thumb-h: 110px;
}

.pin-grid[data-density="large"] {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1.15rem;
  --thumb-h: 160px;
}

.pin-grid[data-density="list"] {
  grid-template-columns: 1fr;
  gap: 0.65rem;
  max-width: 44rem;
  margin: 0 auto;
  width: 100%;
}

.pin-grid[data-density="small"] .pin-body {
  padding: 0.65rem 0.7rem 0.75rem;
  gap: 0.2rem;
}

.pin-grid[data-density="small"] .pin-title {
  font-size: 0.92rem;
}

.pin-grid[data-density="small"] .pin-note {
  display: none;
}

.pin-grid[data-density="large"] .pin-body {
  padding: 1rem 1.05rem 1.1rem;
}

.pin-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  animation: cardIn 0.35s ease both;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.pin-card:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  transform: translateY(-2px);
}

.pin-thumb {
  height: var(--thumb-h);
  background: var(--fallback, var(--brand-soft));
  position: relative;
  overflow: hidden;
}

.pin-thumb-photo {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pin-thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  position: relative;
  background:
    radial-gradient(circle at 28% 18%, color-mix(in srgb, #fff 26%, transparent), transparent 52%),
    linear-gradient(
      155deg,
      color-mix(in srgb, var(--fallback, var(--brand)) 72%, #fff),
      color-mix(in srgb, var(--fallback, var(--brand)) 88%, #1a1a1a)
    );
}

.pin-thumb-letter {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(2.8rem, 14vw, 4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: color-mix(in srgb, #fff 72%, transparent);
  text-shadow: 0 1px 0 color-mix(in srgb, #000 12%, transparent);
  user-select: none;
  pointer-events: none;
}

.pin-favicon {
  width: 16px;
  height: 16px;
  margin-top: 0.2rem;
  flex-shrink: 0;
  border-radius: 2px;
}

.pin-favicon-letter {
  display: inline-grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--paper-2, #eef1ef);
}

.pin-cat-tag {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 2;
  max-width: calc(100% - 0.9rem);
  padding: 0.2rem 0.4rem;
  border-radius: 0;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #f7faf8;
  background: color-mix(in srgb, var(--cat, var(--brand)) 92%, #111 8%);
  border: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.pin-body {
  padding: 0.85rem 0.9rem 1rem;
  display: grid;
  gap: 0.35rem;
  flex: 1;
}

.pin-title-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.pin-title {
  font-weight: 650;
  font-size: 0.98rem;
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pin-domain {
  font-size: 0.8rem;
  color: var(--muted);
}

.pin-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 0;
}

.pin-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.pin-visits {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pin-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.pin-edit:hover {
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  max-width: 28rem;
  margin: 2rem auto;
  animation: riseIn 0.45s ease both;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--brand-deep);
  margin: 0 0 0.5rem;
}

.empty-state p {
  color: var(--muted);
}

/* Modal */
.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 2rem);
}

.modal::backdrop {
  background: rgba(18, 28, 24, 0.45);
  backdrop-filter: blur(2px);
}

.modal-card {
  width: min(440px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  animation: riseIn 0.25s ease both;
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-family: var(--font-display);
  flex: 1;
}

.modal-body {
  padding: 1rem;
  display: grid;
  gap: 0.85rem;
}

.settings-body {
  max-height: min(70vh, 560px);
  overflow: auto;
}

.settings-body h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.settings-body section + section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.stack-form {
  display: grid;
  gap: 0.75rem;
}

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

.token-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.token-status i { font-size: 1.05rem; line-height: 1; }

.token-status.is-active {
  color: var(--brand-deep);
}

.token-status.is-active i { color: var(--brand); }

.token-status.is-inactive {
  color: var(--muted);
  font-weight: 500;
}

.token-status.is-new {
  color: var(--accent);
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.token-reveal {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.65rem;
  word-break: break-all;
}

.token-reveal code {
  flex: 1;
  font-size: 0.82rem;
}

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

.settings-cat-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.form-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0;
}

.form-msg {
  font-size: 0.9rem;
  margin: 0;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #f5faf8;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 50;
  animation: riseIn 0.25s ease both;
}

.go-top {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.65rem;
  height: 2.65rem;
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, #fff 88%, var(--brand-soft));
  color: var(--brand-deep);
  box-shadow:
    0 4px 6px rgba(20, 61, 52, 0.04),
    0 14px 28px rgba(20, 61, 52, 0.12);
  backdrop-filter: blur(12px);
  cursor: pointer;
  font-size: 1.25rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
  animation: riseIn 0.2s ease both;
}

.go-top[hidden] {
  display: none;
}

.go-top:hover {
  background: #fff;
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
  transform: translateY(-2px);
}

.go-top:active {
  transform: translateY(0);
}

@media (max-width: 860px) {
  .go-top {
    right: 0.85rem;
    bottom: 0.85rem;
  }
}

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

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

/* Support / How-to */
.support-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.support-main {
  flex: 1;
  padding: 1.5rem 1.25rem 3rem;
}

.howto-article {
  max-width: 42rem;
  margin: 0 auto;
  animation: riseIn 0.35s ease both;
}

.howto-hero {
  margin-bottom: 1.5rem;
}

.howto-eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.howto-hero h1 {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand-deep);
  line-height: 1.15;
}

.howto-lead {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.howto-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.howto-toc a {
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  color: var(--brand-deep);
}

.howto-toc a:hover {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.howto-section {
  margin-bottom: 2.25rem;
  scroll-margin-top: 1.5rem;
}

.howto-section h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand-deep);
  letter-spacing: -0.015em;
}

.howto-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 1rem;
}

.howto-steps li {
  counter-increment: step;
  position: relative;
  padding: 0.9rem 1rem 0.9rem 3.1rem;
  background: color-mix(in srgb, var(--surface) 88%, white);
  border: 1px solid var(--line);
  border-radius: 0;
}

.howto-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0.85rem;
  top: 0.95rem;
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #f5faf8;
  background: var(--brand);
}

.howto-steps strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--ink);
}

.howto-steps p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
  font-size: 0.95rem;
}

.howto-steps code {
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  background: var(--paper-2);
  border-radius: 3px;
}

.howto-steps em {
  font-style: normal;
  font-weight: 600;
  color: var(--ink);
}

.legal-section p,
.legal-section li {
  color: var(--ink-soft);
  line-height: 1.55;
  font-size: 0.98rem;
}

.legal-section p {
  margin: 0 0 0.85rem;
}

.legal-section ul {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
}

.legal-section li {
  margin-bottom: 0.35rem;
}

.legal-section a {
  color: var(--brand-deep);
  font-weight: 600;
}

.legal-section a:hover {
  color: var(--brand);
}

/* Popular */
.popular-main {
  max-width: 44rem;
  margin: 0 auto;
  width: 100%;
}

.popular-hero {
  animation: riseIn 0.35s ease both;
}

.popular-toc {
  animation: riseIn 0.4s ease both;
}

.popular-section {
  margin-bottom: 2.25rem;
  scroll-margin-top: 1.5rem;
  animation: riseIn 0.45s ease both;
}

.popular-section h2 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand-deep);
  letter-spacing: -0.015em;
}

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

.popular-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  background: color-mix(in srgb, var(--surface) 88%, white);
  border: 1px solid var(--line);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.popular-item:hover {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  background: #fff;
}

.popular-item-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.popular-favicon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--paper-2);
}

.popular-favicon-letter {
  display: inline-grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1;
}

.popular-item-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.popular-item-title {
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.popular-item-meta {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popular-open-icon {
  color: var(--muted);
  font-size: 1.05rem;
}

.popular-item-main:hover .popular-item-title {
  color: var(--brand-deep);
}

.popular-item-main:hover .popular-open-icon {
  color: var(--brand);
}

.popular-add-btn {
  white-space: nowrap;
  font-size: 0.88rem;
  padding: 0.45rem 0.7rem;
  text-decoration: none;
}

.popular-add-preview {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.85rem;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink-soft);
  word-break: break-all;
}

.popular-add-preview strong {
  color: var(--ink);
  font-size: 1rem;
}

@media (max-width: 640px) {
  .popular-item {
    grid-template-columns: 1fr;
  }

  .popular-add-btn {
    justify-self: stretch;
  }

  .popular-item-meta {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

.site-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, white);
}

.site-footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1.25rem;
}

.site-footer-copy {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.15rem;
}

.site-footer-nav a {
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--brand-deep);
}

.site-footer-nav a:hover,
.site-footer-nav a[aria-current="page"] {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.app-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-body .app-shell {
  flex: 1;
}

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { min-height: 180px; padding: 1.5rem; }

  .topbar--app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "search search"
      "view view";
    align-items: center;
    gap: 0.6rem 0.5rem;
    padding: 0.7rem 0.85rem;
  }

  .topbar--app .topbar-brand {
    grid-area: brand;
  }

  .topbar--app .topbar-nav {
    display: none;
  }

  .topbar--app .topbar-search {
    grid-area: search;
    order: unset;
    max-width: none;
    width: 100%;
  }

  .topbar--app .topbar-view {
    grid-area: view;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    width: 100%;
    margin-left: 0;
  }

  .topbar--app .topbar-actions {
    grid-area: actions;
    gap: 0.3rem;
  }

  .topbar--app .btn-label {
    display: none;
  }

  .topbar--app #btnNewPin {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
  }

  .topbar--app .view-dropdown-trigger {
    width: 100%;
    justify-content: flex-start;
    font-size: 0.88rem;
    padding: 0.45rem 0.55rem;
  }

  .topbar--app .view-dropdown-menu {
    left: 0;
    right: 0;
    min-width: 0;
    width: 100%;
  }

  .topbar--doc {
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0.7rem 0.85rem;
  }

  .topbar--doc .topbar-brand {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .topbar--doc .topbar-brand::-webkit-scrollbar {
    display: none;
  }

  .topbar--doc .topbar-nav {
    flex-shrink: 0;
  }

  .topbar--doc .topbar-nav-link {
    padding: 0.3rem 0.45rem;
    font-size: 0.82rem;
  }

  .topbar--doc .btn-label {
    display: none;
  }

  .user-chip { display: none; }

  .category-bar {
    padding: 0.7rem 0.85rem;
  }

  .main-area {
    padding: 0.85rem;
  }

  .pin-grid:not([data-density="list"]) {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  }

  .pin-grid[data-density="small"] {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  }

  .pin-grid[data-density="large"] {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
  }

  :root { --thumb-h: 96px; }
}

@media (max-width: 480px) {
  .topbar-brand .brand-name {
    font-size: 1.28rem;
  }

  .site-footer {
    padding: 0.85rem;
  }
}
