:root {
  color-scheme: light dark;
  --bg: #f5f2ee;
  --card: #ffffff;
  --text: #25221f;
  --muted: #6b665f;
  --line: #e2ddd5;
  --vent: #b93a26;
  --vent-soft: #fbebe7;
  --positive: #27754e;
  --positive-soft: #e6f3eb;
  --on-accent: #ffffff;
  --accent: var(--vent);
  --accent-soft: var(--vent-soft);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151617;
    --card: #1f2123;
    --text: #ecebe8;
    --muted: #a29e97;
    --line: #36393c;
    --vent: #f27a64;
    --vent-soft: #38211d;
    --positive: #62c892;
    --positive-soft: #1b3226;
    --on-accent: #151617;
  }
}

/* The accent follows the active tab; entry cards always use their own kind. */
body[data-tab="positive"],
.entry.positive,
.prompt,
.upside {
  --accent: var(--positive);
  --accent-soft: var(--positive-soft);
}

.entry.vent {
  --accent: var(--vent);
  --accent-soft: var(--vent-soft);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

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

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

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

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

/* ---- header and tabs */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.top h1 {
  flex: 1;
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Quarter-turns of the boxing glove. Transforms do not change the layout box. */
.glove {
  display: inline-block;
}

.glove.cw {
  transform: rotate(90deg);
}

.glove.ccw {
  transform: rotate(-90deg);
}

.top input[type="search"] {
  width: 100%;
  max-width: 200px;
  min-width: 0;
}

input[type="search"],
input[type="text"],
input[type="password"],
textarea {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  padding: 12px;
  overflow: visible;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
}

.tab[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.tab .count {
  margin-left: 8px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.subbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -4px 0 12px;
}

.today {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.filter[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.checks {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
}

.check input {
  width: 1em;
  height: 1em;
  margin: 0;
  accent-color: var(--vent);
}

/* ---- buttons */

.primary {
  padding: 8px 18px;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: var(--on-accent);
  font-weight: 600;
}

.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.ghost,
.tool {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.ghost:hover,
.tool:hover {
  color: var(--text);
  border-color: var(--muted);
}

.link {
  padding: 4px 6px;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.link:hover {
  color: var(--text);
  text-decoration: underline;
}

.link.nudge {
  color: var(--positive);
  font-weight: 600;
}

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

/* ---- composer */

/* minmax(0, 1fr) keeps wide content (long lines, code blocks) from stretching
   a grid past the page width. */
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.composer:focus-within {
  border-color: var(--accent);
}

.composer textarea {
  width: 100%;
  min-height: 5.5em;
  max-height: 60vh;
  resize: vertical;
  field-sizing: content;
}

.preview {
  min-height: 5.5em;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.status {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Cancel and submit stay together, on the right, when the toolbar wraps. */
.toolbar .submit {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.palette button {
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  font-size: 1.25rem;
}

.palette button:hover {
  background: var(--accent-soft);
}

/* ---- entries */

.list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.entry {
  border-left: 4px solid var(--accent);
}

.entry.flash {
  animation: flash 1.2s ease-out;
}

@keyframes flash {
  from {
    background: var(--accent-soft);
  }
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  padding: 1px 8px;
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 600;
}

.avatar {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  vertical-align: middle;
}

.author,
.who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 600;
}

/* Rocky, ringside: yellow caption, the way he yells for Adrian. */
.adrian {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px;
  background: #f5d90a;
  border: 0;
  border-radius: 999px;
  color: #1a1200;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.01em;
}

.adrian span {
  font-style: normal;
  font-weight: 700;
}

.adrian[aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px #1a1200;
}

.belt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px;
  background: linear-gradient(180deg, #ffe7a3, #e2b227 48%, #b8860b);
  border: 2px solid #6b4a08;
  border-radius: 6px;
  color: #1a1200;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.belt[aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px #1a1200;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.avatar-choice {
  padding: 0;
  overflow: hidden;
  background: none;
  border: 2px solid transparent;
  border-radius: 10px;
}

.avatar-choice img {
  display: block;
  width: 100%;
  height: auto;
}

.avatar-choice[aria-pressed="true"] {
  border-color: var(--accent);
}

.context {
  display: block;
  max-width: 100%;
  margin-top: 8px;
  padding: 4px 10px;
  overflow: hidden;
  background: var(--vent-soft);
  border: 0;
  border-radius: 8px;
  color: var(--vent);
  font-size: 0.9rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upside {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding: 2px 12px;
  background: var(--accent-soft);
  border-radius: 8px;
}

.upside > span {
  padding-top: 0.6em;
}

.upside .md {
  flex: 1;
  min-width: 0;
}

.entry footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  margin-left: auto;
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.reactions .palette {
  flex-basis: 100%;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.95rem;
}

.reaction span {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.reaction[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.reaction.add {
  color: var(--muted);
  filter: grayscale(1);
}

.reaction.add:hover {
  filter: none;
}

.share {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.share p {
  margin: 0 0 8px;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-row input {
  flex: 1;
  min-width: 200px;
}

/* ---- rendered markdown */

.md {
  overflow-wrap: anywhere;
}

.md > :first-child {
  margin-top: 0.6em;
}

.md > :last-child {
  margin-bottom: 0.6em;
}

.md p,
.md ul,
.md ol,
.md pre,
.md blockquote,
.md table {
  margin: 0.6em 0;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 0.8em 0 0.4em;
  line-height: 1.25;
}

.md h1 {
  font-size: 1.4rem;
}

.md h2 {
  font-size: 1.2rem;
}

.md h3,
.md h4 {
  font-size: 1.05rem;
}

.md img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  border-radius: 8px;
}

.md a {
  color: var(--accent);
}

.md code {
  padding: 0.1em 0.35em;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.9em;
}

.md pre {
  padding: 12px;
  overflow-x: auto;
  background: var(--bg);
  border-radius: 8px;
}

.md pre code {
  padding: 0;
  background: none;
}

.md blockquote,
.prompt blockquote {
  padding: 2px 14px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.md table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}

.md th,
.md td {
  padding: 4px 10px;
  border: 1px solid var(--line);
}

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
}

/* ---- sign-in */

.auth {
  display: grid;
  gap: 12px;
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 32px 24px;
  text-align: center;
}

.auth .logo {
  font-size: 3.5rem;
  line-height: 1;
}

.auth h1,
.auth p,
.account h3,
.account p {
  margin: 0;
}

.auth input,
.account input {
  width: 100%;
}

.warning {
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--vent-soft);
  border-radius: 8px;
  color: var(--vent);
  font-size: 0.9rem;
}

.account {
  display: grid;
  gap: 12px;
  text-align: left;
}

.account form {
  display: grid;
  gap: 8px;
}

.user-list {
  display: grid;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.error {
  color: var(--vent);
}

.error:empty {
  display: none;
}

/* ---- the "now something positive" dialog */

.prompt,
.account {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 24px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
}

.prompt::backdrop,
.account::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.prompt h2 {
  margin: 0 0 12px;
  font-size: 1.3rem;
}

.prompt blockquote {
  margin: 0 0 12px;
  border-left-color: var(--vent);
}

.prompt .ask {
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 600;
}

.prompt .composer {
  margin: 0;
}

/* ---- toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--text);
  border-radius: 8px;
  color: var(--bg);
  transform: translateX(-50%);
}

@media (max-width: 520px) {
  .top {
    flex-wrap: wrap;
  }

  .top input[type="search"] {
    order: 3;
    flex: 1;
    max-width: none;
  }
}
