/* Lockbox — dark by default, because this is a thing you use at night. */

:root {
  --bg: #14161a;
  --bg-raised: #1b1e24;
  --bg-sunken: #101215;
  --line: #2a2f38;
  --line-soft: #22262d;
  --text: #e6e8ec;
  --text-dim: #99a1ae;
  --text-faint: #6b7280;
  --accent: #7aa2f7;
  --accent-ink: #0d1117;
  --danger: #f7768e;
  --ok: #9ece6a;
  --radius: 10px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-read: ui-serif, Georgia, "Iowan Old Style", serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfbfa;
    --bg-raised: #ffffff;
    --bg-sunken: #f2f2f0;
    --line: #dcdcd8;
    --line-soft: #e8e8e5;
    --text: #1c1e21;
    --text-dim: #5c6370;
    --text-faint: #8b929e;
    --accent: #3a5ccc;
    --accent-ink: #ffffff;
    --danger: #c0334d;
    --ok: #3f7d2f;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button, input, textarea, select { font: inherit; color: inherit; }

.grow { flex: 1; }
.muted { color: var(--text-dim); }
.danger-text { color: var(--danger); }
[hidden] { display: none !important; }

/* ---------- screens ---------- */

.screen { height: 100%; }

.screen--center {
  display: grid;
  place-items: center;
  padding: var(--gutter);
}

/* ---------- gates (setup / unlock) ---------- */

.gate {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logo {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 0 14px;
  color: var(--text-dim);
}

.gate label {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
}

.gate input[type="password"],
.gate input[type="text"],
.dlg input[type="password"],
.dlg input[type="text"],
.dlg input[type="file"] {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

.gate input:focus-visible,
.dlg input:focus-visible,
#search:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 12px 0 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dim);
}

.check input { margin-top: 3px; flex: none; }

.strength {
  font-size: 12px;
  min-height: 16px;
  color: var(--text-faint);
}

.strength[data-level="weak"] { color: var(--danger); }
.strength[data-level="fair"] { color: #e0af68; }
.strength[data-level="strong"] { color: var(--ok); }

.error {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--danger);
}

.fineprint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

/* ---------- buttons ---------- */

button {
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 14px;
  background: transparent;
  transition: background 120ms ease, border-color 120ms ease;
}

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

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  margin-top: 10px;
}

.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.compact { margin-top: 0; padding: 8px 12px; }

.ghost {
  border-color: var(--line);
  color: var(--text-dim);
  padding: 7px 11px;
  font-size: 13px;
}

.ghost:hover { background: var(--bg-raised); color: var(--text); }

.danger {
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}

.linky {
  background: none;
  border: none;
  padding: 8px 0 0;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

#screen-app {
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  flex: none;
}

.brand { font-weight: 600; letter-spacing: -0.01em; }

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 0;
}

/* ---------- sidebar ---------- */

.sidebar {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-sunken);
}

.sidebar-head {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}

#search {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

.note-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}

.note-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
}

.note-item:hover { background: var(--bg-raised); }

.note-item[aria-current="true"] {
  background: var(--bg-raised);
  border-color: var(--line);
}

.note-item h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
}

.note-item .clip { margin-left: 4px; }

.list-empty { padding: 20px; text-align: center; font-size: 13px; }

/* ---------- editor ---------- */

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

.editor-blank { display: grid; place-items: center; height: 100%; }

.editor-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px var(--gutter);
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}

.savestate { font-size: 12px; color: var(--text-faint); }
.savestate[data-state="saved"] { color: var(--ok); }

.note-title {
  border: none;
  background: none;
  outline: none;
  padding: 20px var(--gutter) 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex: none;
}

.note-body {
  flex: 1;
  min-height: 140px;
  border: none;
  background: none;
  outline: none;
  resize: none;
  padding: 6px var(--gutter);
  font-family: var(--font-read);
  font-size: 16.5px;
  line-height: 1.65;
}

.note-title::placeholder, .note-body::placeholder { color: var(--text-faint); }

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 var(--gutter);
  flex: none;
}

.thumbs:not(:empty) { padding-top: 12px; }

.thumb {
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.thumb-drop {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: 15px;
}

.meta {
  padding: 14px var(--gutter);
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  font-size: 12px;
  flex: none;
}

/* ---------- dialogs ---------- */

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-raised);
  color: var(--text);
  padding: 0;
  width: min(420px, calc(100vw - 32px));
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

.dlg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
}

.dlg h2 { margin: 0; font-size: 18px; }
.dlg p { margin: 0 0 6px; font-size: 13.5px; line-height: 1.5; }
.dlg label { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.dlg-actions button { margin-top: 0; }

.dlg-image {
  width: min(92vw, 1000px);
  background: var(--bg-sunken);
  padding: 10px;
}

.dlg-image img {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.img-close { margin-bottom: 8px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(460px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  font-size: 13.5px;
  z-index: 50;
}

.toast[data-kind="error"] { border-color: var(--danger); color: var(--danger); }
.toast[data-kind="ok"] { border-color: var(--ok); }

/* ---------- narrow ---------- */

.only-narrow { display: none; }

@media (max-width: 720px) {
  .workspace { grid-template-columns: 1fr; }
  .only-narrow { display: inline-block; }

  /* One pane at a time on a phone; the editor takes over when a note is open. */
  .workspace[data-view="editor"] .sidebar { display: none; }
  .workspace[data-view="list"] .editor { display: none; }

  .note-title { font-size: 21px; padding-top: 14px; }
  .note-body { font-size: 16px; }
}

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

/* ---------- support ---------- */

.support {
  flex: none;
  padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  gap: 6px;
  align-items: center;
}

.support a {
  color: var(--text-faint);
  text-decoration: none;
}

.support a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dlg-section {
  margin: 14px 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.dlg-section:first-of-type { margin-top: 6px; }

#storage-status[data-state="at-risk"] { color: #e0af68; }
#storage-status[data-state="safe"] { color: var(--ok); }
