:root {
  --bg: #12100e;
  --panel: #1a1613;
  --elev: #221d18;
  --ink: #f4ebe3;
  --mute: #9a8e82;
  --line: rgba(244, 235, 227, 0.1);
  --line2: rgba(244, 235, 227, 0.16);
  --accent: #e8a87c;
  --accent2: #d4895a;
  --ok: #6bbf8a;
  --mine: #3d322a;
  --theirs: #26201b;
  --wash:
    radial-gradient(ellipse 55% 40% at 0% 0%, rgba(232, 168, 124, 0.12), transparent 55%),
    var(--bg);
  --sans: "DM Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--wash);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea {
  -webkit-user-select: text !important;
  user-select: text !important;
  pointer-events: auto !important;
  -webkit-appearance: none;
  appearance: none;
}
#app { height: 100%; }

/* login */
.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
}
.gate-box { width: min(380px, 100%); }
.gate .mark {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.gate h1 {
  font-family: var(--display);
  font-size: 2.2rem;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.gate p { margin: 0 0 24px; color: var(--mute); line-height: 1.5; font-size: 14.5px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--mute); margin-bottom: 5px; }
.field input {
  width: 100%;
  padding: 14px 14px;
  border-radius: 10px;
  border: 1px solid var(--line2);
  background: #2a2420;
  color: #f4ebe3;
  caret-color: #e8a87c;
  outline: none;
  font-size: 16px;
  line-height: 1.3;
}
.field input::placeholder { color: #7a7168; opacity: 1; }
.field input:focus { border-color: var(--accent); background: #322c27; }
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f4ebe3 !important;
  caret-color: #e8a87c;
  box-shadow: 0 0 0 1000px #2a2420 inset !important;
  transition: background-color 99999s ease-out;
}
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 72px; }
.btn-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  border-radius: 8px;
}
.btn-eye:hover { background: rgba(232, 168, 124, 0.12); }
.staff-more {
  margin: 0 0 14px;
  color: var(--mute);
  font-size: 13px;
}
.staff-more summary { cursor: pointer; color: var(--mute); }
.login-form .btn-primary:disabled { opacity: 0.65; cursor: wait; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
}
.btn-primary { background: var(--accent); color: #1a120c; width: 100%; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost { border: 1px solid var(--line2); }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-like {
  background: var(--ok);
  color: #0c1a12;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}
.hint-box {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(232, 168, 124, 0.12);
  border: 1px solid rgba(232, 168, 124, 0.28);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.4;
}
.hint-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent);
  font-weight: 700;
}

/* workspace */
.ws {
  height: 100%;
  display: grid;
  grid-template-columns: 260px 300px 1fr;
}

/* characters */
.chars {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chars-top {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.chars-top .mark {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.chars-top h1 {
  font-family: var(--display);
  font-size: 1.35rem;
  margin: 4px 0 0;
}
.chars-top .hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--mute);
  line-height: 1.4;
}
.chars-list { flex: 1; overflow-y: auto; padding: 8px; }
.char {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  text-align: left;
  margin-bottom: 4px;
}
.char:hover { background: rgba(255,255,255,0.04); }
.char.active {
  background: rgba(232, 168, 124, 0.14);
  outline: 1px solid rgba(232, 168, 124, 0.35);
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--elev);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-meta { min-width: 0; flex: 1; }
.char-meta strong {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-meta span {
  display: block;
  font-size: 12px;
  color: var(--mute);
}
.pill {
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a120c;
  display: grid;
  place-items: center;
}
.chars-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--mute);
}

/* inbox column */
.inbox {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.inbox-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 8px;
}
.inbox-tabs button {
  flex: 1;
  padding: 14px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mute);
  border-bottom: 2px solid transparent;
}
.inbox-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.inbox-scroll { flex: 1; overflow-y: auto; padding: 8px; }
.row {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  text-align: left;
  margin-bottom: 2px;
}
.row:hover { background: rgba(255,255,255,0.04); }
.row.active {
  background: rgba(232, 168, 124, 0.12);
}
.row-meta { min-width: 0; flex: 1; }
.row-meta strong {
  display: block;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta span {
  display: block;
  font-size: 12px;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta .age { color: var(--mute); font-weight: 400; }
.dot-new {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--mute);
  font-size: 13.5px;
  line-height: 1.5;
}
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 14px; }

.like-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 8px;
  background: var(--elev);
}
.like-card .info { flex: 1; min-width: 0; }
.like-card strong { display: block; font-size: 14px; }
.like-card span { font-size: 12px; color: var(--mute); }

/* thread */
.thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: transparent;
}
.thread-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 12px;
}
.thread-head .who strong { display: block; font-size: 15px; }
.thread-head .who span { font-size: 12px; color: var(--mute); }
.as-badge {
  margin-left: auto;
  font-size: 12px;
  color: var(--mute);
  background: var(--elev);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
}
.as-badge b { color: var(--accent); font-weight: 600; }
.typing-bar {
  padding: 8px 20px;
  font-size: 13px;
  color: var(--accent);
  background: rgba(232, 168, 124, 0.08);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.typing-dots {
  width: 28px;
  height: 10px;
  background: radial-gradient(circle closest-side, var(--accent) 90%, transparent) 0% 50%,
    radial-gradient(circle closest-side, var(--accent) 90%, transparent) 50% 50%,
    radial-gradient(circle closest-side, var(--accent) 90%, transparent) 100% 50%;
  background-size: calc(100% / 3) 6px;
  background-repeat: no-repeat;
  animation: typingPulse 1s infinite linear;
  opacity: 0.85;
}
@keyframes typingPulse {
  0% { opacity: 0.35; }
  50% { opacity: 1; }
  100% { opacity: 0.35; }
}
.thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bubble {
  max-width: min(70%, 520px);
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.45;
  word-break: break-word;
}
.bubble.mine {
  align-self: flex-end;
  background: var(--mine);
  border: 1px solid var(--line2);
  border-bottom-right-radius: 4px;
}
.bubble.theirs {
  align-self: flex-start;
  background: var(--theirs);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.bubble time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--mute);
}
.compose {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.compose textarea {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 140px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line2);
  background: var(--elev);
  outline: none;
  line-height: 1.4;
}
.compose textarea:focus { border-color: var(--accent); }
.compose .btn-primary { width: auto; min-width: 88px; }

.placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px;
  text-align: center;
  color: var(--mute);
}
.placeholder strong {
  display: block;
  font-family: var(--display);
  font-size: 1.35rem;
  color: var(--ink);
  margin-bottom: 8px;
}

@media (max-width: 900px) {
  .ws { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .chars, .inbox { max-height: 220px; border-right: none; border-bottom: 1px solid var(--line); }
}
