/* ==========================================================================
   Promptito · app.css
   Layout, componentes y hojas de interfaz.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Estructura de la app
   -------------------------------------------------------------------------- */
.app {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.screen--list {
  position: relative;
}

/* --------------------------------------------------------------------------
   Botones de icono
   -------------------------------------------------------------------------- */
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 0.12s var(--ease);
}

.icon-btn:hover {
  background: color-mix(in oklch, var(--text) 7%, transparent);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.9);
}

.icon-btn--sm {
  width: 34px;
  height: 34px;
}

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

.icon-btn--color {
  position: relative;
}

.icon-btn__dot {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 9px;
  height: 9px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--surface);
  background: var(--dot-color, transparent);
}

.appbar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   Cabecera de la lista
   -------------------------------------------------------------------------- */
.list-appbar {
  flex: none;
  padding: calc(var(--safe-t) + 12px) calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l));
  background: color-mix(in oklch, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid color-mix(in oklch, var(--line) 70%, transparent);
  z-index: 20;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand__mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 6px 18px color-mix(in oklch, var(--brand) 32%, transparent), var(--shadow-1);
  flex: none;
}

.brand__mark svg {
  width: 100%;
  height: 100%;
}

.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.brand__title {
  font-size: 1.3rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  background: linear-gradient(120deg, var(--text), color-mix(in oklch, var(--brand) 70%, var(--text)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand__sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.offline-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  margin-right: 4px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.offline-pill .i {
  width: 14px;
  height: 14px;
  color: var(--warning);
}

/* Buscador ---------------------------------------------------------------- */
.searchbar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 8px 0 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.searchbar:focus-within {
  border-color: color-mix(in oklch, var(--brand) 55%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--brand) 14%, transparent);
}

.searchbar__icon {
  width: 19px;
  height: 19px;
  color: var(--text-3);
  flex: none;
}

.searchbar input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}

.searchbar input::placeholder {
  color: var(--text-3);
}

.searchbar input::-webkit-search-cancel-button,
.searchbar input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.searchbar__clear {
  color: var(--text-3);
}

/* Filtros ----------------------------------------------------------------- */
.filters {
  margin-top: 12px;
  display: flex;
  align-items: center;
}

.chips {
  display: flex;
  gap: 7px;
}

.chip {
  padding: 7px 15px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 0.12s var(--ease);
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.chip:active {
  transform: scale(0.96);
}

.chip.is-active {
  background: var(--brand-soft);
  border-color: color-mix(in oklch, var(--brand) 30%, transparent);
  color: var(--brand);
}

:root[data-theme="dark"] .chip.is-active {
  color: var(--brand);
}

/* --------------------------------------------------------------------------
   Lista de notas
   -------------------------------------------------------------------------- */
.notes-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px calc(16px + var(--safe-r)) calc(108px + var(--safe-b)) calc(16px + var(--safe-l));
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 12px;
  align-content: start;
}

.note-card {
  --hue: 280;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 15px 15px 13px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.note-card[data-color="lilac"] {
  background: var(--note-lilac);
  border-color: var(--note-lilac-border);
}

.note-card[data-color="mint"] {
  background: var(--note-mint);
  border-color: var(--note-mint-border);
}

.note-card[data-color="sky"] {
  background: var(--note-sky);
  border-color: var(--note-sky-border);
}

.note-card[data-color="sand"] {
  background: var(--note-sand);
  border-color: var(--note-sand-border);
}

.note-card[data-color="peach"] {
  background: var(--note-peach);
  border-color: var(--note-peach-border);
}

.note-card[data-color="rose"] {
  background: var(--note-rose);
  border-color: var(--note-rose-border);
}

.note-card::before {
  content: "";
  position: absolute;
  inset: 14px auto 14px 7px;
  width: 3px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, oklch(72% 0.16 var(--hue)), oklch(76% 0.12 calc(var(--hue) + 45)));
  opacity: 0.9;
}

.note-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  border-color: var(--line-strong);
}

.note-card:active {
  transform: scale(0.985);
}

.note-card.is-active {
  border-color: color-mix(in oklch, var(--brand) 50%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 15%, transparent), var(--shadow-1);
}

