:root {
  color-scheme: light;
  --paper: #fffaf0;
  --paper-2: #f8f5ee;
  --ink: #2b241d;
  --muted: #6e6257;
  --line: #d8d0c4;
  --accent: #7d3f24;
  --accent-2: #5c2e1a;
  --danger: #a43b32;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  position: sticky;
  top: 0;
  z-index: 2;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.1rem;
}
h2 {
  font-size: 1.1rem;
  margin-bottom: 0.6rem;
}
a {
  color: var(--accent);
}

.app-shell {
  width: min(52rem, 100%);
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.login-card {
  width: min(24rem, calc(100% - 2rem));
  margin: 12vh auto;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--paper-2);
}

.stack {
  display: grid;
  gap: 0.8rem;
}

.composer,
.search-panel,
.note-card {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.42);
}

textarea,
input[type="search"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.7rem;
  background: #fffefa;
  color: var(--ink);
}

textarea {
  min-height: 14rem;
  resize: vertical;
}

button {
  border: 1px solid var(--accent-2);
  border-radius: 0.5rem;
  padding: 0.65rem 0.9rem;
  background: var(--accent);
  color: #fffaf0;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--accent-2);
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

button.small {
  padding: 0.3rem 0.55rem;
  font-size: 0.9rem;
}

.actions,
.search-row {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.actions.compact {
  margin-top: 0.5rem;
}

.search-row input {
  flex: 1;
}

.note-list {
  display: grid;
  gap: 0.75rem;
}

.note-card header {
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.45rem;
  margin-bottom: 0.65rem;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: end;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  background: var(--paper-2);
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1rem 0 0.35rem;
}

.markdown-body p:last-child,
.markdown-body ul:last-child,
.note-card:last-child {
  margin-bottom: 0;
}

pre {
  overflow-x: auto;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--paper-2);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.94em;
}

.muted,
.hint,
.empty {
  color: var(--muted);
}

.hint {
  margin-bottom: 0;
  font-size: 0.95rem;
}
.error {
  color: var(--danger);
}

@media (max-width: 42rem) {
  .topbar {
    align-items: center;
  }
  .actions,
  .search-row {
    flex-direction: column;
  }
  button:not(.small) {
    width: 100%;
  }
  .note-card header {
    align-items: start;
    flex-direction: column;
  }
  .note-actions {
    justify-content: start;
  }
  textarea {
    min-height: 45vh;
  }
}
