/* Apple-style design tokens (iOS system colors, blue tint) */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: rgba(60, 60, 67, .6);
  --separator: rgba(60, 60, 67, .2);
  --fill: rgba(118, 118, 128, .12);
  --tint: #0071e3;
  --tint-text: #ffffff;
  --select: rgba(0, 113, 227, .12);
  --danger: #ff3b30;
  --bar: rgba(249, 249, 249, .82);
  --menu-bg: rgba(250, 250, 252, .88);
  --seg-active: #ffffff;
  --shadow-pop: 0 14px 44px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .08);
  --c-default: var(--bg);


  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(.32, .72, 0, 1);
  /* One height for list cards, section labels and ruled lines, so both panes match */
  --row-h: 38px;
  color-scheme: light;
}

/* Light by default (owner, 2026-10-19). Dark only when chosen in Menu → Dark mode. */

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --text: #ffffff;
  --muted: rgba(235, 235, 245, .6);
  --separator: rgba(84, 84, 88, .65);
  --fill: rgba(118, 118, 128, .24);
  --tint: #0a84ff;
  --tint-text: #ffffff;
  --select: rgba(10, 132, 255, .24);
  --danger: #ff453a;
  --bar: rgba(22, 22, 23, .82);
  --menu-bg: rgba(40, 40, 42, .88);
  --seg-active: #636366;
  --shadow-pop: 0 14px 44px rgba(0, 0, 0, .55), 0 0 0 .5px rgba(255, 255, 255, .08);
  --c-default: var(--bg);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 var(--font);
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; letter-spacing: inherit; }
input, textarea { letter-spacing: inherit; }

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] { display: none !important; }

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

/* Always two panes on every screen: titles 35% | note 65% */
.app { grid-template-columns: minmax(0, 35fr) minmax(0, 65fr); }
.sidebar { border-right: .5px solid var(--separator); }

/* ---------- Top header: user on the left, menu on the far right ---------- */

.appbar {
  grid-column: 1 / -1;
  position: relative;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: calc(env(safe-area-inset-top) + 8px) max(12px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--bar);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: .5px solid var(--separator);
}
.appbar-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.appbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 16px 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--tint);
  color: var(--tint-text);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--tint) 30%, transparent);
}
.add-btn svg { width: 19px; height: 19px; stroke-width: 2.6; }
.add-btn:active { opacity: .75; }
@media (max-width: 359px) {
  .add-btn { padding: 0 11px; }
  .add-btn span { display: none; }
}

.menu-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  color: var(--tint);
}
.menu-btn svg { width: 22px; height: 22px; stroke-width: 2.2; }
.menu-btn:active { opacity: .6; }

/* ---------- Sidebar: nav ---------- */

.nav { padding: 10px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }


.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--muted);
}
.search svg { width: 17px; height: 17px; flex: none; stroke-width: 2.2; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.search input::placeholder { color: var(--muted); }

/* ---------- Menu (popover) ---------- */

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: 250px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--menu-bg);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow-pop);
  transform-origin: top right;
  animation: pop .22s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.9); } }
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #2997ff, #0060c7);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
}
.menu-id { display: grid; min-width: 0; }
.menu-user { overflow: hidden; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }

.menu > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  background: transparent;
  text-align: left;
}
.menu > button + button { border-top: .5px solid var(--separator); }
.menu > button:hover { background: var(--fill); }
.menu > button svg { width: 20px; height: 20px; }
.menu .danger { color: var(--danger); }

/* ---------- Notebook switcher (replaces the "Notes" heading) ---------- */

.nb-wrap { position: relative; margin: 2px 0 10px; }

.notebook-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--separator);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 3px 8px rgba(0, 0, 0, .06);
  font-size: 17px;
  font-weight: 750;
  text-align: left;
}
.notebook-btn svg { width: 20px; height: 20px; flex: none; color: var(--tint); }
.notebook-btn:active { opacity: .75; }
.nb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notebook-btn .nb-chev { width: 18px; height: 18px; color: var(--muted); transition: transform .2s ease; }
.notebook-btn[aria-expanded="true"] .nb-chev { transform: rotate(180deg); }