.note-card.is-pinned::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 46px;
  height: 46px;
  background: radial-gradient(circle at top right, color-mix(in oklch, var(--brand) 18%, transparent), transparent 70%);
  pointer-events: none;
}

.note-card__head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.note-card__title {
  font-size: 0.98rem;
  font-weight: 680;
  line-height: 1.32;
  letter-spacing: -0.012em;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.note-card__pin {
  width: 30px;
  height: 30px;
  margin: -3px -4px 0 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-3);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 0.12s var(--ease);
  flex: none;
}

.note-card__pin .i {
  width: 17px;
  height: 17px;
}

.note-card:hover .note-card__pin,
.note-card.is-pinned .note-card__pin,
.note-card__pin:focus-visible {
  opacity: 1;
}

.note-card__pin:hover {
  background: color-mix(in oklch, var(--text) 8%, transparent);
  color: var(--text);
}

.note-card.is-pinned .note-card__pin {
  color: var(--brand);
}

.note-card.is-pinned .note-card__pin .i {
  fill: currentColor;
}

.note-card__pin:active {
  transform: scale(0.88);
}

.note-card__excerpt {
  font-size: 0.855rem;
  line-height: 1.5;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3.85em;
}

.note-card__excerpt--empty {
  color: var(--text-3);
  font-style: italic;
}

.note-card__foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
}

.note-card__dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.notes-grid:not(.notes-grid--static) .note-card {
  animation: card-in 0.45s var(--ease) backwards;
  animation-delay: calc(min(var(--i, 0), 12) * 26ms);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Estado vacío ------------------------------------------------------------ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
  padding: 56px 24px;
  animation: fade-in 0.4s var(--ease);
}

.empty__icon {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 26px;
  color: var(--brand);
  background: radial-gradient(circle at 30% 20%, color-mix(in oklch, var(--brand) 20%, transparent), var(--brand-soft));
  border: 1px solid color-mix(in oklch, var(--brand) 18%, transparent);
  box-shadow: var(--shadow-1);
  margin-bottom: 10px;
}

.empty__icon .i {
  width: 32px;
  height: 32px;
}

.empty__title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.empty__text {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-2);
  text-wrap: pretty;
}

.empty .btn {
  margin-top: 14px;
}

/* FAB --------------------------------------------------------------------- */
.fab {
  position: absolute;
  right: calc(18px + var(--safe-r));
  bottom: calc(22px + var(--safe-b));
  width: 60px;
  height: 60px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: var(--brand-contrast);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 14px 30px color-mix(in oklch, var(--brand) 38%, transparent), var(--shadow-2);
  z-index: 30;
  transition: transform var(--dur) var(--spring), box-shadow var(--dur) var(--ease), filter var(--dur) var(--ease);
}

.fab .i {
  width: 27px;
  height: 27px;
  stroke-width: 2.2;
}

.fab:hover {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.06);
}

.fab:active {
  transform: scale(0.93);
}

/* --------------------------------------------------------------------------
   Editor
   -------------------------------------------------------------------------- */
.editor-appbar {
  flex: none;
  padding: calc(var(--safe-t) + 6px) calc(10px + var(--safe-r)) 10px calc(10px + var(--safe-l));
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.editor-heading {
  flex: 1;
  min-width: 0;
  padding: 0 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.editor-title {
  font-size: 0.97rem;
  font-weight: 680;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-3);
  line-height: 1.3;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex: none;
}

.editor-status[data-state="saving"] .status-dot {
  background: var(--warning);
  animation: pulse 1s var(--ease) infinite;
}

.editor-status[data-state="error"] .status-dot {
  background: var(--danger);
}

.editor-status[data-state="error"] {
  color: var(--danger);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.85);
  }
}

/* Segmentado -------------------------------------------------------------- */
.segmented {
  display: flex;
  gap: 2px;
  width: fit-content;
  margin: 9px auto 0;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
}

.segmented button {
  padding: 6px 17px;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  font-weight: 620;
  color: var(--text-2);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

/* Cuerpo del editor ------------------------------------------------------- */
.editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--surface);
}

