:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe5f2;
  --primary: #0d6efd;
  --primary-dark: #054cb5;
  --danger: #dc2626;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(13, 110, 253, 0.13), transparent 34%),
    linear-gradient(135deg, #eef5ff 0%, #f8fafc 44%, #eef2ff 100%);
}

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

button,
input,
textarea {
  font: inherit;
}

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  overflow-x: hidden;
}

.auth-shell {
  width: min(100%, 460px);
}

.auth-card,
.editor-card,
.empty-state,
.note-card,
.sidebar {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(219, 229, 242, 0.92);
  box-shadow: var(--shadow);
}

.auth-card {
  border-radius: 32px;
  padding: 34px;
  text-align: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 14px 32px rgba(13, 110, 253, 0.32);
}

.small-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 14px;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin-top: 0;
}

.auth-card h1 {
  margin: 18px 0 8px;
  font-size: clamp(30px, 7vw, 42px);
  letter-spacing: -0.05em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
  text-align: left;
}

label span {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  color: var(--text);
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input {
  min-height: 50px;
  padding: 0 16px;
}

textarea {
  resize: vertical;
  padding: 16px;
}

input:focus,
textarea:focus {
  border-color: rgba(13, 110, 253, 0.65);
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12);
}

.btn {
  min-height: 46px;
  border: 0;
  border-radius: 15px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

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

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 14px 30px rgba(13, 110, 253, 0.28);
}

.btn-secondary {
  color: var(--primary-dark);
  background: #eaf2ff;
}

.btn-ghost {
  color: var(--text);
  background: #f1f5f9;
}

.btn-danger {
  color: #fff;
  background: var(--danger);
}

.full {
  width: 100%;
}

.auth-footer {
  margin: 22px 0 0;
}

.auth-footer a {
  color: var(--primary-dark);
  font-weight: 800;
}

.alert {
  border-radius: 16px;
  padding: 14px 16px;
  margin: 20px 0 0;
  text-align: left;
  font-weight: 700;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.app-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
  gap: 24px;
  padding: 24px;
}

.sidebar {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-head strong,
.sidebar-head span {
  display: block;
}

.sidebar-head span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-radius: 15px;
  color: var(--muted);
  font-weight: 800;
}

.side-nav a.active,
.side-nav a:hover {
  background: #edf5ff;
  color: var(--primary-dark);
}

.side-nav b {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}

.logout-form {
  margin-top: auto;
}

.content {
  min-width: 0;
}

.topbar,
.editor-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: -0.05em;
}

.topbar p {
  margin-bottom: 0;
}

.searchbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.searchbar input {
  flex: 1;
  background: rgba(255, 255, 255, 0.92);
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.note-card {
  border-radius: 22px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
}

.note-card:hover {
  transform: translateY(-2px);
}

.note-card.pinned {
  border-color: rgba(13, 110, 253, 0.42);
}

.note-link {
  display: block;
  padding: 20px 20px 14px;
}

.note-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.note-card h2 {
  font-size: 20px;
  line-height: 1.15;
  margin-bottom: 12px;
  letter-spacing: -0.025em;
}

.note-card p {
  color: var(--muted);
  line-height: 1.55;
  min-height: 52px;
}

.note-card time {
  display: block;
  color: #94a3b8;
  font-size: 12px;
  margin-top: 14px;
}

.pin {
  flex: 0 0 auto;
  color: var(--primary-dark);
  background: #eaf2ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  padding: 5px 9px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.tags span {
  background: #f1f5f9;
  color: #475569;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.card-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  border-top: 1px solid rgba(219, 229, 242, 0.65);
  padding-top: 12px;
}

.mini-btn {
  min-height: 34px;
  border: 0;
  border-radius: 11px;
  padding: 0 12px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 800;
  cursor: pointer;
}

.empty-state {
  border-radius: var(--radius);
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 40px;
}

.empty-icon {
  font-size: 54px;
  margin-bottom: 10px;
}

.empty-state h2 {
  font-size: 30px;
  margin-bottom: 10px;
}

.editor-shell {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 24px;
}

.editor-card {
  border-radius: 28px;
  padding: clamp(18px, 4vw, 34px);
}

.editor-actions {
  display: flex;
  gap: 10px;
}

.note-form {
  display: grid;
  gap: 18px;
}

.title-input {
  border: 0;
  background: transparent;
  border-radius: 0;
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 900;
  letter-spacing: -0.06em;
  min-height: auto;
  padding: 0;
}

.title-input:focus {
  box-shadow: none;
}

.body-input {
  min-height: 48vh;
  border-radius: 22px;
  line-height: 1.65;
  font-size: 17px;
  background: var(--panel-soft);
}

.editor-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.checkbox-label input {
  width: 18px;
  min-height: auto;
  height: 18px;
}

.checkbox-label span {
  margin: 0;
  white-space: nowrap;
}

.save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.note-finder {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fbff;
}

.finder-field {
  position: relative;
}

.finder-input {
  width: 100%;
  min-height: 50px;
  padding: 0 78px 0 16px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.finder-input:focus {
  border-color: rgba(13, 110, 253, 0.55);
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.10);
}

.finder-count {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  min-width: 50px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.finder-count.has-results {
  color: var(--primary-dark);
  background: #dceaff;
}

.finder-count.no-results {
  color: #b42318;
  background: #fee4e2;
}

.finder-btn {
  min-height: 50px;
  padding-inline: 16px;
  white-space: nowrap;
}

.mobile-fab {
  display: none;
}

@media (max-width: 850px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .sidebar {
    position: static;
    height: auto;
    border-radius: 22px;
  }

  .logout-form {
    margin-top: 0;
  }

  .desktop-only {
    display: none;
  }

  .topbar {
    align-items: flex-start;
  }

  .searchbar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .searchbar .btn-ghost {
    grid-column: 1 / -1;
  }

  .mobile-fab {
    display: grid;
    place-items: center;
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 58px;
    height: 58px;
    border-radius: 20px;
    color: #fff;
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 18px 34px rgba(13, 110, 253, 0.35);
  }

  .editor-meta,
  .note-finder {
    grid-template-columns: 1fr;
  }

  .finder-btn {
    width: 100%;
  }

  .checkbox-label {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .auth-card {
    padding: 24px;
    border-radius: 26px;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .editor-topbar,
  .save-row {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-shell {
    padding: 14px;
  }

  .editor-actions,
  .editor-actions form,
  .editor-actions button,
  .save-row .btn {
    width: 100%;
  }
}

.finder-btn.is-disabled,
.finder-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Menú hamburguesa izquierdo para el dashboard */
.dashboard-layout {
  display: block;
  width: min(100%, 1180px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px;
}

.dashboard-content {
  width: 100%;
  min-width: 0;
}

.dashboard-menu-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(219, 229, 242, 0.95);
  border-radius: 28px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  position: relative;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  z-index: 50;
}

.dashboard-menu-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.dashboard-menu-logo {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  font-size: 22px;
  flex: 0 0 auto;
}

.dashboard-menu-title {
  min-width: 0;
}

.dashboard-menu-title strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.dashboard-menu-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hamburger-button {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 16px 34px rgba(13, 110, 253, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  row-gap: 5px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex: 0 0 auto;
}

.hamburger-button:hover {
  transform: translateY(-1px);
}

.hamburger-button span {
  display: block;
  width: 23px;
  height: 3px;
  border-radius: 999px;
  background: #ffffff;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger-button.is-open span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger-button.is-open span:nth-child(2) {
  opacity: 0;
}

.hamburger-button.is-open span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.dashboard-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  left: 20px;
  right: auto;
  width: min(380px, calc(100vw - 88px));
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.2);
  display: none;
  z-index: 3000;
  transform-origin: top left;
  animation: menuGrowLeft 0.18s ease-out;
}

.dashboard-dropdown.open {
  display: block;
}

@keyframes menuGrowLeft {
  from {
    opacity: 0;
    transform: scaleX(0.82) translateY(-6px);
  }

  to {
    opacity: 1;
    transform: scaleX(1) translateY(0);
  }
}

.dashboard-dropdown-item {
  width: 100%;
  border: 0;
  text-decoration: none;
  color: var(--text);
  background: #f1f5f9;
  border-radius: 16px;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  font-size: 17px;
  font-weight: 850;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  text-align: left;
}

.dashboard-dropdown-item:last-child {
  margin-bottom: 0;
}

.dashboard-dropdown-item:hover {
  background: #eaf2ff;
  transform: translateY(-1px);
}

.dashboard-dropdown-item.active {
  background: #eaf2ff;
  color: var(--primary-dark);
}

.dashboard-dropdown-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 12px 26px rgba(13, 110, 253, 0.24);
}

.dashboard-dropdown-primary:hover {
  background: linear-gradient(135deg, #0b63e5, #0445a7);
}

.dashboard-dropdown-item b {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.dashboard-dropdown-form {
  margin: 0;
}

.dashboard-dropdown-button {
  color: var(--text);
  background: #eef2f8;
}

.dashboard-header {
  margin-bottom: 18px;
}

@media (max-width: 850px) {
  .dashboard-layout {
    padding: 14px;
  }

  .dashboard-menu-card {
    border-radius: 24px;
    padding: 16px;
    margin-bottom: 26px;
  }

  .dashboard-menu-logo {
    width: 54px;
    height: 54px;
    border-radius: 17px;
    font-size: 21px;
  }

  .dashboard-menu-title strong {
    font-size: 21px;
  }

  .dashboard-menu-title span {
    font-size: 14px;
    max-width: 190px;
  }

  .hamburger-button {
    width: 50px;
    height: 50px;
    border-radius: 16px;
  }

  .dashboard-dropdown {
    left: 16px;
    width: min(360px, calc(100vw - 60px));
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 520px) {
  .dashboard-layout {
    padding: 14px;
  }

  .dashboard-menu-card {
    padding: 14px;
    gap: 10px;
  }

  .dashboard-menu-left {
    gap: 10px;
  }

  .dashboard-menu-logo {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    font-size: 18px;
  }

  .hamburger-button {
    width: 46px;
    height: 46px;
    border-radius: 15px;
  }

  .hamburger-button span {
    width: 21px;
    height: 3px;
  }

  .dashboard-menu-title strong {
    font-size: 19px;
  }

  .dashboard-menu-title span {
    max-width: 150px;
  }

  .dashboard-dropdown {
    left: 14px;
    right: 14px;
    width: calc(100% - 28px);
    border-radius: 22px;
    max-height: calc(100vh - 145px);
  }

  .dashboard-dropdown-item {
    font-size: 16px;
    padding: 14px 15px;
  }

  .searchbar {
    grid-template-columns: 1fr auto;
  }
}

/* Mejoras del editor móvil: guardar primero, eliminar secundario y buscador compacto */
.editor-shell-v2 {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 20px;
}

.editor-topbar-v2 {
  position: sticky;
  top: 12px;
  z-index: 1200;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 0;
}

.editor-back-btn,
.editor-save-top {
  min-height: 52px;
  border-radius: 18px;
  padding-inline: 22px;
}

.editor-back-btn {
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(219, 229, 242, 0.9);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.editor-save-top {
  min-width: 160px;
}

.editor-card-v2 {
  padding: clamp(18px, 3vw, 30px);
}

.note-form-v2 {
  gap: 16px;
}

.title-input-v2 {
  margin-top: 4px;
  font-size: clamp(30px, 6vw, 46px);
}

.note-finder-v2 {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 18px;
  background: rgba(248, 251, 255, 0.92);
}

.finder-field-v2 {
  min-width: 0;
}

.finder-input-v2 {
  min-height: 48px;
  padding-right: 74px;
}

.finder-count-v2 {
  min-width: 48px;
}

.finder-actions-v2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.finder-icon-btn,
.finder-clear-btn {
  min-height: 48px;
  border-radius: 14px;
  white-space: nowrap;
}

.finder-icon-btn {
  min-width: 48px;
  padding-inline: 14px;
}

.finder-next-btn {
  min-width: 124px;
}

.finder-clear-btn {
  min-width: 82px;
  padding-inline: 14px;
}

.body-input-v2 {
  min-height: 56vh;
  font-size: 17px;
}

.save-row-v2 {
  padding-top: 2px;
}

.danger-zone-note {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid #fecaca;
  background: #fff7f7;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.danger-zone-note strong {
  display: block;
  color: #991b1b;
  font-size: 15px;
  margin-bottom: 4px;
}

.danger-zone-note p {
  margin: 0;
  color: #7f1d1d;
  font-size: 13px;
  line-height: 1.35;
}

.btn-danger-soft {
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fecaca;
  box-shadow: none;
}

.btn-danger-soft:hover {
  background: #fecaca;
}

@media (max-width: 850px) {
  .editor-shell-v2 {
    padding: 14px;
  }

  .editor-topbar-v2 {
    top: 10px;
    grid-template-columns: 1fr 1fr;
  }

  .editor-back-btn,
  .editor-save-top {
    width: 100%;
    justify-content: center;
    min-height: 52px;
    font-size: 16px;
  }

  .editor-save-top {
    min-width: 0;
  }

  .editor-card-v2 {
    border-radius: 24px;
  }

  .title-input-v2 {
    font-size: clamp(28px, 9vw, 38px);
    line-height: 1.05;
  }

  .note-finder-v2 {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .finder-actions-v2 {
    display: grid;
    grid-template-columns: 52px 1fr 82px;
    gap: 8px;
  }

  .finder-icon-btn,
  .finder-clear-btn {
    width: 100%;
    min-height: 46px;
    padding-inline: 10px;
    font-size: 15px;
  }

  .finder-next-btn {
    min-width: 0;
  }

  .body-input-v2 {
    min-height: 58vh;
    font-size: 16px;
    line-height: 1.58;
  }

  .editor-meta-v2 {
    grid-template-columns: 1fr;
  }

  .save-row-v2 {
    align-items: stretch;
    flex-direction: column;
  }

  .save-row-v2 .btn {
    width: 100%;
    min-height: 54px;
  }

  .save-row-v2 .small {
    text-align: center;
  }

  .danger-zone-note {
    align-items: stretch;
    flex-direction: column;
  }

  .danger-zone-note form,
  .danger-zone-note button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .topbar.editor-topbar,
  .editor-topbar-v2,
  .save-row-v2 {
    flex-direction: initial;
    align-items: center;
  }

  .editor-topbar-v2 {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .editor-back-btn,
  .editor-save-top {
    min-height: 48px;
    border-radius: 16px;
    padding-inline: 12px;
  }

  .editor-card-v2 {
    padding: 16px;
  }

  .note-finder-v2 {
    border-radius: 16px;
  }

  .finder-input-v2 {
    min-height: 46px;
    font-size: 15px;
    padding-left: 14px;
    padding-right: 68px;
  }

  .finder-count-v2 {
    right: 9px;
    min-width: 46px;
  }

  .finder-actions-v2 {
    grid-template-columns: 46px 1fr 72px;
  }

  .finder-icon-btn,
  .finder-clear-btn {
    min-height: 44px;
    border-radius: 13px;
    font-size: 14px;
  }

  .body-input-v2 {
    min-height: 62vh;
    border-radius: 18px;
  }

  .danger-zone-note {
    padding: 14px;
  }
}


/* Buscador fijo dentro del editor: no se pierde al navegar entre resultados */
.note-finder-v2 {
  position: sticky;
  top: 84px;
  z-index: 1100;
  border: 1px solid rgba(219, 229, 242, 0.96);
  background: rgba(248, 251, 255, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.note-finder-v2.finder-active,
.note-finder-v2:focus-within {
  border-color: rgba(13, 110, 253, 0.28);
  box-shadow: 0 18px 42px rgba(13, 110, 253, 0.14);
}

.body-input-v2 {
  scroll-margin-top: 180px;
}

@media (max-width: 850px) {
  .note-finder-v2 {
    top: 72px;
    margin-inline: -2px;
  }

  .finder-actions-v2 {
    grid-template-columns: 48px 1fr 78px;
  }

  .finder-next-btn {
    font-size: 0;
  }

  .finder-next-btn::after {
    content: 'Siguiente';
    font-size: 14px;
  }

  .finder-icon-btn:first-child {
    font-size: 0;
  }

  .finder-icon-btn:first-child::after {
    content: '↑';
    font-size: 20px;
    line-height: 1;
  }
}

@media (max-width: 520px) {
  .note-finder-v2 {
    top: 68px;
    padding: 8px;
    border-radius: 18px;
  }

  .finder-input-v2 {
    min-height: 42px;
  }

  .finder-actions-v2 {
    grid-template-columns: 44px 1fr 68px;
    gap: 6px;
  }

  .finder-icon-btn,
  .finder-clear-btn {
    min-height: 40px;
    border-radius: 12px;
  }
}

/* =========================================================
   Buscador minimalista dentro de la nota
   Estilo compacto tipo Safari/WhatsApp para celular
   ========================================================= */

body.note-page {
  padding-bottom: 118px;
}

.note-search-dock {
  position: sticky;
  top: 78px;
  z-index: 1250;
  margin: 12px 0 16px;
  transition: bottom 0.22s ease, transform 0.22s ease;
}

.note-search-bar {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(207, 224, 247, 0.95);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.10);
  backdrop-filter: blur(18px);
}

.note-search-input-wrap {
  min-width: 0;
  position: relative;
}

.note-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #7b8aa5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.note-search-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #d8e5f5;
  border-radius: 16px;
  padding: 0 14px 0 44px;
  background: #f8fbff;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.note-search-input:focus {
  border-color: rgba(13, 110, 253, 0.7);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.10);
}

.note-search-count {
  min-width: 62px;
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  background: #edf4ff;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

.note-search-count.has-results {
  color: var(--primary-dark);
  background: #e4f0ff;
}

.note-search-count.no-results {
  color: #b91c1c;
  background: #fee2e2;
}

.note-search-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.note-search-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: 0;
  border-radius: 14px;
  background: #eef3fa;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.note-search-btn:hover {
  transform: translateY(-1px);
  background: #e5edf8;
}

.note-search-btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 10px 24px rgba(13, 110, 253, 0.22);
}

.note-search-btn-primary:hover {
  background: linear-gradient(135deg, #0b63e5, #0445a7);
}

.note-search-btn.is-disabled,
.note-search-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#noteBody.body-input-v2 {
  scroll-margin-top: 140px;
  margin-bottom: 18px;
}

@media (max-width: 850px) {
  .note-search-dock {
    top: 68px;
  }
}

@media (max-width: 768px) {
  body.note-page {
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  .note-search-dock {
    position: fixed;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom) + var(--find-keyboard-offset, 0px));
    z-index: 3000;
    margin: 0;
  }

  .note-search-bar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    padding: 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.20);
  }

  .note-search-input {
    min-height: 44px;
    border-radius: 14px;
    padding-left: 40px;
    font-size: 16px;
  }

  .note-search-icon {
    left: 12px;
  }

  .note-search-count {
    min-width: 54px;
    height: 40px;
    padding: 0 10px;
    font-size: 14px;
  }

  .note-search-actions {
    gap: 5px;
  }

  .note-search-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 13px;
  }

  .note-search-btn svg {
    width: 20px;
    height: 20px;
  }

  #noteBody.body-input-v2 {
    min-height: 64vh;
    padding-bottom: 84px;
  }

  .editor-card-v2 {
    margin-bottom: 96px;
  }
}

@media (max-width: 390px) {
  .note-search-bar {
    gap: 5px;
    padding: 7px;
  }

  .note-search-count {
    min-width: 48px;
    font-size: 13px;
    padding: 0 8px;
  }

  .note-search-btn {
    width: 39px;
    height: 39px;
    min-width: 39px;
    border-radius: 12px;
  }

  .note-search-input {
    min-height: 42px;
    padding-right: 10px;
  }
}

/* ===== Corrección UX búsqueda v6: barra superior fija + vista con resaltado ===== */
body.note-page {
  padding-bottom: 24px !important;
}

body.note-page.note-search-mode {
  padding-bottom: 24px !important;
}

.note-page .editor-topbar-v2 {
  position: sticky;
  top: max(10px, env(safe-area-inset-top));
  z-index: 2400;
}

.note-page .note-search-dock {
  position: sticky !important;
  top: calc(max(10px, env(safe-area-inset-top)) + 64px) !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  z-index: 2300 !important;
  margin: 10px 0 14px !important;
  width: 100% !important;
}

.note-page .note-search-bar {
  width: 100%;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto auto !important;
  align-items: center;
  gap: 8px !important;
  padding: 8px !important;
  border-radius: 22px !important;
  background: rgba(255, 255, 255, 0.97) !important;
  border: 1px solid rgba(198, 216, 240, 0.96) !important;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.12) !important;
  backdrop-filter: blur(18px);
}

.note-page .note-search-input {
  min-height: 46px !important;
  border-radius: 16px !important;
  background: #f8fbff !important;
  font-size: 16px !important;
}

.note-page .note-search-count {
  height: 42px !important;
  min-width: 58px !important;
  border-radius: 999px !important;
}

.note-page .note-search-actions {
  display: inline-flex !important;
  align-items: center;
  gap: 6px !important;
}

.note-page .note-search-btn {
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  border-radius: 14px !important;
}

.note-search-preview {
  display: none;
  width: 100%;
  min-height: 58vh;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding: 18px;
  border: 1px solid #dbe5f2;
  border-radius: 20px;
  background: #f8fbff;
  color: var(--text);
  font-size: 17px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  scroll-behavior: smooth;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.72);
}

