/* Pocket Notes — index cards on cool paper, with a highlighter-yellow
   strip reserved for one meaning only: "pinned". */

:root {
  --paper: #e9eef4;
  --card: #ffffff;
  --ink: #1d2a3b;
  --muted: #5a6a7e;
  --line: #c6d0dc;
  --rule: #d9e4f1;          /* index-card ruled lines */
  --highlight: #ffd84a;     /* pinned only */
  --highlight-ink: #3b3000;
  --danger: #b42318;
  --focus: #2f6fe0;

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;

  --radius-sm: 6px;
  --radius-card: 3px;       /* index cards are nearly square-cornered */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131a23;
    --card: #1c2531;
    --ink: #e4ebf3;
    --muted: #93a3b7;
    --line: #334256;
    --rule: #25303e;
    --highlight: #f2cc3d;
    --highlight-ink: #2a2200;
    --danger: #ff8a7a;
    --focus: #7fa8ff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

.stack > * + * { margin-top: 1rem; }

/* ---------- form controls ---------- */

.field { display: block; }
.field > span { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
.field small { display: block; color: var(--muted); margin-top: .3rem; font-size: .85rem; }

input[type="email"], input[type="password"], input[type="text"],
input[type="search"], input:not([type]), textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .6rem .75rem;
}
textarea { resize: vertical; min-height: 7rem; }
input:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }

.btn {
  font: inherit;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: .6rem 1.1rem;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 85%, var(--focus)); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-text { background: none; border: 0; padding: .25rem .4rem; color: var(--muted); font-size: .9rem; }
.btn-text:hover { color: var(--ink); text-decoration: underline; }
.btn-text.danger:hover { color: var(--danger); }

.form-error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
  font-size: .95rem;
}

/* ---------- sign-in page ---------- */

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 6rem);
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 4rem);
}

.wordmark {
  font-size: clamp(3.5rem, 11vw, 8rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: .86;
}

.lede { font-size: 1.15rem; color: var(--muted); max-width: 32ch; margin: 1.25rem 0 0; }

.card-stack { position: relative; height: 14rem; margin-top: 2.5rem; max-width: 26rem; }

.index-card {
  position: absolute;
  width: 17rem;
  padding: 1rem 1.1rem 1.2rem;
  background-image: repeating-linear-gradient(to bottom, transparent 0 1.55rem, var(--rule) 1.55rem calc(1.55rem + 1px));
  background-color: var(--card);
  background-position: 0 2.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 1px 0 var(--line), 0 12px 24px -18px rgb(20 35 60 / .45);
}
.index-card strong { display: block; font-family: var(--font-display); font-size: 1.1rem; margin-bottom: .35rem; }
.index-card span { color: var(--muted); font-size: .95rem; }
.index-card.c1 { top: 0; left: 0; transform: rotate(-4deg); }
.index-card.c2 { top: 3.2rem; left: 5rem; transform: rotate(2.5deg); z-index: 2; }
.index-card.c3 { top: 7.4rem; left: 1.5rem; transform: rotate(-1.5deg); }

/* The one bold element: a strip of highlighter tape on pinned cards. */
.is-pinned::before {
  content: "";
  position: absolute;
  top: -.55rem;
  left: 50%;
  width: 5.5rem;
  height: 1.1rem;
  transform: translateX(-50%) rotate(-2deg);
  background: var(--highlight);
  opacity: .92;
  border-radius: 1px;
}

.auth-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.tabs { display: flex; gap: .25rem; border-bottom: 1.5px solid var(--line); margin-bottom: 1.5rem; }
.tabs button {
  font: inherit;
  font-weight: 700;
  background: none;
  border: 0;
  padding: .6rem .9rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1.5px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.auth-panel .btn-primary { width: 100%; padding: .75rem; }

/* ---------- app ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: .9rem; }
.user-name { color: var(--muted); }

.app-layout {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  max-width: 80rem;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 2.5rem) 4rem;
  align-items: start;
}

.composer {
  position: sticky;
  top: 5.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
}
.composer h2 { font-size: 1.3rem; }
.composer .btn-primary { width: 100%; }

.notes-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.notes-toolbar h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -0.03em; }
.notes-toolbar input { max-width: 16rem; }

.status { color: var(--muted); margin: 0 0 1rem; }

.notes-grid { columns: 17rem; column-gap: 1.25rem; }

.note {
  position: relative;
  break-inside: avoid;
  margin: 0 0 1.5rem;
  padding: 1rem 1.1rem .6rem;
  background-color: var(--card);
  background-image: repeating-linear-gradient(to bottom, transparent 0 1.55rem, var(--rule) 1.55rem calc(1.55rem + 1px));
  background-position: 0 2.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.note h3 { font-size: 1.15rem; margin-bottom: .35rem; overflow-wrap: anywhere; }
.note p { margin: 0 0 .75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .25rem;
  border-top: 1px solid var(--line);
  padding-top: .4rem;
}
.note time { color: var(--muted); font-size: .82rem; }
.note .actions { display: flex; }
.note .stack > * + * { margin-top: .75rem; }
.note .edit-actions { display: flex; gap: .5rem; }

.note.just-added { animation: settle .35s ease-out; }
@keyframes settle {
  from { transform: translateY(-6px) rotate(-1.5deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@media (max-width: 860px) {
  .auth-layout { grid-template-columns: 1fr; align-items: start; }
  .card-stack { display: none; }
  .app-layout { grid-template-columns: 1fr; }
  .composer { position: static; }
  .user-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
