/* Memos. A warm notepad look, distinct from the green of Mike's landlording
   apps so the two families never get confused on the home screen. */

:root {
  --bg: #fbf8f1;
  --surface: #ffffff;
  --ink: #2a2620;
  --ink-soft: #6b6255;
  --ink-faint: #9a9080;
  --line: #e8e1d3;
  --accent: #a86a12;
  --accent-ink: #ffffff;
  --accent-soft: #f6ead3;
  --mark: #ffe28a;
  --danger: #b3261e;
  --ok: #2e7d4f;
  --warn: #9a6200;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a17;
    --surface: #25231f;
    --ink: #ece6da;
    --ink-soft: #b5ab9a;
    --ink-faint: #857c6e;
    --line: #38342d;
    --accent: #e0a040;
    --accent-ink: #1b1a17;
    --accent-soft: #3a2f1c;
    --mark: #6b5510;
    --danger: #ff8a80;
    --ok: #7bd29c;
    --warn: #f0c060;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--font);
}
a { color: var(--accent); }
[hidden] { display: none !important; }

/* --- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 22px; }
.brand img { border-radius: 6px; }
.topbar-title { margin: 0; font-size: 18px; }
.back { text-decoration: none; font-size: 17px; padding: 6px 0; white-space: nowrap; }

.page { max-width: 760px; margin: 0 auto; padding: 12px 16px 40px; }

/* --- Buttons & inputs --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
form.inline { display: inline; }

.text-input, .search-input, .sort-select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.text-input:focus, .search-input:focus, .sort-select:focus,
.title-input:focus, .body-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.text-input.small { font-size: 15px; min-height: 38px; padding: 6px 10px; }

/* --- List page ----------------------------------------------------------- */
.searchbar { display: flex; gap: 8px; margin: 4px 0 10px; }
.search-input { flex: 1; min-width: 0; font-size: 17px; }
.sort-select { flex: 0 0 auto; max-width: 42%; font-size: 15px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; }
.chip {
  flex: 0 0 auto; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); font-size: 14px; text-decoration: none;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.chip-n { color: var(--ink-faint); font-weight: 400; }

.result-count { margin: 2px 2px 8px; color: var(--ink-faint); font-size: 14px; }
.memo-list { list-style: none; margin: 0; padding: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.memo-list li + li { border-top: 1px solid var(--line); }
.memo-row { display: block; padding: 12px 14px; color: inherit; text-decoration: none; }
.memo-row:hover, .memo-row:focus-visible { background: var(--accent-soft); }
.row-top { display: flex; align-items: baseline; gap: 10px; }
.row-title { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-date { flex: 0 0 auto; color: var(--ink-faint); font-size: 13px; }
.row-snippet { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-top: 2px; color: var(--ink-soft); font-size: 15px; line-height: 1.4; }
.row-cat { display: inline-block; margin-top: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--ink-soft); font-size: 12px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.more-wrap { text-align: center; margin: 14px 0; }
.empty { color: var(--ink-soft); text-align: center; padding: 30px 10px; }
.hint { color: var(--ink-soft); font-size: 15px; }
.page-foot { display: flex; justify-content: space-between; margin-top: 22px; font-size: 15px; color: var(--ink-soft); }

/* --- Editor -------------------------------------------------------------- */
.save-state { flex: 1; text-align: center; font-size: 13px; color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state.ok { color: var(--ok); }
.save-state.bad { color: var(--danger); white-space: normal; }
.save-state.warn { color: var(--warn); white-space: normal; }

.title-input {
  display: block; width: 100%; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 24px; font-weight: 700; line-height: 1.25;
  padding: 6px 2px; border-radius: 6px; resize: none; overflow: hidden;
}
.memo-meta { margin: 0 2px 10px; color: var(--ink-faint); font-size: 13px; }
.meta-sep { margin: 0 6px; }
.body-input {
  display: block; width: 100%; min-height: 240px; resize: none; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 17px; line-height: 1.55; padding: 14px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.cat-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--ink-soft); font-size: 15px; }
.cat-row .text-input { flex: 1; max-width: 320px; }

.banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 4px 0 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid var(--accent); font-size: 15px;
}
.banner-actions { display: flex; gap: 8px; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 6px; display: grid; gap: 2px;
}
.menu-panel a, .menu-panel button {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  background: none; border: 0; font: inherit; font-size: 15px; color: var(--ink); text-decoration: none; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--accent-soft); }
.menu-panel .danger { color: var(--danger); }

/* --- History ------------------------------------------------------------- */
.history-title { font-size: 20px; margin: 6px 0; }
.version { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin: 12px 0; }
.version-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  color: var(--ink-soft); font-size: 14px; }
.version-titleline { margin: 8px 0 0; font-weight: 600; }
.version-body { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 15px;
  margin: 8px 0 0; max-height: 320px; overflow: auto; color: var(--ink); }

/* --- Sign-in ------------------------------------------------------------- */
.login { max-width: 360px; margin: 0 auto; padding: 60px 20px; text-align: center; }
.login-icon { border-radius: 16px; }
.login h1 { margin: 12px 0 24px; }
.login form { text-align: left; display: grid; gap: 10px; }
.field-label { font-size: 14px; color: var(--ink-soft); }
.trust-row { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink-soft); }
.error-line { color: var(--danger); margin: 0; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .brand { font-size: 20px; }
  .title-input { font-size: 21px; }
  .page { padding: 10px 12px 40px; }
}
