/* NoteX — warm neutral dark UI + purple accents only */

:root {
  color-scheme: dark;

  --color-brand-primary: #8b5cf6;
  --color-brand-primary-hover: #a78bfa;
  --color-brand-primary-soft: #c4b5fd;
  --color-brand-secondary: #6d28d9;
  --color-brand-secondary-soft: #7c3aed;

  /* Same warm dark neutrals as the original app (no purple tint) */
  --color-bg-page: #0c0b0a;
  --color-bg-canvas: #161412;
  --color-bg-surface: #1e1c19;
  --color-bg-alt: #252220;
  --color-bg-muted: #2f2c28;

  --color-text-primary: #ebe6e0;
  --color-text-secondary: #a9a095;
  --color-text-muted: #7a7269;
  --color-text-inverse: #141210;
  --color-heading-accent: #a78bfa;

  --color-border: #4a433c;
  --color-border-soft: #35302b;
  --color-border-strong: #6b6258;

  --icon-accent: #a78bfa;
  --icon-neutral: #7d776f;
  --icon-pink: #e879f9;
  --icon-blue: #818cf8;
  --icon-red: #f87171;

  --state-success: #7eb878;
  --state-warning: #d4a05c;
  --state-danger: #e07068;
  --state-focus: #a78bfa;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-composer: 0 2px 6px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-button: 0 2px 0 rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.45);

  --font-primary: Poppins, "Roboto", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --motion-fast: 150ms;
  --motion-base: 200ms;
  --motion-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --layout-max: 1200px;
  --page-pad-x: clamp(16px, 4vw, 48px);
  --page-pad-y: clamp(24px, 3vw, 40px);

  --navbar-height: 64px;
  --keep-card-radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--color-text-primary);
  background: var(--color-bg-page);
  -webkit-font-smoothing: antialiased;
}

body.modal-open,
body.settings-modal-open {
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-frame {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-canvas);
  max-width: 100%;
  margin: 0 auto;
}

.quick-links-row {
  background: var(--color-bg-canvas);
  border-bottom: 1px solid var(--color-border-soft);
}

.quick-links-strip {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 8px var(--page-pad-x) 10px;
  min-height: 40px;
}

.quick-links-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.quick-link-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  padding: 6px 12px;
  min-height: 30px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-soft);
  background: var(--color-bg-alt);
  color: var(--color-brand-primary-soft);
  text-decoration: none;
  transition:
    background var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease);
}

.quick-link-pill:hover {
  background: var(--color-bg-muted);
  border-color: var(--color-brand-primary);
  color: var(--color-heading-accent);
}

.quick-link-pill:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

/* Navbar */
.navbar {
  height: var(--navbar-height);
  background: var(--color-bg-canvas);
  border-bottom: 1px solid var(--color-border-soft);
  position: sticky;
  top: 0;
  z-index: 40;
}

.navbar__inner {
  height: 100%;
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 0 var(--page-pad-x);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}

.navbar__search {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  justify-self: center;
}

.navbar__tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  justify-self: end;
  min-width: 0;
}

.navbar__tool {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  color: var(--color-text-primary);
  transition:
    background var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease);
}

.navbar__tool:hover {
  background: var(--color-bg-muted);
  border-color: var(--color-border-strong);
}

.navbar__tool:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

.navbar__tool--logout {
  border-color: rgba(224, 112, 104, 0.45);
  color: var(--state-danger);
}

.navbar__tool--logout:hover {
  background: rgba(224, 112, 104, 0.12);
  border-color: var(--icon-red);
}

.logo {
  text-decoration: none;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.logo__word {
  color: var(--color-text-primary);
  border-bottom: 2px solid var(--color-brand-primary);
  padding-bottom: 2px;
}

.logo__accent {
  color: var(--color-heading-accent);
}

/* Search */
.search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--color-bg-alt);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition:
    background var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

.search-field--nav {
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.search-field:focus-within {
  background: var(--color-bg-alt);
  border-color: var(--color-border-strong);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.22);
}

.search-field__icon {
  flex-shrink: 0;
  color: var(--icon-neutral);
}

.search-field__input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-primary);
  font-size: 15px;
  color: var(--color-text-primary);
  min-width: 0;
}