.nb-menu {
  left: 0;
  right: auto;
  width: min(280px, calc(100vw - 20px));
  transform-origin: top left;
}
.nb-head {
  padding: 12px 16px 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.nb-list { max-height: 50vh; overflow-y: auto; }
.nb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  text-align: left;
}
.nb-item:hover { background: var(--fill); }
.nb-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.nb-c { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nb-check { width: 18px; height: 18px; flex: none; color: var(--tint); stroke-width: 2.6; visibility: hidden; }
.nb-item[aria-checked="true"] .nb-check { visibility: visible; }
.nb-item[aria-checked="true"] .nb-n { color: var(--tint); }
/* New / Rename / Delete as real buttons under the notebook list */
.nb-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: .5px solid var(--separator);
}
.nb-act {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: var(--fill);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.nb-act svg { width: 18px; height: 18px; flex: none; }
.nb-act:hover { filter: brightness(.96); }
.nb-act:active { opacity: .7; }
.nb-act-new { grid-column: 1 / -1; background: var(--tint); color: var(--tint-text); }
.nb-act-new:hover { filter: brightness(1.08); }
.nb-act-delete { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* ---------- Name dialog (new / rename notebook) ---------- */

.name-dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 22px 20px 18px;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.name-dialog::backdrop { background: rgba(0, 0, 0, .35); }
.name-dialog[open] { animation: pop .22s var(--ease); }
.name-dialog h2 { margin: 0 0 14px; font-size: 18px; font-weight: 700; text-align: center; }
.name-dialog input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--separator);
  border-radius: 12px;
  outline: 0;
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.name-dialog input:focus { border-color: var(--tint); background: var(--surface); box-shadow: 0 0 0 3px var(--select); }
.name-dialog .auth-error { margin-top: 10px; }

/* Delete notebook: red warning + type the name */
.del-nb-dialog h2 { color: var(--danger); }
.del-nb-warning {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
}
.del-nb-label { display: block; margin: 0 0 8px; font-size: 14px; color: var(--text); }
.del-nb-label b { overflow-wrap: anywhere; }
.del-nb-dialog .btn-danger { height: 44px; }
.del-nb-dialog .btn-danger:disabled { opacity: .4; cursor: not-allowed; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.dialog-actions .btn-primary { height: 44px; margin-top: 0; box-shadow: none; }
.btn-secondary {
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  font-weight: 600;
}

/* ---------- Sidebar: list ---------- */

.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}

/* Each note is its own raised card: "1.  Title" */
#groups { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 6px 0 4px; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: var(--row-h);
  padding: 0 12px;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 3px 8px rgba(0, 0, 0, .06);
  font-size: 15px;
  font-weight: 650;
  text-align: left;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.row:hover { box-shadow: 0 2px 4px rgba(0, 0, 0, .08), 0 8px 18px rgba(0, 0, 0, .09); }
.row:active { transform: scale(.985); }
.row:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }
.row[aria-current="true"] { border-color: var(--tint); background: var(--select); box-shadow: 0 0 0 1px var(--tint); }

.row-num { flex: none; min-width: 1.3em; font-variant-numeric: tabular-nums; }
.row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.loading { padding: 40px 0; text-align: center; color: var(--muted); }

.empty { margin-top: 18vh; padding: 0 24px; text-align: center; color: var(--muted); }
.empty p { margin: 0 auto; max-width: 30ch; }
.empty-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 6px !important; }

/* ---------- Buttons ---------- */

.tool-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--tint);
}
.tool-btn:hover { background: var(--fill); }
.tool-btn:active { opacity: .5; }
.tool-btn svg { width: 24px; height: 24px; }

/* ---------- Editor ---------- */

.editor-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  height: 100%;
  color: var(--muted);
}
.editor-empty img { border-radius: 15px; opacity: .55; filter: grayscale(.4); }
.editor-empty p { margin: 0; }

.editor-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--c-default);
  transition: background-color .25s ease;
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 4px max(8px, env(safe-area-inset-right)) 4px max(4px, env(safe-area-inset-left));
}
.spacer { flex: 1; }



.editor-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }

