/* ══════════════════════════════════════════════════
   Focused Kepler - Design System
   Monochrome editorial index · Geist typeface & Chillax
   ══════════════════════════════════════════════════ */

@font-face {
  font-family: 'Chillax-Semibold';
  src: url('fonts/Chillax-Semibold.woff2') format('woff2'),
       url('fonts/Chillax-Semibold.woff') format('woff'),
       url('fonts/Chillax-Semibold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
  font-style: normal;
}

/* ── Reset & Base ──────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f8f8f7;
  --bg-card: #ffffff;
  --bg-hover: #f2f2f0;
  --bg-input: #ffffff;
  --bg-modal: #ffffff;
  --bg-overlay: rgba(0,0,0,0.3);
  --border: #e8e8e6;
  --border-focus: #bbb;
  --text: #1a1a1a;
  --text-secondary: #717171;
  --text-tertiary: #a3a3a3;
  --text-vpn: #92400e;
  --bg-vpn: #fef3c7;
  --star-active: #1a1a1a;
  --star-inactive: #d4d4d4;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --btn-primary-hover: #333333;
  --radius: 6px;
  --font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

:root[data-theme="dark"] {
  --bg: #111111;
  --bg-card: #181818;
  --bg-hover: #222222;
  --bg-input: #1f1f1f;
  --bg-modal: #1c1c1c;
  --bg-overlay: rgba(0,0,0,0.65);
  --border: #2c2c2c;
  --border-focus: #666666;
  --text: #f3f3f3;
  --text-secondary: #9e9e9e;
  --text-tertiary: #666666;
  --text-vpn: #fcd34d;
  --bg-vpn: #451a03;
  --star-active: #f3f3f3;
  --star-inactive: #444444;
  --danger: #ef4444;
  --danger-bg: #450a0a;
  --btn-primary-hover: #dddddd;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  font-weight: 400;
  letter-spacing: 0;
  transition: background 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

/* ── Animations ────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes settingsSlideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Reduced Motion ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
}

/* ── Layout ────────────────────────────────────── */
.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 32px 80px;
}

/* ── Header ────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

.header-title {
  font-family: 'Chillax-Semibold', 'Geist', sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

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

.btn-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-icon:active {
  background: var(--bg-hover);
}

.btn-icon.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-text {
  height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-text:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-text:active {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-text.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ── Breadcrumbs ───────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  font-size: 0.82rem;
  color: var(--text-tertiary);
  flex-wrap: wrap;
}

.breadcrumb-item {
  color: var(--text-tertiary);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 0.82rem;
  padding: 4px 2px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease;
}

.breadcrumb-item:active {
  color: var(--text);
}

.breadcrumb-sep {
  color: var(--text-tertiary);
  user-select: none;
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 500;
}

/* ── Search Bar ─────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 0 12px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color 0.15s ease;
}

.search-bar:focus-within {
  border-color: var(--border-focus);
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.87rem;
  color: var(--text);
  height: 100%;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

/* ── List (Editorial Index - no outer border) ──── */
#list {
  display: flex;
  flex-direction: column;
}

/* ── Empty State ───────────────────────────────── */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 20px;
  color: var(--text-tertiary);
  font-size: 0.87rem;
  line-height: 1.6;
}

.empty-state p {
  margin-bottom: 16px;
}

.btn-empty-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-empty-add:hover {
  background: var(--bg-hover);
}

.btn-empty-add:active {
  background: var(--bg-hover);
}

.empty-search {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  font-size: 0.87rem;
}

/* ── Base Item Animations & Drag ───────────────── */
.item {
  animation: fadeInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  animation-delay: var(--delay, 0ms);
}

.item.dragging {
  opacity: 0.4;
}

.item.drag-over {
  box-shadow: inset 0 -2px 0 var(--text);
}

/* ── Folder Row ────────────────────────────────── */
.folder-row {
  display: flex;
  align-items: stretch;
  background: transparent;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease, transform 0.2s ease;
}

.folder-row:last-child {
  border-bottom: 1px solid var(--border);
}

.folder-row:active {
  background: var(--bg-hover);
}