.editor-pane,
.preview-pane {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.editor-body[data-view="edit"] .preview-pane,
.editor-body[data-view="preview"] .editor-pane {
  display: none;
}

.editor-body[data-view="split"] {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.editor-body[data-view="split"] .preview-pane {
  border-left: 1px solid var(--line);
}

#editor {
  width: 100%;
  height: 100%;
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--brand);
  padding: 18px calc(16px + var(--safe-r)) 40px calc(16px + var(--safe-l));
  font-family: var(--font-mono);
  font-size: 15.5px;
  line-height: 1.72;
  tab-size: 2;
}

#editor::placeholder {
  color: var(--text-3);
}

.preview-pane {
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
}

#preview {
  flex: 1;
  padding: 18px calc(18px + var(--safe-r)) 80px calc(18px + var(--safe-l));
}

/* Barra de formato -------------------------------------------------------- */
.md-toolbar {
  order: 3;
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
  background: color-mix(in oklch, var(--surface) 94%, transparent);
  border-top: 1px solid var(--line);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.md-toolbar::-webkit-scrollbar {
  display: none;
}

.tool {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 600;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 0.12s var(--ease);
}

.tool .i {
  width: 19px;
  height: 19px;
}

.tool:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tool:active {
  transform: scale(0.9);
  background: var(--surface-3);
}

.tool--text b,
.tool--text i,
.tool--text s {
  font-size: 0.95rem;
}

.tool-sep {
  flex: none;
  width: 1px;
  height: 22px;
  margin: 0 5px;
  background: var(--line);
}

/* Pie del editor ---------------------------------------------------------- */
.editor-footer {
  order: 2;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 2px calc(16px + var(--safe-r)) 6px calc(16px + var(--safe-l));
  background: var(--surface);
  color: var(--text-3);
  font-size: 0.69rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.dot-sep {
  opacity: 0.6;
}

/* Placeholder escritorio -------------------------------------------------- */
.screen--placeholder {
  display: none;
  background: transparent;
}

.screen--placeholder .empty {
  padding: 24px;
}

/* --------------------------------------------------------------------------
   Hojas y diálogos
   -------------------------------------------------------------------------- */
dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: none;
  max-height: none;
}

dialog::backdrop {
  background: oklch(10% 0.02 278 / 0.48);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade-in 0.22s var(--ease);
}

.sheet {
  width: min(560px, calc(100vw - 32px));
  margin: auto;
  overflow: visible;
}

.sheet__inner {
  max-height: min(86dvh, 800px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 6px calc(18px + var(--safe-r)) 20px calc(18px + var(--safe-l));
  animation: sheet-in 0.32s var(--ease);
}

.sheet__grabber {
  width: 42px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--line-strong);
  margin: 8px auto 10px;
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.sheet__title {
  font-size: 1.08rem;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.sheet__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
}

/* Selector de color de nota ------------------------------------------------ */
.note-color-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.note-color {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 620;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 0.12s var(--ease);
}

.note-color:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.note-color:active {
  transform: scale(0.97);
}

.note-color[aria-checked="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 16%, transparent);
}

.note-color__swatch {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.note-color[data-color="lilac"] .note-color__swatch {
  background: var(--note-lilac);
  border-color: var(--note-lilac-border);
}

.note-color[data-color="mint"] .note-color__swatch {
  background: var(--note-mint);
  border-color: var(--note-mint-border);
}

.note-color[data-color="sky"] .note-color__swatch {
  background: var(--note-sky);
  border-color: var(--note-sky-border);
}

.note-color[data-color="sand"] .note-color__swatch {
  background: var(--note-sand);
  border-color: var(--note-sand-border);
}

.note-color[data-color="peach"] .note-color__swatch {
  background: var(--note-peach);
  border-color: var(--note-peach-border);
}

.note-color[data-color="rose"] .note-color__swatch {
  background: var(--note-rose);
  border-color: var(--note-rose-border);
}

.note-color--none {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
}

.note-color--none .note-color__swatch {
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  background:
    linear-gradient(135deg, transparent 46%, var(--text-3) 46%, var(--text-3) 54%, transparent 54%),
    var(--surface);
}

.sheet__item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px 11px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 550;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.sheet__item .i {
  color: var(--text-2);
  width: 20px;
  height: 20px;
}

.sheet__item:hover {
  background: var(--surface-2);
}

.sheet__item:active {
  background: var(--surface-3);
}

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

.sheet__item--danger .i {
  color: var(--danger);
}

.sheet__item--danger:hover {
  background: var(--danger-soft);
}

.sheet__foot {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text-3);
  font-size: 0.73rem;
  text-align: center;
}

.sheet__foot .i {
  width: 14px;
  height: 14px;
}

.settings-group {
  margin-top: 20px;
}

.settings-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-3);
}

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
}