/* ---------- Note sheet: "Title" and "Notes" sections on ruled lines ---------- */

.sheet {
  --lh: var(--row-h);
  --line: color-mix(in srgb, var(--tint) 32%, var(--separator));
  /* Fills the pane at minimum, grows with the note; the ruled textarea takes all spare height */
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  padding: 4px 20px 0;
}
.sheet > * { flex-shrink: 0; }

.sec-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--row-h);
  padding: 0 12px;
  /* Same card look as the title list on the left */
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 3px 8px rgba(0, 0, 0, .06);
  font-size: 15px;
  font-weight: 650;
}
.sec-date { font-size: 12.5px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }

.note-title,
.note-body {
  display: block;
  width: 100%;
  margin: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0;
}
.note-title {
  height: var(--lh);
  margin-top: 10px;
  padding: 0 12px;
  border-bottom: 2px solid var(--line);
  font-size: 15px;
  font-weight: 500;
}
.title-count {
  margin: 3px 4px 10px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Ruled lines are drawn behind the text, one per --lh, and scroll with it */
.note-body {
  flex: 1 0 auto;
  min-height: calc(var(--lh) * 4);
  margin-top: 6px;
  padding: 4px 12px 0;
  overflow: hidden;
  resize: none;
  font-size: 15px;
  line-height: var(--lh);
  background-image: linear-gradient(to bottom, transparent calc(var(--lh) - 2px), var(--line) calc(var(--lh) - 2px));
  background-size: 100% var(--lh);
}
.note-title::placeholder,
.note-body::placeholder { color: var(--muted); }

/* While editing, the focused title line turns blue */
.sheet.editing .note-title:focus { border-bottom-color: var(--tint); }
.note-title[readonly],
.note-body[readonly] { cursor: default; }

@media (max-width: 899px) {
  .sheet { padding: 4px 12px 32px; }
}

/* ---------- Editor bar: Edit / Done + ⋮ menu ---------- */

.edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  margin: 0 2px 0 8px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--select);
  color: var(--tint);
  font-size: 15px;
  font-weight: 700;
}
.edit-btn svg { width: 18px; height: 18px; stroke-width: 2.2; }
.edit-btn .i-done,
.edit-btn.on .i-edit { display: none; }
.edit-btn.on .i-done { display: block; }
.edit-btn.on { background: var(--tint); color: var(--tint-text); }
.edit-btn:active { opacity: .7; }
.edit-btn:disabled { opacity: .45; cursor: progress; }

.tool-btn svg circle { fill: currentColor; }
.editor-meta { margin-right: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.editor-meta.warn { display: inline !important; color: var(--danger); font-weight: 600; white-space: normal; text-align: right; line-height: 1.2; }

/* ---------- Auth ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  overflow-y: auto;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--bg);
}
body:has(.auth:not([hidden])) { overflow: auto; }

.auth-card {
  width: 100%;
  max-width: 360px;
  padding: 38px 28px 32px;
  border: 1px solid var(--separator);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .04);
  text-align: center;
  animation: card-in .5s var(--ease);
}
@keyframes card-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.auth-icon { border-radius: 15px; box-shadow: 0 8px 20px rgba(0, 113, 227, .32); }
.auth-card h1 { margin: 16px 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
/* Shown after this device was signed out because the account was opened elsewhere */
.auth-notice {
  margin: -12px 0 20px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, #ff9f0a 16%, transparent);
  color: color-mix(in srgb, #b25f00 85%, var(--text));
  font-size: 13.5px;
  line-height: 1.4;
  text-align: left;
}
.auth-tag { margin: 0 0 28px; font-size: 14px; color: var(--muted); }

.field { display: grid; gap: 6px; margin-bottom: 14px; text-align: left; }
.field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 600;
  color: color-mix(in srgb, var(--text) 75%, transparent);
}
.counter { font-size: 11px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.field input,
.field select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--separator);
  border-radius: 12px;
  outline: 0;
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.field input::placeholder { color: var(--muted); }
.field input:focus,
.field select:focus {
  border-color: var(--tint);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--select);
}
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0 6px;
  text-align: center;
  text-align-last: center;
  cursor: pointer;
}