/* ── Rich Link Card (WhatsApp Style Preview) ───── */
.link-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  padding: 14px 16px;
  gap: 12px;
  transition: border-color 0.15s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.link-card:active {
  border-color: var(--border-focus);
}

/* Card Header */
.link-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.link-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-card-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Index number */
.item-index {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-width: 28px;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Edit mode drag handle */
.item-drag {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  cursor: grab;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.item-drag:active {
  cursor: grabbing;
}

.edit-mode .item-drag {
  display: flex;
}

.item-drag svg {
  width: 14px;
  height: 14px;
}

/* Star */
.item-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--star-inactive);
  transition: color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.item-star:active {
  color: var(--text-secondary);
}

.item-star.starred {
  color: var(--star-active);
}

.item-star svg {
  width: 15px;
  height: 15px;
}

/* VPN tag */
.vpn-tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-vpn);
  background: var(--bg-vpn);
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

/* Card Body (Preview Area) */
.link-card-body {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  cursor: pointer;
  padding: 4px 0;
}

.folder-row .item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

/* OG Image thumbnail inside Card */
.link-preview-wrapper {
  width: 140px;
  height: 88px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.3s ease;
}

/* Text info */
.link-info-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folder-row .item-info {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.38;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.folder-row .item-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.folder-row .item-desc {
  font-size: 0.8rem;
  white-space: nowrap;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Card Footer (URL Box + Open Button) */
.link-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

/* URL + Copy box */
.item-url-box {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
  min-width: 0;
  max-width: 360px;
  height: 32px;
  background: var(--bg);
}

.item-url {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 30px;
  flex: 1;
  min-width: 0;
}

.item-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  border-left: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.item-copy:active {
  background: var(--bg-hover);
  color: var(--text);
}

.item-copy svg {
  width: 14px;
  height: 14px;
}

/* Open external button */
.item-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.item-open:active {
  background: var(--bg-hover);
  color: var(--text);
}

.item-open svg {
  width: 15px;
  height: 15px;
}

/* Folder icon */
.folder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.folder-icon svg {
  width: 22px;
  height: 22px;
}

.folder-count {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

/* Folder chevron */
.folder-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  align-self: stretch;
}

.folder-chevron svg {
  width: 15px;
  height: 15px;
}

/* ── Edit Mode ─────────────────────────────────── */
.edit-mode .item {
  border-left: 2px solid var(--border);
  padding-left: 0;
}

.item-delete {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  color: var(--danger);
  cursor: pointer;
  flex-shrink: 0;
  align-self: stretch;
  transition: background 0.15s ease;
}

.item-delete:active {
  background: var(--danger-bg);
}

.item-delete svg {
  width: 15px;
  height: 15px;
}

.edit-mode .item-delete {
  display: flex;
}

.edit-mode .item-url-box {
  display: none;
}

.item-vpn-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  align-self: stretch;
  font-size: 0.6rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.item-vpn-toggle:active {
  background: var(--bg-vpn);
  color: var(--text-vpn);
}

.item-vpn-toggle.vpn-on {
  background: var(--bg-vpn);
  color: var(--text-vpn);
}

.edit-mode .item-vpn-toggle {
  display: flex;
}

.edit-mode .link-row .item-open {
  display: none;
}

/* ── Hover Enhancements (desktop only) ─────────── */
@media (hover: hover) {
  .btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border);
  }

  .btn-text:hover {
    background: var(--bg-hover);
    color: var(--text);
  }

  .breadcrumb-item:hover {
    color: var(--text);
  }

  .folder-row:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
  }

  .link-card:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--bg-overlay);
  }

  .link-card-body:hover .link-preview-img {
    transform: scale(1.04);
  }

  .item-star:hover {
    color: var(--text-secondary);
  }

  .item-copy:hover {
    background: var(--bg-hover);
    color: var(--text);
  }

  .item-open:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border-focus);
  }

  .item-delete:hover {
    background: var(--danger-bg);
  }

  .item-vpn-toggle:hover {
    background: var(--bg-vpn);
    color: var(--text-vpn);
  }

  .btn-empty-add:hover {
    background: var(--bg-hover);
    border-color: var(--border-focus);
  }

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

  .modal-btn-secondary:hover {
    background: var(--bg-hover);
  }

  .settings-btn:hover {
    background: var(--bg-hover);
  }
}

