:root {
  color-scheme: light dark;
  --bg: #f4f3ef;
  --panel: #ffffff;
  --side: #e9e7e0;
  --fg: #1c1c1a;
  --dim: #71716c;
  --border: #d8d6cf;
  --accent: #3468a8;
  --accent-fg: #ffffff;
  --danger: #b03030;
  --mine: #e8f0fa;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191a1c;
    --panel: #222327;
    --side: #131416;
    --fg: #e6e5e1;
    --dim: #8f8f89;
    --border: #35363b;
    --accent: #6fa3dd;
    --accent-fg: #10151c;
    --mine: #253243;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, system-ui, sans-serif;
  background: var(--bg); color: var(--fg);
}

.shell { display: flex; min-height: 100vh; }

/* sidebar is always dark, whatever the system theme */
aside {
  --sb-fg: #d6d6d0;
  --sb-dim: #85857f;
  width: 220px; flex-shrink: 0;
  background: #141518; color: var(--sb-fg);
  padding: 1rem .9rem;
  display: flex; flex-direction: column; gap: 1.1rem;
}
.brand {
  font-weight: 800; font-size: 1.35rem; letter-spacing: -.01em;
  color: #fff; text-decoration: none; padding: 0 .4rem .2rem;
}
aside nav { display: flex; flex-direction: column; gap: 1px; }
.navrow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 .4rem .3rem;
}
.navhead {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--sb-dim);
}
a.plus, button.plus {
  display: flex; align-items: center; justify-content: center;
  width: 1.35rem; height: 1.35rem; border-radius: 6px;
  background: rgba(255,255,255,.09); color: var(--sb-fg);
  text-decoration: none; font-size: 1rem; line-height: 1;
  border: 0; cursor: pointer; padding: 0; font-family: inherit;
}
a.plus:hover, button.plus:hover, a.plus[data-active] { background: var(--accent); color: var(--accent-fg); }
aside nav a:not(.plus) {
  color: var(--sb-fg); text-decoration: none;
  padding: .3rem .45rem; border-radius: 6px;
  display: flex; align-items: center; gap: .4rem;
}
.navlabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot {
  width: .5rem; height: .5rem; border-radius: 50%; flex-shrink: 0;
  background: #e8a33d; margin-left: auto;
}
/* a dot carrying an unread count grows into a badge */
.dot:not(:empty) {
  width: auto; min-width: 1.15rem; height: 1.15rem; border-radius: .6rem;
  padding: 0 .3rem; display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #241a05;
}
.dot.inline { display: inline-block; margin-left: .3rem; vertical-align: middle; }
.dot.inline:not(:empty) { display: inline-flex; }
aside nav a:not(.plus):hover { background: rgba(255,255,255,.08); }
aside nav a:not(.plus).active { background: var(--accent); color: var(--accent-fg); }
.sidefoot {
  margin-top: auto; padding-top: .8rem; border-top: 1px solid rgba(255,255,255,.1);
  display: flex; flex-direction: column; gap: .55rem;
}
/* settings dropdown lives in the sidebar footer and opens upward */
details.menu { position: relative; }
details.menu summary {
  cursor: pointer; list-style: none; user-select: none;
  color: var(--sb-dim); padding: 0 .4rem; font-size: .88rem;
}
details.menu summary::-webkit-details-marker { display: none; }
details.menu summary::after { content: " ▾"; font-size: .75em; }
details.menu[open] summary { color: var(--sb-fg); }
.menupanel {
  position: absolute; left: 0; bottom: calc(100% + .5rem); z-index: 10;
  min-width: 11.5rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  display: flex; flex-direction: column; padding: .35rem;
}
.menupanel a, .menupanel button {
  text-align: left; padding: .4rem .6rem; border-radius: 6px;
  color: var(--fg); text-decoration: none; background: none; border: none;
  font: inherit; cursor: pointer;
}
.menupanel a:hover, .menupanel button:hover {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
}
.menupanel button.danger { color: var(--danger); font-size: inherit; }
button.logout {
  width: 100%; text-align: center;
  background: rgba(255,255,255,.09); color: var(--sb-fg);
  border-radius: 7px; padding: .45rem .6rem;
}
button.logout:hover { background: rgba(255,255,255,.16); }

