:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --border: #dcdcd8;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --danger: #b42318;
  --hover: #f0f0ec;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --surface: #1f1f22;
    --text: #ececee;
    --muted: #9a9aa2;
    --border: #34343a;
    --accent: #6d8ff0;
    --accent-text: #0e0e10;
    --danger: #ff7b6e;
    --hover: #28282c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

[hidden] { display: none !important; }

h1 { font-size: 1.5rem; margin: 0; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

button {
  font: inherit;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover { background: var(--hover); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
button.primary:hover { filter: brightness(1.08); }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search { margin-bottom: 16px; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 0;
}

.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.note-list:empty { display: none; }

.note {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
}
.note:first-child { border-top: 0; }

.note-open {
  flex: 1;
  min-width: 0; /* lets text truncate inside flex */
  text-align: left;
  border: 0;
  border-radius: 0;
  padding: 12px 16px;
  background: transparent;
}
.note-title,
.note-preview {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-title { font-weight: 600; }
.note-preview { color: var(--muted); font-size: 0.925rem; min-height: 1.4em; }

.note-delete {
  margin-right: 12px;
  padding: 6px 12px;
  font-size: 0.875rem;
  color: var(--danger);
  background: transparent;
}

form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
form h1 { margin-bottom: 16px; }

.field { margin-bottom: 16px; }
.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
label { font-weight: 600; }
.optional { font-weight: 400; color: var(--muted); }
.counter { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.counter.full { color: var(--danger); }

input, textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
textarea { resize: vertical; }
input[aria-invalid="true"] { border-color: var(--danger); }

.error { color: var(--danger); margin: 0 0 16px; }

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