.seg button {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--r-full);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.seg button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.select {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color var(--dur) var(--ease);
}

.select:hover {
  border-color: var(--line-strong);
}

.storage {
  padding: 13px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.meter {
  height: 7px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 2%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 0.5s var(--ease);
}

.storage__text {
  margin-top: 9px;
  font-size: 0.78rem;
  color: var(--text-2);
}

/* Respaldo ---------------------------------------------------------------- */
.backup-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 0.83rem;
  font-weight: 520;
  color: var(--text-2);
}

.backup-status__dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
}

.backup-status[data-state="on"] .backup-status__dot {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--success) 18%, transparent);
}

.backup-status[data-state="warn"] .backup-status__dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--warning) 20%, transparent);
}

.backup-note {
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-2);
}

.backup-error {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--danger-soft);
  border: 1px solid color-mix(in oklch, var(--danger) 28%, transparent);
  border-radius: var(--r-sm);
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.45;
}

.backup-warning {
  margin-top: 8px;
  color: var(--danger);
  font-size: 0.78rem;
  line-height: 1.5;
}

.backup-form {
  margin-top: 4px;
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text-2);
}

.input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color var(--dur) var(--ease);
}

.input:hover {
  border-color: var(--line-strong);
}

.input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.field-hint {
  margin-top: 6px;
  font-size: 0.73rem;
  line-height: 1.45;
  color: var(--text-3);
}

.field-hint code {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-2);
  cursor: pointer;
}

.check input {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  flex: none;
  accent-color: var(--brand);
}

.backup-form .btn--block {
  margin-top: 18px;
}

.backup-panel__status {
  margin-top: 14px;
  font-size: 0.92rem;
  font-weight: 650;
}

.backup-panel__meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-3);
}

.backup-meter {
  margin-top: 12px;
}

.backup-actions {
  margin-top: 14px;
}

.backup-daily {
  margin-top: 16px;
}

.backup-list-label {
  margin-top: 22px;
}

.backup-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.backup-empty {
  padding: 14px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-3);
}

.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px 9px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.backup-item__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.backup-item__main strong {
  font-size: 0.84rem;
  font-weight: 650;
}

.backup-item__main span {
  font-size: 0.73rem;
  color: var(--text-3);
}

.backup-item__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.backup-item__actions .btn {
  padding: 0 12px;
}

.backup-account {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.backup-account .btn {
  justify-content: center;
}

/* Compartir --------------------------------------------------------------- */
.share-text {
  width: 100%;
  height: 168px;
  margin-top: 12px;
  padding: 12px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  resize: vertical;
}

.sheet__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.sheet__actions .btn {
  flex: 1;
  padding: 0 10px;
}

/* Confirmación ------------------------------------------------------------ */
.dialog {
  width: min(430px, calc(100vw - 36px));
  margin: auto;
}

.dialog__card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 24px;
  animation: pop-in 0.26s var(--spring);
}