.phone-wrap { display: grid; grid-template-columns: 68px 1fr; gap: 8px; }
/* Fixed +91 (India only), styled like the inputs next to it */
.country-code {
  display: grid;
  place-items: center;
  height: 44px;
  border: 1px solid var(--separator);
  border-radius: 12px;
  background: var(--fill);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 48px; }
.eye-btn {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
  transform: translateY(-50%);
}
.eye-btn svg { width: 19px; height: 19px; }
.eye-btn .eye-closed,
.eye-btn[aria-pressed="true"] .eye-open { display: none; }
.eye-btn[aria-pressed="true"] .eye-closed { display: block; }

.hint { font-size: 11.5px; color: var(--muted); }

.auth-error {
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  font-size: 13.5px;
  text-align: left;
}

.btn-primary {
  width: 100%;
  height: 48px;
  margin-top: 16px;
  border: 0;
  border-radius: 12px;
  background: var(--tint);
  color: var(--tint-text);
  font-weight: 600;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--tint) 30%, transparent);
}

/* Small text buttons: Forgot password?, Change number, Resend OTP */
.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--tint);
  font-size: 13.5px;
  font-weight: 600;
}
.link-btn:disabled { color: var(--muted); cursor: default; }
.forgot-btn { justify-self: end; margin-top: -2px; }

/* OTP step */
.otp-info { margin: 0 0 6px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
/* 4 boxes: the real input lies invisibly on top, the boxes underneath show its digits */
.otp-boxes { position: relative; }
.otp-cells { display: grid; grid-template-columns: repeat(4, 56px); justify-content: center; gap: 12px; }
.otp-cells span {
  display: grid;
  place-items: center;
  height: 58px;
  border: 1px solid var(--separator);
  border-radius: 12px;
  background: var(--fill);
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.otp-cells span.filled { background: var(--surface); }
.otp-cells span.active { border-color: var(--tint); background: var(--surface); box-shadow: 0 0 0 3px var(--select); }
.field .otp-boxes input.otp-input {
  position: absolute;
  inset: 0;
  z-index: 1;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  caret-color: transparent;
  font-size: 16px; /* under 16px iOS zooms in */
}
.field .otp-boxes input.otp-input::selection { background: transparent; }
.otp-row { display: flex; justify-content: space-between; align-items: center; }

/* Profile: phone number with a Change button beside it */
.phone-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.phone-line .btn-secondary { height: 44px; padding: 0 16px; }

.auth-switch { margin: 22px 0 0; font-size: 13.5px; color: var(--muted); }
.auth-switch button { padding: 0 2px; border: 0; background: none; color: var(--tint); font-weight: 700; }

@media (max-width: 380px) {
  .auth-card { padding: 30px 22px 26px; border-radius: 24px; }
}
/* iOS zooms into inputs under 16px â€” keep auth inputs at 16px on phones */
@media (max-width: 899px) {
  .field input, .field select { font-size: 16px; }
}
.btn-primary:active { opacity: .8; }
.btn-primary:disabled { opacity: .5; cursor: progress; }

/* ---------- Toast & offline ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(66px + env(safe-area-inset-bottom));
  z-index: 70; /* above the menu panel */
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(30, 30, 32, .92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
  font-size: 15px;
  transform: translateX(-50%);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  animation: toast-in .3s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.toast button { padding: 0; border: 0; background: transparent; color: #64b5ff; font-weight: 600; }

.offline-bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* Thin, unobtrusive scrollbars on desktop */
@media (hover: hover) {
  .list, .editor-scroll { scrollbar-width: thin; scrollbar-color: var(--separator) transparent; }
}

/* Back to the titles list — only used on phones */
.back-btn {
  display: none;
  align-items: center;
  height: 40px;
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--tint);
  font-size: 16px;
  font-weight: 600;
}
.back-btn svg { width: 24px; height: 24px; stroke-width: 2.4; }
.back-btn:active { opacity: .5; }

/* ---------- Phones: one screen at a time (titles list, or one note full screen) ---------- */

@keyframes note-in { from { opacity: 0; transform: translateX(24%); } }

@media (max-width: 699px) {
  :root { --row-h: 40px; }
  /* Ruled lines of a note: a bit closer on phones (iPhone and Android alike). The iPhone's text
     cursor is as tall as the whole line, so a shorter line keeps it from reaching up into the
     line above as much. */
  .sheet { --lh: 34px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .editor { grid-column: 1; grid-row: 2; }
  .sidebar { border-right: 0; }
  .editor { display: none; }
  .app.show-note .sidebar { display: none; }
  .app.show-note .editor { display: flex; animation: note-in .3s var(--ease); }
  .back-btn { display: flex; }

  .nav { padding-left: 12px; padding-right: 12px; }
  .search input { font-size: 16px; }

  .list { padding: 0 12px 16px; }
  #groups { gap: 8px; }
  .row { padding: 0 12px; gap: 6px; font-size: 15px; }

  .editor-bar { min-height: 48px; padding: 4px 4px 4px 6px; }
  .editor-meta { display: none; }
  .edit-btn { height: 34px; margin-left: 0; padding: 0 12px; }

  .sheet { padding: 2px 8px 0; }
  .sec-label { padding: 0 8px; border-radius: 9px; font-size: 14px; }
  .sec-date { font-size: 10.5px; }
  .note-title { margin-top: 8px; padding: 0 6px; font-size: 16px; }
  .title-count { margin-bottom: 8px; font-size: 11px; }
  .note-body { padding: 2px 6px 0; font-size: 16px; }
  .editor-empty img { width: 48px; height: 48px; }
  .editor-empty p { padding: 0 12px; text-align: center; font-size: 14px; }
}

/* ---------- Account menu panel (☰): side panel on PC, bottom sheet on phones ---------- */

.panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, .32);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes panel-in { from { transform: translateX(100%); } }
@keyframes sheet-in { from { transform: translateY(100%); } }

.panel {
  width: min(380px, 100%);
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top) + 18px) 20px calc(env(safe-area-inset-bottom) + 20px);
  background: var(--bg);
  box-shadow: -10px 0 34px rgba(0, 0, 0, .16);
  animation: panel-in .32s var(--ease);
}

@media (max-width: 699px) {
  .panel-overlay { align-items: flex-end; }
  .panel {
    width: 100%;
    height: auto;
    max-height: 90dvh;
    padding-top: 10px;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 34px rgba(0, 0, 0, .16);
    animation-name: sheet-in;
  }
  .panel::before {
    content: "";
    display: block;
    width: 36px;
    height: 5px;
    margin: 0 auto 14px;
    border-radius: 3px;
    background: var(--separator);
  }
}

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 700; }