main { flex: 1; padding: 1.4rem 2rem 3rem; max-width: 46rem; min-width: 0; }
main.solo { margin: 6vh auto 0; flex: initial; width: min(24rem, 92vw); padding: 0 1rem; }

h1 { font-size: 1.25rem; margin: 0 0 1rem; }
h2 { font-size: 1rem; margin: 1.8rem 0 .6rem; }
a { color: var(--accent); }
p { margin: .4rem 0; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .45rem 0; border-bottom: 1px solid var(--border); }

.stack { display: flex; flex-direction: column; gap: .6rem; max-width: 24rem; }
.stack label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--dim); }
label.check { flex-direction: row; align-items: center; gap: .45rem; color: var(--fg); }
input:not([type=checkbox]), textarea {
  font: inherit; color: var(--fg); background: var(--panel);
  padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 7px;
  width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
button {
  font: inherit; padding: .42rem 1rem; border: none; border-radius: 7px;
  background: var(--accent); color: var(--accent-fg); cursor: pointer;
  align-self: flex-start;
}
button:disabled { opacity: .5; }
button.linkish {
  background: none; color: var(--accent); padding: 0; border-radius: 0;
  text-decoration: underline; cursor: pointer; font-size: .85rem;
}
button.linkish.danger { color: var(--danger); }
form.inline { display: inline; margin-left: .5rem; }
.topnav form.inline { margin-left: 0; }

/* flat admin-style rows: divider lines, no card chrome */
article {
  position: relative;
  padding: .6rem 0 .65rem;
  border-bottom: 1px solid var(--border);
}
article .meta { font-size: .78rem; color: var(--dim); }
article.mine .meta { color: var(--accent); }
article p { margin: .15rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
article .actions {
  position: absolute; top: .5rem; right: 0; display: flex; gap: .1rem;
  opacity: 0; transition: opacity .12s;
}
article:hover .actions, article .actions:focus-within { opacity: 1; }
article .del {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-size: .9rem; padding: .1rem .3rem; border-radius: 5px;
}
article .del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.editwrap { display: flex; flex-direction: column; gap: .45rem; margin-top: .45rem; max-width: 100%; }
.editwrap button { align-self: flex-start; }
textarea { min-height: 4.2rem; resize: vertical; overflow: hidden; }

#msgs { max-height: 60vh; overflow-y: auto; margin-bottom: 1rem; padding-right: .2rem; }

.err { color: var(--danger); }
.dim { color: var(--dim); font-size: .88rem; }
.pager { display: flex; gap: 1.5rem; margin-top: 1rem; }
code {
  background: color-mix(in srgb, var(--fg) 9%, transparent);
  padding: .1rem .35rem; border-radius: 5px; overflow-wrap: anywhere; font-size: .85em;
}
details:not(.menu) { margin-top: .4rem; }
details:not(.menu) summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
details .stack { margin: .6rem 0 .4rem; }

@media (max-width: 700px) {
  .shell { flex-direction: column; }
  aside {
    width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: .8rem; padding: .7rem .8rem;
  }
  .brand { font-size: 1.15rem; padding: 0 .2rem; width: 100%; }
  aside nav { flex-direction: row; flex-wrap: wrap; gap: .2rem; align-items: center; }
  .navrow { padding: 0 .2rem; gap: .4rem; }
  .sidefoot { margin: 0 0 0 auto; border: none; padding: 0; flex-direction: row; align-items: center; gap: .8rem; }
  .menupanel { left: auto; right: 0; bottom: auto; top: calc(100% + .5rem); }
  button.logout { width: auto; padding: .3rem .7rem; }
  main { padding: 1rem; }
}
