/* Link Vault design system */
:root {
  --bg: #f6f4ee;
  --surface: #fffdf7;
  --surface-muted: #fbf8f1;
  --border: #ddd6c6;
  --text: #1f1d17;
  --muted: #6d675b;
  --accent: #202020;
  --accent-soft: #ece7db;
  --success: #126d3d;
  --warning: #8a6100;
  --danger: #9d3434;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(31, 29, 23, 0.06);
  --control-font-size: 14px;
  --control-radius: 12px;
  --control-height: 36px;
  --control-height-small: 36px;
  --control-padding-x: 12px;
  --control-border-width: 1px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(circle at top left, rgba(32, 32, 32, 0.04), transparent 18%);
  background-repeat: no-repeat;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
.hidden { display: none !important; }

.app-shell {
  width: min(980px, calc(100% - 20px));
  margin: 16px auto 34px;
}
.app-shell--narrow { max-width: 920px; }

.page-header {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.page-heading {
  display: grid;
  gap: 4px;
  min-height: 72px;
  align-content: start;
}
.page-kicker {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}
.page-title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
}
.page-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  max-width: 640px;
}

.page-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.page-nav__link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height-small);
  padding: 0 11px;
  border-radius: 999px;
  border: var(--control-border-width) solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}
.page-nav__link.is-active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.page-stack {
  display: grid;
  gap: 10px;
}
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.surface--compact { padding: 12px; }
.surface--form { padding: 14px; }
.surface--nested {
  background: var(--surface-muted);
  border-radius: 14px;
  padding: 12px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.section-header--compact { margin-bottom: 6px; }
.section-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}
.section-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.stats-grid {
  display: grid;
  gap: 10px;
}
.stats-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat-tile {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.stat-tile span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}
.stat-tile strong {
  font-size: 24px;
  line-height: 1;
}

.shortcut-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.shortcut-card {
  display: block;
  text-decoration: none;
}
.shortcut-card:hover { border-color: #bdb39e; }

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

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--control-height-small);
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  font-size: 13px;
}
.toggle-chip input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.field-group {
  display: grid;
  gap: 6px;
  font-size: 14px;
}
.form-stack {
  display: grid;
  gap: 10px;
}
.form-stack--tight { gap: 8px; }
.two-up {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--control-padding-x);
  border-radius: var(--control-radius);
  border: var(--control-border-width) solid var(--border);
  background: white;
  color: var(--text);
  font-size: var(--control-font-size);
  line-height: 1.2;
}
textarea.field {
  min-height: 110px;
  padding: 10px var(--control-padding-x);
}
.field--textarea {
  min-height: 110px;
  resize: vertical;
}
.field--compact-textarea {
  min-height: 92px;
}
.field:focus {
  outline: 2px solid var(--accent-soft);
  border-color: #b5ab97;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: var(--control-height);
  padding: 0 var(--control-padding-x);
  border: var(--control-border-width) solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: var(--control-radius);
  cursor: pointer;
  font-size: var(--control-font-size);
  line-height: 1;
  white-space: nowrap;
}
.button--small {
  min-height: var(--control-height-small);
  font-size: 13px;
  padding: 0 10px;
}
.button--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.button--danger {
  color: var(--danger);
}
.button:hover { opacity: 0.95; }

.recent-list,
.list-stack {
  display: grid;
  gap: 8px;
}
.list-stack--rows { gap: 6px; }

.recent-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 4px;
  border-top: 1px solid var(--border);
}
.recent-row:first-child {
  border-top: 0;
  padding-top: 2px;
}
.recent-row__status {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}
.recent-row__main {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.recent-row__title {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}
.recent-row__title:hover { color: #45403a; }
.recent-row__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.library-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.library-row:hover {
  border-color: #cfc6b3;
  box-shadow: 0 8px 18px rgba(31, 29, 23, 0.05);
}
.library-row:has(.pin-toggle.is-pinned) {
  border-color: #cfe5d7;
  background: #f3faf5;
}
.library-row__status {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding-top: 4px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #b8b0a2;
}
.status-dot--saved { background: #b8b0a2; }
.status-dot--unread { background: #c89200; }
.status-dot--useful { background: #1c8b51; }
.status-dot--archived { background: #776f95; }

.pin-toggle {
  border: 0;
  background: transparent;
  color: #9b917f;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 13px;
  font-weight: 700;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 140ms ease, transform 140ms ease;
}
.pin-toggle:hover {
  color: #5d564b;
  transform: scale(1.08);
}
.pin-toggle:focus-visible {
  outline: 2px solid #d8ceb8;
  outline-offset: 2px;
  border-radius: 4px;
}
.pin-toggle.is-pinned { color: #1f8f5f; }
.pin-toggle.is-pinned:hover { color: #18754d; }

.library-row__main {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.library-row__title-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.library-row__title {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
}
.library-row__title:hover { color: #45403a; }
.library-row__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}
.library-row__url {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  max-height: 0;
  transition: opacity 140ms ease, max-height 140ms ease;
}
.library-row:hover .library-row__url,
.library-row:focus-within .library-row__url {
  opacity: 1;
  max-height: 20px;
}
.library-row__tags { margin-top: 1px; }
.library-row__notes {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.library-row__actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  flex-shrink: 0;
}
.library-row__actions .button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.tag {
  background: var(--accent-soft);
  border-color: transparent;
  color: #4b463f;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}
.form-message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.success { color: var(--success); }
.error { color: var(--danger); }

.date-group {
  display: grid;
  gap: 6px;
}
.date-group__header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 2px 0;
}
.date-group--pinned .date-group__header { color: #18794e; }
.date-group__header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 12px, 980px);
    margin-top: 10px;
  }
  .page-header,
  .section-header {
    align-items: stretch;
  }
  .page-title {
    font-size: 30px;
  }
  .page-heading {
    min-height: 0;
  }
  .stats-grid--3,
  .shortcut-grid,
  .two-up,
  .toolbar-row,
  .toolbar-row--tight {
    grid-template-columns: 1fr;
    display: grid;
  }
  .page-nav {
    gap: 6px;
  }
  .page-nav__link {
    min-height: var(--control-height-small);
    padding: 0 11px;
  }
  .library-row {
    grid-template-columns: 12px minmax(0, 1fr);
  }
  .library-row__url {
    opacity: 1;
    max-height: 20px;
  }
  .library-row__title-line {
    flex-direction: column;
    align-items: stretch;
  }
  .library-row__actions {
    justify-content: flex-start;
    margin-top: 2px;
  }
  .library-row__title,
  .recent-row__title {
    -webkit-line-clamp: 3;
  }
}
