:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1a1d27;
  --muted: #7a7f8e;
  --accent: #3b6ef5;
  --danger: #d64545;
  --border: #e2e4ec;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1d27;
    --card: #242836;
    --text: #eceef4;
    --muted: #8b90a0;
    --accent: #6b93ff;
    --danger: #ff7070;
    --border: #333849;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.screen { min-height: 100dvh; display: flex; flex-direction: column; }
/* hidden属性はUA標準のdisplay:noneで効くが、上のdisplay:flexが勝ってしまうため明示上書きが必要 */
.screen[hidden] { display: none; }

/* --- ゲート（設定・解除）画面 --- */
.gate { justify-content: center; align-items: center; padding: 24px; }
.gate-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.gate-box h1 { font-size: 22px; text-align: center; margin: 0 0 8px; }

input[type="password"], input[type="text"], input[type="search"] {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
}

button {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.danger { background: transparent; color: var(--danger); }
button:disabled { opacity: .6; }

.note { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0; }
.center { text-align: center; padding: 32px 16px; }
.error { color: var(--danger); font-size: 14px; text-align: center; margin: 0; }
.check { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
button.linklike { background: transparent; color: var(--accent); font-size: 13px; padding: 4px; }

/* --- 一覧画面 --- */
.topbar {
  display: flex; gap: 8px; align-items: center;
  padding: 12px;
  position: sticky; top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar input[type="search"] { flex: 1; }
.spacer { flex: 1; }

#memo-list { list-style: none; margin: 0; padding: 8px 12px 96px; }
#memo-list li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.memo-title { font-weight: 600; font-size: 15px; }
.memo-snippet { color: var(--muted); font-size: 13px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memo-date { color: var(--muted); font-size: 11px; margin-top: 4px; }

.fab {
  position: fixed; right: 20px; bottom: 24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 28px; line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

#toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  z-index: 10;
  max-width: 80vw;
}

/* --- 編集画面 --- */
#screen-edit { padding-bottom: 8px; }
#edit-title { margin: 12px 12px 0; font-weight: 600; }
#edit-body {
  flex: 1;
  margin: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  line-height: 1.7;
  resize: none;
  min-height: 55dvh;
}
