:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --panel: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --danger: #dc2626;
  --border: #e5e7eb;
  --code-bg: #f1f3f5;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --fg: #e9eaee;
    --muted: #8a8f9a;
    --accent: #7aa2f7;
    --accent-fg: #0b0d12;
    --danger: #f7768e;
    --border: #2a2e36;
    --code-bg: #0b0d12;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-size: 17px;
  line-height: 1.45;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.topbar nav button[type="submit"] {
  padding: 6px 14px;
  font-size: 15px;
  border-radius: 8px;
}

button {
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
button.linkish {
  background: none;
  color: var(--muted);
  padding: 0;
  font-weight: 400;
  font-size: 15px;
}
button.linkish.danger { color: var(--danger); }

.page-compose { display: flex; flex-direction: column; }
.compose {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}
.compose form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.compose textarea {
  flex: 1;
  width: 100%;
  min-height: 50vh;
  resize: none;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font: inherit;
  font-size: 17px;
  line-height: 1.5;
}
.compose textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.compose .hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.list { padding: 12px 16px 40px; max-width: 760px; margin: 0 auto; }
.note {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.note .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.note .meta .grow { flex: 1; }
.note .meta a { color: var(--muted); text-decoration: none; }
.note .meta a:hover { color: var(--fg); }
.note .edited { font-style: italic; }
.note .body { word-wrap: break-word; }
.note .body p:first-child { margin-top: 0; }
.note .body p:last-child { margin-bottom: 0; }
.note .body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
}
.note .body code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
.note .body pre code { background: transparent; padding: 0; }

.empty { color: var(--muted); text-align: center; margin-top: 30px; }

.login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.login h1 { margin: 0 0 8px; font-size: 22px; text-align: center; }
.login input {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
}
.login .error { color: var(--danger); font-size: 14px; margin: 0; text-align: center; }