.round-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text);
}
.round-btn svg { width: 18px; height: 18px; stroke-width: 2.2; }

.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 16px; font-weight: 700; color: var(--tint); }
.user-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.big { width: 64px; height: 64px; font-size: 22px; }

.menu-list { display: grid; gap: 9px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--separator);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .05);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  transition: transform .15s ease, box-shadow .15s ease;
}
.menu-item:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(0, 0, 0, .1), 0 2px 4px rgba(0, 0, 0, .06); }
.menu-item > svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.menu-item > span { flex: 1; }
.menu-item .go { width: 16px; height: 16px; }
.menu-item.danger, .menu-item.danger > svg { color: var(--danger); }
.menu-item.static { align-items: flex-start; cursor: default; }
.menu-item.static:hover { transform: none; box-shadow: 0 2px 6px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .05); }
.help-title { font-size: 14px; font-weight: 700; }
.help-text { margin-top: 3px; font-size: 13px; font-weight: 400; line-height: 1.5; color: var(--muted); }

.panel-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.panel-foot img { border-radius: 8px; }

.profile-top { display: flex; justify-content: center; margin-bottom: 18px; }
.panel .field input:disabled { opacity: .55; }
.panel .btn-primary { margin-top: 6px; }
.panel-text { margin: 0 0 16px; font-size: 14px; line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.danger-zone { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--separator); }
.zone-label { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.btn-danger {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}
.btn-danger:disabled, .btn-secondary:disabled { opacity: .5; cursor: progress; }

.bin-book {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -6px 0 10px;
  font-weight: 700;
  color: var(--tint);
}
.bin-book svg { width: 18px; height: 18px; flex: none; }
.bin-book span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bin-card {
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid var(--separator);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .05);
}
.bin-title { font-weight: 700; overflow-wrap: anywhere; }
.bin-meta { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.bin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.bin-actions button { height: 38px; font-size: 13.5px; }
.bin-empty { display: grid; justify-items: center; gap: 6px; padding: 30px 10px; text-align: center; }
.bin-empty svg { width: 40px; height: 40px; color: var(--muted); }
.bin-empty h3 { margin: 6px 0 0; font-size: 16px; }
.bin-empty p { margin: 0; font-size: 13.5px; }

.about { text-align: center; }
.about img { border-radius: 16px; box-shadow: 0 8px 20px rgba(0, 113, 227, .3); }
.about h3 { margin: 12px 0 2px; font-size: 19px; font-weight: 800; }
.about p { margin: 0 0 14px; }
.about-text { font-size: 14px; line-height: 1.6; text-align: left; color: var(--muted); }

/* ---------- Search row: search + filter + PDF ---------- */

.search-row { position: relative; display: flex; align-items: center; gap: 8px; }
.search-row .search { flex: 1; min-width: 0; }
.icon-tool {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: var(--fill);
  color: var(--tint);
}
.icon-tool svg { width: 19px; height: 19px; }
.icon-tool:active { opacity: .6; }
.icon-tool.on { background: var(--tint); color: var(--tint-text); }
.filter-menu { width: 200px; }
.filter-menu svg { visibility: hidden; color: var(--tint); stroke-width: 2.6; }
.filter-menu [aria-checked="true"] { color: var(--tint); font-weight: 600; }
.filter-menu [aria-checked="true"] svg { visibility: visible; }

/* "Completed" badge on an open note */
.status-badge {
  margin-left: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, #34c759 18%, transparent);
  color: #1f8f3f;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
:root[data-theme="dark"] .status-badge { color: #30d158; }

/* ---------- PDF (print) ---------- */

#printArea { display: none; }
@media print {
  /* No page margin: that is where browsers print their own date, page title, address and page
     numbers. The white space comes from #printArea's sides and the repeated table header/footer. */
  @page { margin: 0; }
  html, body { overflow: visible !important; height: auto !important; background: #fff !important; color: #000 !important; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; padding: 0 14mm; font: 12pt/1.5 -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif; }
  .print-page { width: 100%; border-collapse: collapse; }
  .print-page td { padding: 0; vertical-align: top; }
  .print-gap { height: 16mm; }
  .print-head { margin-bottom: 14pt; padding-bottom: 8pt; border-bottom: 2px solid #0071e3; }
  .print-head h1 { margin: 0; font-size: 18pt; }
  .print-head p { margin: 2pt 0 0; color: #555; font-size: 10pt; }
  .print-list { margin: 0; padding: 0; list-style: none; }
  .print-list li { display: flex; gap: 8pt; padding: 6pt 2pt; border-bottom: 1px solid #ddd; break-inside: avoid; font-size: 12.5pt; }
  .print-list .num { min-width: 2.2em; font-weight: 700; font-variant-numeric: tabular-nums; }
  .print-list .t { overflow-wrap: anywhere; }
  .print-head .book { margin: 0 0 2pt; color: #0071e3; font-size: 10pt; font-weight: 700; }
  /* Ruled like the app: every line of text sits on a light blue line. Each line is its own block
     (.pl) with its own lines drawn from its own top, so the lines can't drift off the text when a
     page breaks. print-color-adjust: exact prints them even with "Background graphics" off. */
  .print-body { --lh: 26pt; padding: 0 4pt; font-size: 12pt; }
  .pl {
    min-height: var(--lh);
    line-height: var(--lh);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    break-inside: avoid;
    background-image: linear-gradient(to bottom, transparent calc(var(--lh) - 1.2pt), #9cc3ef calc(var(--lh) - 1.2pt));
    background-size: 100% var(--lh);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
