:root {
  color-scheme: light dark;
  --fg: #1a1a1a;
  --bg: #ffffff;
  --muted: #666;
  --border: #ddd;
  --accent: #2563eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e5e5e5;
    --bg: #121212;
    --muted: #999;
    --border: #333;
    --accent: #60a5fa;
  }
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  color: var(--fg);
  background: var(--bg);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

header h1 { font-size: 1.25rem; margin: 0; }
header a { color: var(--fg); text-decoration: none; }

.login-main {
  max-width: 320px;
  margin: 4rem auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-main h1 { margin: 0; }
.login-main .button { align-self: center; }

.button {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
}

.layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.sidebar {
  flex: 0 0 180px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1rem;
}

.layout main { flex: 1 1 auto; min-width: 0; }

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.main-nav a {
  color: var(--fg);
  text-decoration: none;
  padding: 0.2rem 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.main-nav a:hover { color: var(--accent); }

.nav-action {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}

.nav-action:hover { color: var(--accent); }

/* A minor action styled like .nav-action but for a <button> element (e.g.
   "Expand All") — resets the generic button rule's background/border/
   padding, which would otherwise fight with .nav-action's own styling. */
.link-button {
  display: inline-block;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  align-self: auto;
}

.link-button:hover { color: var(--accent); }

.filter-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-form .clear {
  font-size: 0.8rem;
  color: var(--muted);
}

.sort-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
}

.sort-toggle a {
  color: var(--muted);
  text-decoration: none;
}

.sort-toggle a.active {
  color: var(--fg);
  font-weight: 600;
}

@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    position: static;
    width: 100%;
  }
  .main-nav { flex-direction: row; gap: 1rem; }
  .filter-form { flex: 1 1 100%; flex-direction: row; order: 1; }
  .filter-form input[type="search"] { flex: 1 1 auto; }
}

.feed { list-style: none; padding: 0; margin: 0; }

/* Collapsed by default (title/date/kind only, no line between records — a
   high-density list). Expanding a record (click its title, or "Expand
   All") reveals .item-full and adds top/bottom borders that visually
   bound just that record. */
.item { padding: 0; }

/* Title on its own line (full width), date/kind on a subtitle line
   underneath — in both the collapsed and expanded states, since
   .item-summary itself is never hidden, only .item-full is. */
.item-summary {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.25rem 0;
}

.item-summary .item-title { cursor: pointer; }

.item-kind {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

.item-full { display: none; padding: 0 0 0.6rem; }

.item.expanded {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0;
}

/* Two adjacent expanded records would otherwise show a double line where
   they meet (this item's top border right next to the previous item's
   bottom border) — drop this one so the shared boundary stays a single
   line. */
.item.expanded + .item.expanded {
  border-top: none;
}

.item.expanded .item-full { display: block; margin-top: 0.35rem; }

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0;
}

.page-toolbar .page-info { margin: 0; }

.item-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.item-title {
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}

.item-title:hover { color: var(--accent); }

/* Highlights a title for items where model.IsMyNote is true (text starts
   with "[me]"). Fixed colors rather than theme variables — a highlighter
   effect should look the same in light and dark mode, and dark text is
   needed on the yellow regardless of theme for contrast. */
.my-note {
  background: #fde68a;
  color: #1a1a1a;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
}

.button-small {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.button-small:hover { color: var(--accent); border-color: var(--accent); }

.item-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.15rem 0 0.4rem;
}

.item-text { margin: 0.25rem 0; white-space: pre-wrap; }

.item-links { margin: 0.25rem 0; padding-left: 1.1rem; }

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

.page-info { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0; }

.page-sidebar {
  flex: 0 0 3rem;
  margin-left: 1rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.page-links {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
}

.page-links a {
  color: var(--muted);
  text-decoration: none;
  text-align: right;
  padding: 0.1rem 0.3rem;
}

.page-links a:hover { color: var(--accent); }

.page-links a.active {
  color: var(--fg);
  font-weight: 700;
}

@media (max-width: 640px) {
  .page-sidebar { display: none; }
}

form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 480px; }

textarea, input[type="text"], input[type="search"] {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}

.attachments {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.attachment img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 6px;
  display: block;
}

.attachment-audio { flex-basis: 100%; }
.attachment audio { width: 100%; max-width: 360px; }

.attachment-video { flex-basis: 100%; }
.attachment video { max-width: 100%; border-radius: 6px; }

.attachment-file a {
  display: inline-block;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.1s ease;
}

.drop-zone.drag-active {
  border-color: var(--accent);
}

.drop-zone textarea { border: none; padding: 0.25rem; }
.drop-zone textarea:focus { outline: none; }

.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-entry {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  max-width: 220px;
}

.file-entry img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
}

.file-entry-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-entry-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.file-picker {
  align-self: flex-start;
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  padding: 0.3rem 0;
}

button {
  font: inherit;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  align-self: flex-start;
}

.button-row { display: flex; gap: 0.5rem; }

.error { color: #dc2626; }

.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.25rem; }

.edit-attachments { margin-top: 1.5rem; }

.delete-form { margin-top: 2rem; }

.button-danger {
  background: none;
  border: 1px solid #dc2626;
  color: #dc2626;
}

.button-danger:hover { background: #dc2626; color: white; }
