/*!
 * Nenyok — Ephemeral E2EE Chat
 * https://nenyok.com
 */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, sans-serif;
  background: #000;
  color: #d1d5db;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ── Shared container ── */
.container {
  width: 92vw;
  max-width: 640px;
  min-width: 300px;
  margin: 32px auto;
  background: rgba(28,28,30,0.88);
  padding: 20px;
  border: 1px solid #2c2c2e;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}

h1 { margin: 0 0 16px; font-size: 20px; }

.row { display: flex; gap: 8px; margin-bottom: 12px; }

input[type="text"], textarea {
  flex: 1;
  padding: 12px 14px;
  min-height: 44px;
  border: 1px solid #3b3b3f;
  border-radius: 12px;
  font-size: 16px;
  background: rgba(22,22,26,0.8);
  color: #e5e7eb;
}
input[disabled], textarea[disabled] { background: #2a2a2d; color: #9aa0a6; }
input::placeholder, textarea::placeholder { color: #9aa0a6; }
input:focus, textarea:focus { outline: none; border-color: #5b3fa8; }

button:focus-visible { outline: 2px solid #8b5cf6; outline-offset: 2px; }
button {
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  color: #e5e7eb;
  background: linear-gradient(180deg, #4b3a6f, #2f2548);
  border: 1px solid rgba(187,173,255,0.22);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 8px 20px rgba(0,0,0,0.35);
  min-height: 44px;
  min-width: 44px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.row button:hover:not(:disabled) {
  background: linear-gradient(180deg, #564080, #352b57);
  border-color: rgba(200,190,255,0.28);
}
.row button:active:not(:disabled) {
  transform: translateY(1px);
  background: linear-gradient(180deg, #43356d, #2b2249);
}

/* ── Messages list ── */
.messages {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  background: #1c1c1e;
  border: 1px solid #2c2c2e;
  border-radius: 8px;
  overflow: auto;
}
.messages li {
  padding: 6px 10px;
  color: #f2f2f7;
  border-bottom: 1px solid #2c2c2e;
  font-size: 13px;
  line-height: 1.4;
}
.messages li:last-child { border-bottom: none; }

/* ── Status badge ── */
.status {
  margin-top: 10px;
  font-size: 11px;
  color: #a1a1aa;
  display: inline-block;
  padding: 5px 10px;
  border-radius: 10px;
  border: 1px solid #2c2c2e;
  background: rgba(20,20,22,0.7);
}
.status[data-state="connected"]    { color: #22c55e; border-color: #14532d; background: rgba(12,40,22,0.35); }
.status[data-state="disconnected"] { color: #f59e0b; border-color: #3f2d0b; background: rgba(40,28,12,0.35); }
.status[data-state="error"]        { color: #ef4444; border-color: #3b0f0f; background: rgba(44,12,12,0.35); }

.helper { margin-top: 12px; font-size: 14px; color: #9aa0a6; }

/* ── Chat page ── */
body.chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 0;
  height: 100%;
  overflow: hidden;
}
body.chat .container {
  width: 100%;
  max-width: 680px;
  margin: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 32px);
  padding: 12px;
}
body.chat .messages {
  flex: 1;
  margin: 0;
  padding: 8px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
body.chat .messages li {
  margin: 6px;
  border-bottom: none;
  background: #2b2b2e;
  border: 1px solid #3b3b3f;
  border-radius: 14px;
  max-width: 78%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
body.chat .messages li.mine { align-self: flex-end; }
body.chat .messages li.other {
  align-self: flex-start;
  background: linear-gradient(180deg, #4b3a6f, #2f2548);
  border-color: rgba(187,173,255,0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}
body.chat .messages li.system {
  align-self: center;
  background: rgba(167,139,250,0.07);
  border-color: rgba(167,139,250,0.18);
  color: #a78bfa;
  font-size: 12px;
  text-align: center;
  font-style: italic;
  max-width: 90%;
}
body.chat .messages .msg-text { flex: 1; }
body.chat .messages .msg-status { margin-left: 8px; font-size: 11px; white-space: nowrap; }
.msg-status.sent      { color: #9aa0a6; }
.msg-status.delivered { color: #60a5fa; }

.messages li.draft {
  background: rgba(91,76,138,0.25);
  border-color: rgba(187,173,255,0.32);
  color: #d1d5db;
  font-style: italic;
}

/* ── Chat header ── */
body.chat .chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(20,20,22,0.75);
  padding: 4px 6px;
  border: 1px solid #2c2c2e;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin-bottom: 8px;
}
body.chat .chat-header .status { font-size: 11px; padding: 3px 8px; border-radius: 6px; margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
body.chat .chat-header button  { font-size: 12px; padding: 4px 10px; min-height: 28px; border-radius: 8px; white-space: nowrap; flex-shrink: 0; }

/* ── Chat input ── */
body.chat .chat-input {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: rgba(20,20,22,0.75);
  padding: 8px;
  border: 1px solid #2c2c2e;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
body.chat .chat-input .input-wrap { position: relative; flex: 1; display: flex; }
body.chat .chat-input textarea {
  line-height: 16px;
  min-height: 20px;
  padding: 2px 12px;
  max-height: 120px;
  resize: none;
  width: 100%;
}
body.chat .chat-input input[type="text"] { height: 20px; line-height: 16px; padding: 2px 12px; width: 100%; }
body.chat .chat-input button { min-height: 40px; font-size: 15px; padding: 8px 12px; }
body.chat .chat-input .icon-btn {
  width: 40px; min-width: 40px; height: 40px;
  padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
body.chat .chat-input .icon-btn svg { display: block; width: 20px; height: 20px; }
body.chat .chat-input .msg-placeholder {
  position: absolute; top: 50%; left: 12px;
  transform: translateY(-50%);
  color: #9aa0a6; pointer-events: none; font-size: 13px; line-height: 1;
}
body.chat .chat-input .msg-placeholder.hidden { opacity: 0; }

/* ── Ephemeral note ── */
.ephemeral-note { text-align: center; font-size: 11px; color: #6b7280; margin: 6px 0 0; }

/* ── Footer / about ── */
.footer-link { text-align: center; font-size: 12px; color: #9aa0a6; margin-top: 8px; }
.footer-link a { color: #9aa0a6; text-decoration: underline; }

.about .container h1 { font-size: 18px; }
.about .container h2 { font-size: 16px; }
.about .container ul li { font-size: 13px; }
.about .about-header { justify-content: flex-start; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none; animation: none; }
  .row button:active:not(:disabled) { transform: none; }
}

@media (min-width: 768px) {
  body.chat .container {
    max-width: 460px;
  }
}