/* ── Modal / Overlay ───────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-modal);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 680px;
  padding: 24px 20px;
  transform: translateY(40px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0);
  opacity: 1;
}

.modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.modal-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  font-size: 0.87rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.modal-input:focus {
  border-color: var(--border-focus);
}

.modal-input + .modal-input {
  margin-top: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

.modal-btn {
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 44px;
  cursor: pointer;
  outline: none;
}

.modal-btn-primary {
  background: var(--text);
  color: var(--bg);
  border: 1px solid transparent;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

.modal-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  opacity: 0.95;
}

.modal-btn-primary:active {
  transform: translateY(0);
  background: var(--btn-primary-hover);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  opacity: 1;
}

.modal-btn-primary:disabled {
  background: var(--text-tertiary);
  border-color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.modal-btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.modal-btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-focus);
}

.modal-btn-secondary:active {
  background: var(--bg-hover);
}

/* Loading spinner */
.modal-loading {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

.modal-loading.visible {
  display: flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Settings Panel ────────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.settings-overlay.open {
  opacity: 1;
  visibility: visible;
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(315px, 86vw);
  background: var(--bg-card);
  z-index: 201;
  padding: 22px 18px;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  overflow-y: auto;
}

.settings-overlay.open + .settings-panel,
.settings-panel.open {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.settings-title {
  font-family: 'Geist', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.settings-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin-bottom: 8px;
}

.settings-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.settings-btn:active {
  background: var(--bg-hover);
}

.settings-btn svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.settings-danger {
  color: var(--danger);
}

.settings-danger svg {
  color: var(--danger);
}

.settings-footer {
  font-family: 'Chillax-Semibold', 'Geist', sans-serif;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

/* Hidden file input */
.hidden-input {
  display: none;
}

/* ── Toast ─────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
  animation: toastSlideUp 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Undo Button in Toast ─────────────────────── */
.toast-undo {
  background: none;
  border: none;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 4px 2px;
  min-height: 44px;
  display: none;
  align-items: center;
  margin-left: 4px;
  font-family: inherit;
}

.toast-undo:active {
  opacity: 0.7;
}

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

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

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

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Full-Screen Auth Page (#auth-page) ───────── */
.auth-page {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.auth-page-logo {
  text-align: center;
}

.auth-page-brand {
  font-family: 'Chillax-Semibold', 'Geist', sans-serif;
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  color: var(--text);
  line-height: 1.15;
  display: inline-block;
}

.auth-page-tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

.auth-page-card {
  max-width: 440px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 16px 48px var(--shadow-color);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-hover);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 2px 8px var(--shadow-color);
}

.auth-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-panel.active {
  display: flex;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 4px;
}

.auth-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.password-gen-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}

.password-gen-input {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  border: none !important;
  background: transparent !important;
  flex: 1;
  padding: 10px !important;
  margin: 0 !important;
}

.password-gen-box .btn-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.password-gen-box .btn-icon:hover {
  background: var(--bg-card);
  box-shadow: 0 2px 6px var(--shadow-color);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 8px 0;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
  margin: 0 10px;
}

.auth-error {
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 500;
  display: none;
  min-height: 0;
}

.auth-error:not(:empty) {
  display: block;
}

.auth-panel .modal-btn-primary {
  margin-top: 4px;
}

.auth-restore-btn {
  width: 100%;
  justify-content: center;
}

/* ── Shared Banner & Read-Only Mode ───────────── */
.shared-banner {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: none;
  position: relative;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 18px;
  font-size: 0.85rem;
  gap: 10px;
  box-shadow: 0 4px 16px var(--shadow-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.shared-banner-text {
  padding-right: 36px;
  word-break: break-all;
  line-height: 1.5;
}

.shared-banner-text strong {
  font-weight: 700;
  word-break: break-all;
}

.btn-create-own {
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: var(--radius);
  height: 38px;
  padding: 0 16px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
  width: 100%;
}

.btn-create-own:hover {
  opacity: 0.88;
}

.btn-close-banner {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease;
  position: absolute;
  top: 10px;
  right: 10px;
}

.btn-close-banner:hover {
  background: var(--bg-hover);
  color: var(--text);
}

body.is-shared-view #btn-add-link,
body.is-shared-view #btn-add-folder,
body.is-shared-view #btn-edit,
body.is-shared-view #btn-settings,
body.is-shared-view .item-delete,
body.is-shared-view .item-drag,
body.is-shared-view .item-vpn-toggle,
body.is-shared-view .item-star:not(.starred),
body.is-locked-mode #btn-add-link,
body.is-locked-mode #btn-add-folder,
body.is-locked-mode #btn-edit,
body.is-locked-mode #btn-settings,
body.is-locked-mode #btn-view-mode,
body.is-locked-mode .item-delete,
body.is-locked-mode .item-drag,
body.is-locked-mode .item-vpn-toggle,
body.is-locked-mode .item-star:not(.starred) {
  display: none !important;
}

body.is-shared-view .item-star.starred,
body.is-locked-mode .item-star.starred {
  pointer-events: none !important;
  opacity: 0.85 !important;
  cursor: default !important;
}

/* ── Lock Mode (Reading Mode) ──────────────────── */
body.is-locked-mode #btn-lock-mode {
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  background: var(--text) !important;
  color: var(--bg) !important;
  border: 1px solid var(--text) !important;
  border-radius: var(--radius) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.15s ease, background 0.15s ease;
}

body.is-locked-mode #btn-lock-mode:hover {
  opacity: 0.85;
  background: var(--text) !important;
  color: var(--bg) !important;
}

body.is-locked-mode #btn-lock-mode svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0;
}

body.is-locked-mode #btn-lock-mode .icon-lock-closed {
  display: none !important;
}
body.is-locked-mode #btn-lock-mode .icon-lock-open {
  display: inline-block !important;
}

/* ── List View Modes ──────────────────── */
/* Mode 2: Compact (Heading + Link, hide image preview) */
body.view-mode-compact .link-preview-wrapper {
  display: none !important;
}

/* Mode 3: Minimal (Only Link URL visible on link cards) */
body.view-mode-link-only .link-preview-wrapper,
body.view-mode-link-only .link-info-wrapper {
  display: none !important;
}
body.view-mode-link-only .link-card-body {
  padding: 0 !important;
  min-height: 0 !important;
}
body.view-mode-link-only .link-card-footer {
  padding-top: 4px;
}

/* Mode 4: Masked (No thumbnail, no heading, only link which is also hidden/blurred like a password until hover) */
body.view-mode-masked .link-preview-wrapper,
body.view-mode-masked .link-info-wrapper {
  display: none !important;
}
body.view-mode-masked .link-card-body {
  padding: 0 !important;
  min-height: 0 !important;
}
body.view-mode-masked .link-card-footer {
  padding-top: 4px;
}
body.view-mode-masked .item-url {
  filter: blur(5px);
  user-select: none;
  cursor: pointer;
  transition: filter 0.2s ease, opacity 0.2s ease, background 0.2s ease;
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}
body.view-mode-masked .item-url:hover,
body.view-mode-masked .item-url-box:hover .item-url {
  filter: blur(0px);
  user-select: auto;
  background: transparent;
}

/* ── Desktop Modal (centered) ──────────────────── */
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }

  .modal {
    max-width: 480px;
    border-radius: var(--radius);
    padding: 28px 24px;
  }
}

/* ── Responsive - Mobile ───────────────────────── */
@media (max-width: 480px) {
  .app {
    padding: 16px 16px 100px;
  }

  .link-card-body {
    flex-direction: column;
    gap: 12px;
  }

  .link-preview-wrapper {
    width: 100%;
    height: auto;
    max-height: 280px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .link-preview-img {
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: contain;
  }

  .item-star {
    width: 28px;
    height: 28px;
  }

  .item-index {
    width: 24px;
    min-width: 24px;
    font-size: 0.72rem;
  }

  .header-title {
    font-size: 1.15rem;
  }
}
