:root {
  --bg: #f3efe8;
  --ink: #12100e;
  --muted: #6f675e;
  --line: #e4ddd3;
  --paper: #fffcf7;
  --accent: #c45c26;
  --accent-fg: #fff;
  --mine: #c45c26;
  --theirs: #fff;
  --danger: #c43a3a;
  --ok: #3d6b4f;
  --scrim: rgba(18, 16, 14, 0.18);
  --theme: #f3efe8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Instrument Sans", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100dvh;
  min-height: 100svh;
}
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100svh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.screen.on { display: flex; }

.gate {
  padding: 48px 24px 32px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}
.mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  box-shadow: 0 10px 28px rgba(196, 92, 38, 0.28);
}
.mark svg { width: 36px; height: 36px; }
.gate h1 {
  font-size: 32px;
  letter-spacing: -0.04em;
  margin: 0 0 8px;
}
.gate p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 16px;
}
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.nick-row {
  display: flex;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  margin-bottom: 16px;
}
.nick-row span {
  color: var(--accent);
  font-weight: 600;
  font-size: 18px;
}
.nick-row input {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 18px;
  padding: 14px 8px;
  outline: none;
  color: var(--ink);
  min-width: 0;
}
.btn {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  width: 100%;
  cursor: pointer;
}
.btn[disabled] { opacity: 0.5; }
.hint, .err {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.4;
}
.err { color: var(--danger); }
.hint { color: var(--muted); }

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  min-height: 56px;
}
.top h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.ico {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  border-radius: 12px;
  font-size: 24px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
}
.status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9c3ba;
  flex-shrink: 0;
}
.status.on { background: var(--ok); }
.sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.list {
  flex: 1;
  overflow: auto;
  padding: 12px 14px 24px;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .row {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}
.chip .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--ok);
  border-radius: 50%;
  margin-right: 6px;
}
.row {
  display: flex;
  width: 100%;
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  margin-bottom: 8px;
  align-items: center;
  gap: 10px;
}
.row .who { font-weight: 600; }
.row .preview {
  flex: 1;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.empty {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  padding: 8px 2px 0;
}
.write {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.write input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 12px;
  font: inherit;
  outline: none;
  min-width: 0;
}
.write .btn { width: auto; padding: 12px 16px; }

.pwa-box {
  margin-top: 22px;
}
.list .pwa-box {
  margin: 0 0 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.h-screen {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pwa-btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin: 4px 0 10px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(196, 92, 38, 0.32);
}
.pwa-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.pwa-btn:active { transform: scale(0.98); }
.pwa-btn[hidden], .pwa-how[hidden], .pwa-done[hidden] { display: none; }
.pwa-how { display: flex; flex-direction: column; gap: 8px; }
.pwa-os {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.pwa-os-name {
  margin: 0 0 5px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--accent);
}
.pwa-os-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
.pwa-done {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--ok);
}
.pwa-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.pwa-sheet[hidden] { display: none; }
.pwa-sheet-card {
  width: 100%;
  max-width: 440px;
  background: var(--paper);
  border-radius: 22px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 40px rgba(18, 16, 14, 0.18);
}
.pwa-sheet-card .pwa-btn { margin-top: 16px; }

.thread {
  flex: 1;
  overflow: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px;
  line-height: 1.35;
  font-size: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.out {
  margin-left: auto;
  background: var(--mine);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble.in {
  margin-right: auto;
  background: var(--theirs);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.bubble.sys {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  max-width: 94%;
  text-align: center;
}
.composer {
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.composer input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  outline: none;
  min-width: 0;
}
.composer .btn { width: auto; border-radius: 14px; padding: 12px 16px; }

.banner {
  display: none;
  margin: 0;
  padding: 8px 14px;
  background: #f6efe4;
  color: #6a4a28;
  font-size: 13px;
  text-align: center;
}
.banner.on { display: block; }
.banner.bad { background: #f8e4e0; color: var(--danger); }