body.note-search-mode .note-search-preview {
  display: block;
}

body.note-search-mode #noteBody.body-input-v2 {
  display: none !important;
}

.note-search-hit {
  padding: 0 2px;
  border-radius: 6px;
  background: #fff1a8;
  color: inherit;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.18);
}

.note-search-hit.is-current {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.18);
}

.note-search-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 768px) {
  body.note-page,
  body.note-page.note-search-mode {
    padding-bottom: 18px !important;
  }

  .note-page .editor-shell-v2 {
    padding: 12px !important;
  }

  .note-page .editor-topbar-v2 {
    top: 8px !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
  }

  .note-page .editor-back-btn,
  .note-page .editor-save-top {
    min-height: 46px !important;
    border-radius: 16px !important;
    font-size: 15px !important;
  }

  .note-page .note-search-dock {
    top: calc(8px + 58px) !important;
    margin: 8px 0 12px !important;
  }

  .note-page .note-search-bar {
    grid-template-columns: minmax(0, 1fr) auto auto !important;
    gap: 6px !important;
    padding: 7px !important;
    border-radius: 19px !important;
  }

  .note-page .note-search-input-wrap {
    min-width: 0;
  }

  .note-page .note-search-input {
    min-height: 42px !important;
    padding-left: 40px !important;
    padding-right: 10px !important;
    font-size: 15px !important;
    border-radius: 14px !important;
  }

  .note-page .note-search-icon {
    left: 12px !important;
  }

  .note-page .note-search-count {
    min-width: 52px !important;
    height: 40px !important;
    padding: 0 9px !important;
    font-size: 14px !important;
  }

  .note-page .note-search-actions {
    gap: 5px !important;
  }

  .note-page .note-search-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    border-radius: 13px !important;
  }

  .note-page .note-search-btn svg {
    width: 19px !important;
    height: 19px !important;
  }

  .note-search-preview {
    min-height: 62vh;
    max-height: calc(100vh - 178px);
    padding: 14px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.58;
  }

  .note-page .editor-card-v2 {
    margin-bottom: 0 !important;
  }
}

@media (max-width: 390px) {
  .note-page .note-search-count {
    min-width: 48px !important;
    font-size: 13px !important;
  }

  .note-page .note-search-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
  }

  .note-page .note-search-input {
    font-size: 14px !important;
  }
}