.search-field__input::placeholder {
  color: var(--color-text-muted);
}

.search-field__input:focus {
  outline: none;
}

/* Main + composer (Keep-style) */
.main--keep {
  flex: 1;
  padding: 16px var(--page-pad-x) var(--page-pad-y);
  max-width: var(--layout-max);
  margin: 0 auto;
  width: 100%;
}

.category-strip {
  margin-bottom: 18px;
  min-height: 48px;
  padding: 4px 0;
  border-radius: var(--radius-sm);
}

.category-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.category-pill {
  font-family: var(--font-primary);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.2;
  padding: 10px 20px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--color-border-soft);
  background: transparent;
  color: var(--color-text-muted);
  box-shadow: none;
  transition:
    background var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease);
}

.category-pill:hover {
  background: var(--color-bg-surface);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.category-pill:focus-visible {
  outline: 1px solid var(--state-focus);
  outline-offset: 3px;
}

.category-pill--active {
  background: rgba(139, 92, 246, 0.08);
  color: var(--color-brand-primary-soft);
  border: 1px solid var(--color-brand-primary);
  box-shadow: none;
}

.category-pill--active:hover {
  background: rgba(139, 92, 246, 0.11);
  color: var(--color-brand-primary-soft);
  border-color: var(--color-brand-primary-hover);
}

.ctx-menu {
  position: fixed;
  z-index: 120;
  min-width: 160px;
  padding: 6px;
  margin: 0;
  list-style: none;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
}

.ctx-menu[hidden] {
  display: none !important;
}

.ctx-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-ease);
}

.ctx-menu__item:hover {
  background: var(--color-bg-muted);
}

.ctx-menu__item:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 0;
}

.ctx-menu__item--danger {
  color: var(--state-danger);
}

.ctx-menu__item--danger:hover {
  background: rgba(224, 112, 104, 0.12);
}

.settings-modal__footer--split {
  justify-content: space-between;
  gap: 12px;
}

.settings-modal__input--full {
  width: 100%;
  margin-top: 4px;
}

.category-delete-modal__text {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.composer-wrap {
  max-width: 600px;
  margin: 0 auto 24px;
}

.composer {
  position: relative;
}

.composer__collapsed {
  width: 100%;
  display: block;
  text-align: left;
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 14px 18px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--keep-card-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: text;
  transition:
    box-shadow var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease);
}

.composer__collapsed:hover {
  border-color: var(--color-border);
}

.composer__collapsed:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

.composer__expanded {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--keep-card-radius);
  box-shadow: var(--shadow-composer);
  padding: 12px 16px 8px;
  animation: composerIn var(--motion-base) var(--motion-ease);
}

@keyframes composerIn {
  from {
    opacity: 0.85;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.composer__title {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-primary);
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
  padding: 6px 4px 8px;
  margin: 0;
}

.composer__title::placeholder {
  color: var(--color-text-muted);
  font-weight: 500;
}

.composer__title:focus {
  outline: none;
}

.composer__body {
  display: block;
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: none;
  background: transparent;
  font-family: var(--font-primary);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text-primary);
  padding: 4px 4px 12px;
  margin: 0;
}

.composer__body::placeholder {
  color: var(--color-text-muted);
}

.composer__body:focus {
  outline: none;
}

.composer__footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px solid var(--color-border-soft);
  margin-top: 4px;
}

.composer__close {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--motion-base) var(--motion-ease);
}

.composer__close:hover {
  background: var(--color-bg-muted);
}

.composer__close:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

/* Note cards grid (Keep-style) */
.grid-hint {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 15px;
  margin: 32px 16px 24px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}

.keep-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  width: 100%;
  min-height: 96px;
  padding: 14px 16px 12px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--keep-card-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  font-family: var(--font-primary);
  transition:
    box-shadow var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease);
}

.keep-card:hover {
  box-shadow: var(--shadow-card);
  border-color: var(--color-border);
}

.keep-card:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