.dialog__title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dialog__text {
  margin-top: 8px;
  font-size: 0.91rem;
  line-height: 1.55;
  color: var(--text-2);
  text-wrap: pretty;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

/* --------------------------------------------------------------------------
   Botones y formularios
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 620;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 0.12s var(--ease), filter var(--dur) var(--ease);
}

.btn .i {
  width: 18px;
  height: 18px;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  border-color: transparent;
  color: var(--brand-contrast);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px color-mix(in oklch, var(--brand) 30%, transparent);
}

.btn--primary:hover {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  filter: brightness(1.05);
}

.btn--danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in oklch, var(--danger) 26%, transparent);
}

.btn--danger:hover {
  background: color-mix(in oklch, var(--danger) 16%, var(--surface));
}

.btn--ghost {
  background: transparent;
}

.btn--block {
  width: 100%;
  margin-top: 8px;
  justify-content: flex-start;
  padding: 0 14px;
}

.btn--sm {
  height: 34px;
  padding: 0 13px;
  font-size: 0.8rem;
  border-radius: var(--r-xs);
}

/* --------------------------------------------------------------------------
   Toasts, avisos y arranque
   -------------------------------------------------------------------------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-b));
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: color-mix(in oklch, var(--text) 92%, transparent);
  color: var(--surface);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.4;
  animation: toast-in 0.34s var(--spring);
}

.toast.is-out {
  animation: toast-out 0.22s var(--ease) forwards;
}

.toast__action {
  margin-left: auto;
  padding: 5px 9px;
  border-radius: var(--r-xs);
  color: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  flex: none;
}

.toast--error {
  background: var(--danger);
  color: oklch(98% 0 0);
}

.toast--success {
  background: var(--success);
  color: oklch(99% 0.01 150);
}

.update-banner {
  position: fixed;
  top: calc(12px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-2);
  z-index: 320;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  animation: drop-in 0.4s var(--spring);
}

/* Boot -------------------------------------------------------------------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg);
  transition: opacity 0.45s var(--ease), visibility 0.45s;
}

.boot.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot__mark {
  width: 78px;
  height: 78px;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 44px color-mix(in oklch, var(--brand) 40%, transparent);
  animation: boot-pop 0.7s var(--spring);
}

.boot__mark svg {
  width: 100%;
  height: 100%;
}

.boot__name {
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
}

.boot__spinner {
  width: 18px;
  height: 18px;
  margin-top: 6px;
  border-radius: 50%;
  border: 2.5px solid color-mix(in oklch, var(--brand) 22%, transparent);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

/* Animaciones ------------------------------------------------------------- */
@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

@keyframes drop-in {
  from {
    opacity: 0;
    transform: translate(-50%, -14px);
  }
}

@keyframes boot-pop {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
}

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

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (hover: none) {
  .note-card__pin {
    opacity: 1;
    color: var(--text-3);
  }
}

@media (max-width: 719px) {
  .segmented [data-view="split"] {
    display: none;
  }

  .md-toolbar {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }

  .md-toolbar.is-scroll-end {
    -webkit-mask-image: none;
    mask-image: none;
  }

  .brand__sub {
    max-width: 46vw;
  }

  .offline-pill span {
    display: none;
  }

  .sheet {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
  }

  .sheet__inner {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    padding-bottom: calc(18px + var(--safe-b));
    animation: sheet-up 0.34s var(--ease);
    max-height: 90dvh;
  }

  .toast-host {
    bottom: calc(96px + var(--safe-b));
  }
}

@media (max-width: 1023px) {
  .app.is-editing .screen--list {
    display: none;
  }

  .editor-body[data-view="split"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .editor-body[data-view="split"] .preview-pane {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (min-width: 1024px) {
  .app {
    display: grid;
    grid-template-columns: 384px minmax(0, 1fr);
    grid-template-rows: 100dvh;
  }

  .screen {
    height: 100%;
  }

  .screen--list {
    display: flex;
    grid-column: 1;
    grid-row: 1;
    border-right: 1px solid var(--line);
    background: color-mix(in oklch, var(--bg) 60%, transparent);
  }

  .screen--editor {
    grid-column: 2;
    grid-row: 1;
  }

  .screen--placeholder {
    grid-column: 2;
    grid-row: 1;
    display: none;
    align-items: center;
    justify-content: center;
  }

  .app:not(.is-editing) .screen--placeholder {
    display: flex;
  }

  .list-appbar {
    padding-top: 20px;
  }

  .notes-scroll {
    padding-bottom: calc(96px + var(--safe-b));
  }

  .fab {
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }

  .toast-host {
    bottom: calc(36px + var(--safe-b));
  }

  .editor-appbar {
    padding-top: 12px;
  }

  .segmented {
    margin-top: 11px;
  }

  #editor {
    padding-left: 28px;
    padding-right: 24px;
    font-size: 15px;
  }

  #preview {
    padding: 30px 40px 80px;
  }

  .editor-body[data-view="split"] #preview {
    padding-left: 24px;
    padding-right: 24px;
  }

  .md-toolbar,
  .editor-footer {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (min-width: 1440px) {
  .app {
    grid-template-columns: 420px minmax(0, 1fr);
  }
}

/* Vista de pantalla completa opcional en móviles */
@supports (height: 100dvh) {
  .app {
    height: 100dvh;
  }
}
