:root {
  --bg: #07090d;
  --panel: #0b0f16;
  --border: #1a2333;
  --text: #e7eefc;
  --muted: #8aa0c2;
  --danger: #ff3b3b;
  --primary: #6aa6ff;
  --ghost: rgba(255, 255, 255, 0.06);
  --shadow: rgba(0, 0, 0, 0.4);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 800px at 10% 0%, #0f1630 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--sans);
}

body {
  overflow-x: hidden;
  overflow-y: auto;
}

.app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.panel {
  width: min(760px, 94vw);
  background: radial-gradient(1200px 800px at 50% 0%, rgba(106, 166, 255, 0.10), transparent 60%),
              linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  box-shadow: 0 24px 80px var(--shadow);
  padding: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  padding: 10px 12px;
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(255,255,255,0.92);
  background: rgba(0,0,0,0.60);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 14px 50px rgba(0,0,0,0.60);
  transition: opacity 140ms ease, transform 140ms ease;
  max-width: min(720px, 92vw);
  text-align: center;
}

.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-warn {
  border-color: rgba(255, 184, 84, 0.45);
}

.toast-err {
  border-color: rgba(255, 59, 59, 0.55);
}

.header {
  display: grid;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  position: relative;
}

.lang-switch {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 8px;
}

.lang-btn {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.12);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 8px;
  cursor: pointer;
  line-height: 1;
  font-size: 16px;
}

.lang-btn-active {
  border-color: rgba(106, 166, 255, 0.45);
  background: rgba(106, 166, 255, 0.14);
}

.flag {
  display: block;
  width: 18px;
  height: 14px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.10) inset;
  background-size: cover;
  background-position: center;
}

.flag-br {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' viewBox='0 0 18 14'%3E%3Crect width='18' height='14' fill='%2300963f'/%3E%3Cpolygon points='9,1 16,7 9,13 2,7' fill='%23ffdf00'/%3E%3Ccircle cx='9' cy='7' r='3' fill='%23002776'/%3E%3C/svg%3E");
}

.flag-us {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' viewBox='0 0 18 14'%3E%3Crect width='18' height='14' fill='%23b22234'/%3E%3Cg fill='%23fff'%3E%3Crect y='1' width='18' height='1'/%3E%3Crect y='3' width='18' height='1'/%3E%3Crect y='5' width='18' height='1'/%3E%3Crect y='7' width='18' height='1'/%3E%3Crect y='9' width='18' height='1'/%3E%3Crect y='11' width='18' height='1'/%3E%3Crect y='13' width='18' height='1'/%3E%3C/g%3E%3Crect width='8' height='7' fill='%233c3b6e'/%3E%3C/svg%3E");
}

.title {
  margin: 0;
  letter-spacing: 0.22em;
  font-weight: 700;
  font-size: 18px;
  font-family: var(--mono);
}

.subtitle {
  font-size: 13px;
  color: var(--muted);
}

.screen {
  display: grid;
  gap: 14px;
}

.hidden { display: none !important; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
}

.row {
  display: grid;
  gap: 8px;
}

.send-actions {
  display: grid;
  grid-template-columns: 120px 120px 1fr;
  gap: 10px;
}

.send-actions .btn {
  width: 100%;
}

@media (max-width: 520px) {
  .send-actions { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 380px) {
  .send-actions { grid-template-columns: 1fr; }
}

.label {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.input, .textarea {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-family: var(--mono);
  outline: none;
}

.textarea {
  resize: none;
}

.input:focus, .textarea:focus {
  border-color: rgba(106, 166, 255, 0.7);
}

.btn {
  border: 1px solid var(--border);
  background: var(--ghost);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.btn:hover {
  border-color: rgba(255,255,255,0.2);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: rgba(106, 166, 255, 0.18);
  border-color: rgba(106, 166, 255, 0.35);
}

.btn-danger {
  background: rgba(255, 59, 59, 0.16);
  border-color: rgba(255, 59, 59, 0.35);
}

.btn-ghost {
  background: transparent;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.live-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.live-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.12em;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

.conn {
  display: grid;
  gap: 10px;
  border: 1px dashed rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 14px;
  background: rgba(0,0,0,0.12);
}

.crypto-badge {
  justify-self: start;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  user-select: none;
}

.crypto-badge-ok {
  border-color: rgba(106, 166, 255, 0.35);
  background: rgba(106, 166, 255, 0.14);
}

.crypto-badge-warn {
  border-color: rgba(255, 184, 84, 0.35);
  background: rgba(255, 184, 84, 0.10);
}

.crypto-badge-off {
  opacity: 0.8;
}

.now {
  display: grid;
  gap: 8px;
  border: 1px dashed rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 14px;
  background: rgba(0,0,0,0.18);
  min-height: 120px;
}

.messages {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 6px;
}

.msg-row {
  display: flex;
}

.msg-row.me {
  justify-content: flex-end;
}

.msg-row.peer {
  justify-content: flex-start;
}

.msg-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  user-select: none;
}

.msg-image {
  display: block;
  width: 100%;
  max-width: 340px;
  max-height: 340px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
}

.msg-video {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 340px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
}

.msg-audio {
  display: block;
  width: 100%;
  max-width: 340px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
  color-scheme: dark;
  filter: invert(1) hue-rotate(180deg);
}

.msg-file {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.14);
  border-radius: 10px;
  padding: 8px 10px;
}

.msg-file:hover {
  border-color: rgba(255,255,255,0.22);
}

.msg-row.me .msg-bubble {
  border-color: rgba(106, 166, 255, 0.28);
  background: rgba(106, 166, 255, 0.10);
}

.msg-meta {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}

.msg-chip {
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 2px 8px;
  font-family: var(--mono);
}

.msg-chip.enc {
  border-color: rgba(106, 166, 255, 0.35);
}

.msg-chip.plain {
  border-color: rgba(255, 184, 84, 0.35);
}

.dead {
  display: grid;
  gap: 10px;
  place-items: start;
}

.dead-title {
  font-family: var(--mono);
  font-size: 28px;
  letter-spacing: 0.2em;
  color: rgba(255, 59, 59, 0.9);
}