.keep-card[draggable="true"] {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.keep-card[draggable="true"]:active {
  cursor: grabbing;
}

.keep-card--dragging {
  opacity: 0.55;
  box-shadow: var(--shadow-card);
}

.keep-card--drop-before {
  box-shadow: inset 0 3px 0 0 var(--color-brand-primary);
}

.keep-card--drop-after {
  box-shadow: inset 0 -3px 0 0 var(--color-brand-primary);
}

.keep-card__title {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 8px;
  line-height: 1.35;
  word-break: break-word;
}

.keep-card__title--empty {
  color: var(--color-text-muted);
  font-weight: 500;
}

.keep-card__body {
  font-size: 14px;
  line-height: 1.45;
  color: var(--color-text-secondary);
  word-break: break-word;
  flex: 1;
  margin-bottom: 12px;
  max-height: 200px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 9;
}

.keep-card__meta {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: auto;
}

.keep-card__meta--hidden {
  display: none !important;
}

.keep-card__body--placeholder {
  filter: none;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  color: var(--color-text-muted);
  font-style: italic;
  max-height: none;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
  display: block;
  overflow: visible;
}

/* Modal (edit note) */
.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 48px;
  overflow-y: auto;
}

.modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin-top: min(8vh, 64px);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--keep-card-radius);
  box-shadow: var(--shadow-composer);
  padding: 16px 18px 12px;
  animation: modalIn var(--motion-base) var(--motion-ease);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal__title-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-primary);
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text-primary);
  padding: 8px 4px 12px;
  margin: 0;
}

.modal__title-input::placeholder {
  color: var(--color-text-muted);
}

.modal__title-input:focus {
  outline: none;
}

.modal__body-input {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  border: none;
  background: transparent;
  font-family: var(--font-primary);
  font-size: 15px;
  line-height: 1.55;
  color: var(--color-text-primary);
  padding: 8px 4px 16px;
  margin: 0;
}

.modal__body-input:focus {
  outline: none;
}

.modal__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border-soft);
}

.modal__saved {
  font-size: 12px;
  color: var(--state-success);
  min-height: 1.2em;
}

.modal__saved.is-pending {
  color: var(--color-text-muted);
}

.modal__actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.modal__btn {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: background var(--motion-base) var(--motion-ease);
}

.modal__btn--primary {
  background: var(--color-brand-primary);
  color: #faf5ff;
}

.modal__btn--primary:hover {
  background: var(--color-brand-primary-hover);
}

.modal__btn--danger {
  background: transparent;
  color: var(--state-danger);
}

.modal__btn--danger:hover {
  background: rgba(224, 112, 104, 0.12);
}

.modal__btn:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

/* Settings modal */
.settings-modal[hidden] {
  display: none !important;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}

.settings-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.settings-modal__panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin-top: min(12vh, 80px);
  padding: 22px 22px 18px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-composer);
}

.settings-modal__title {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}

.settings-modal__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--color-border-soft);
  border-bottom: 1px solid var(--color-border-soft);
}

.settings-modal__row-text {
  flex: 1;
  min-width: 0;
}

.settings-modal__label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.settings-modal__hint {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.settings-modal__field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-top: 14px;
  margin-bottom: 6px;
}

.quick-link-form-modal .settings-modal__title + .settings-modal__field-label {
  margin-top: 4px;
}

.settings-modal__row--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.settings-modal__category-add {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.settings-modal__input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-primary);
  font-size: 15px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
}

.settings-modal__input::placeholder {
  color: var(--color-text-muted);
}

.settings-modal__input:focus {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

.settings-modal__btn-add {
  flex-shrink: 0;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  background: var(--color-brand-primary);
  color: #faf5ff;
  transition: background var(--motion-base) var(--motion-ease);
}

.settings-modal__btn-add:hover {
  background: var(--color-brand-primary-hover);
}

.settings-modal__btn-add:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

.settings-modal__error {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--state-danger);
}

.settings-modal__footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.settings-modal__done {
  font-family: var(--font-primary);
  font-size: 15px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  background: var(--color-brand-primary);
  color: #faf5ff;
  transition: background var(--motion-base) var(--motion-ease);
}

.settings-modal__done:hover {
  background: var(--color-brand-primary-hover);
}

.settings-modal__done:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 2px;
}

.settings-modal__done--wide {
  width: 100%;
}

/* Toggle switch */
.toggle {
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-pill);
}

.toggle:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 3px;
}

.toggle__track {
  display: block;
  width: 52px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--color-bg-muted);
  border: 2px solid var(--color-border);
  position: relative;
  transition:
    background var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease);
}

