:root {
  --bg: #f2f1ef;
  --bg-2: #ece8e2;
  --panel: #fcfbf9;
  --line: #cfc7bb;
  --ink: #22201c;
  --muted: #686258;
  --accent: #b0671e;
  --accent-2: #8e5012;
  --chip: #f4eee6;
  --chip-ink: #6f4519;
  color-scheme: light;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, Monaco, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
}

.app-shell {
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 8px;
}

.topbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-spacer {
  margin-left: auto;
  flex: 1 1 auto;
}

.clock {
  color: var(--muted);
  font-size: 0.76rem;
  min-width: 46px;
}

.identity-pill {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip);
  color: var(--chip-ink);
  font-weight: 700;
  font-size: 0.74rem;
  white-space: nowrap;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

#messages {
  list-style: none;
  margin: 0;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-y: auto;
  background: var(--panel);
}

#messages li {
  padding: 2px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  display: grid;
  grid-template-columns: max-content max-content 1fr;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  font-size: 0.80rem;
  white-space: nowrap;
  overflow: hidden;
}

#messages li:last-child { border-bottom: none; }
#messages time {
  color: var(--muted);
  font-size: 0.74rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
#messages .from {
  font-size: 0.73rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
#messages .from.unknown { color: var(--muted); font-weight: 500; }
#messages p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.rejection-row {
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.73rem;
  color: #9b2618;
}

.rejection-row.hidden {
  display: none;
}

.rejection-chip {
  border: 1px solid color-mix(in srgb, #b53926 45%, var(--line));
  border-radius: 999px;
  padding: 2px 8px;
  background: color-mix(in srgb, #b53926 12%, var(--panel));
  color: inherit;
}

.button-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex: 0 0 auto;
}

button {
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

button:hover { background: var(--accent-2); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.meta {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.top-link {
  color: var(--muted);
  font-size: 0.75rem;
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
  line-height: 1;
}

.top-link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.top-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.icon-link {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.icon-link svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.icon-link:hover {
  color: var(--ink);
  border-color: var(--muted);
}

input[type="text"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  background: var(--panel);
  color: var(--ink);
}

.send-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .topbar-spacer {
    display: none;
  }

  .identity-pill {
    max-width: 52vw;
  }

  .button-row {
    gap: 4px;
  }

  .button-row button {
    padding: 6px 8px;
    font-size: 0.72rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --bg-2: #1e1a15;
    --panel: #23201b;
    --line: #3a3329;
    --ink: #eee7dd;
    --muted: #aea28f;
    --accent: #d08a3f;
    --accent-2: #b8732e;
    --chip: #31281d;
    --chip-ink: #e6b37c;
    color-scheme: dark;
  }

  .rejection-row {
    color: #ff9d8f;
  }

  .rejection-chip {
    border-color: color-mix(in srgb, #ff6f5a 45%, var(--line));
    background: color-mix(in srgb, #ff6f5a 14%, var(--panel));
  }
}