.toggle__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-text-primary);
  border: 1px solid var(--color-border-strong);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform var(--motion-base) var(--motion-ease);
}

.toggle[aria-checked="true"] .toggle__track {
  background: rgba(139, 92, 246, 0.28);
  border-color: var(--color-brand-primary);
}

.toggle[aria-checked="true"] .toggle__knob {
  transform: translateX(22px);
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary-soft);
}

/* Footer */
.footer {
  padding: 20px var(--page-pad-x) 28px;
  border-top: 1px solid var(--color-border-soft);
  text-align: center;
}

.footer p {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Login gate */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--color-bg-page);
}

.login-gate[hidden] {
  display: none !important;
}

.login-gate__box {
  width: 100%;
  max-width: 360px;
  padding: 32px 28px 28px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-composer);
}

.login-gate__brand {
  margin: 0 0 24px;
  text-align: center;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-gate__brand-word {
  color: var(--color-text-primary);
  border-bottom: 2px solid var(--color-brand-primary);
  padding-bottom: 2px;
}

.login-gate__brand-accent {
  color: var(--color-heading-accent);
}

.login-gate__label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 10px;
}

.login-gate__input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font-primary);
  font-size: 16px;
  color: var(--color-text-primary);
  background: var(--color-bg-canvas);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  transition: border-color var(--motion-base) var(--motion-ease);
}

.login-gate__input::placeholder {
  color: var(--color-text-muted);
}

.login-gate__input:focus {
  outline: none;
  border-color: var(--state-focus);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.2);
}

.login-gate__submit {
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 600;
  color: #faf5ff;
  background: var(--color-brand-secondary-soft);
  border: 2px solid #1a1218;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: var(--shadow-button);
  transition:
    background var(--motion-base) var(--motion-ease),
    transform var(--motion-base) var(--motion-ease);
}

.login-gate__submit:hover {
  background: var(--color-brand-primary-hover);
}

.login-gate__submit:active {
  transform: translateY(1px);
}

.login-gate__submit:focus-visible {
  outline: 2px solid var(--state-focus);
  outline-offset: 3px;
}

.login-gate__error {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--state-danger);
  text-align: center;
}

.app-shell[hidden] {
  display: none !important;
}

/* Narrow screens & phones: layout, safe areas, touch targets */
@media (max-width: 720px) {
  .navbar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    height: auto;
    min-height: var(--navbar-height);
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    padding-bottom: 10px;
    padding-left: max(var(--page-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--page-pad-x), env(safe-area-inset-right, 0px));
  }

  .logo {
    font-size: 20px;
  }

  .navbar__search {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
  }

  .navbar__tools {
    margin-left: auto;
  }

  .search-field--nav {
    width: 100%;
  }

  .search-field__input {
    font-size: 16px;
  }

  .navbar__tool {
    min-height: 44px;
    padding: 10px 14px;
    touch-action: manipulation;
  }

  .quick-links-strip {
    padding-left: max(var(--page-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--page-pad-x), env(safe-area-inset-right, 0px));
  }

  .quick-link-pill {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 13px;
    touch-action: manipulation;
  }

  .main--keep {
    padding-top: 12px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    padding-left: max(var(--page-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--page-pad-x), env(safe-area-inset-right, 0px));
  }

  .notes-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .keep-card {
    min-height: 100px;
    padding: 16px;
    touch-action: manipulation;
  }

  .category-pill {
    min-height: 44px;
    padding: 12px 18px;
    touch-action: manipulation;
  }

  .composer__collapsed {
    min-height: 48px;
    touch-action: manipulation;
  }

  .composer__title,
  .composer__body {
    font-size: 16px;
  }

  .settings-modal__input {
    font-size: 16px;
  }

  .modal {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }

  .modal__panel {
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal__title-input,
  .modal__body-input {
    font-size: 16px;
  }

  .settings-modal {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }

  .settings-modal__panel {
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .settings-modal__done,
  .settings-modal__btn-add,
  .modal__btn {
    touch-action: manipulation;
    min-height: 44px;
  }

  .ctx-menu__item {
    min-height: 44px;
    padding: 12px 14px;
  }

  .login-gate {
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
  }

  .footer {
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }
}
