/* Encrypted self-chat — minimal, mobile-first, light/dark theming via CSS variables. */
:root {
  --bg: #0b141a; --card: #111b21; --header: #202c33; --border: #222d34;
  --input-bg: #2a3942; --bubble: #202c33; --bubble-mine: #005c4b;
  --text: #e9edef; --muted: #8696a0; --accent: #00a884; --link: #53bdeb; --danger: #f15c6d;
}
body.light {
  --bg: #d2dbe0; --card: #ffffff; --header: #f0f2f5; --border: #d1d7db;
  --input-bg: #ffffff; --bubble: #ffffff; --bubble-mine: #d9fdd3;
  --text: #111b21; --muted: #667781; --accent: #008f72; --link: #027eb5; --danger: #d9314a;
}

* { box-sizing: border-box; }
/* the `hidden` attribute must beat the display rules below (.screen/.pub-toggle use
   display:flex, which otherwise overrides the UA [hidden]{display:none}). */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
.screen { height: 100dvh; display: flex; flex-direction: column; }

/* ---- lock / setup ---- */
.lock-screen { align-items: center; justify-content: center; padding: 24px; }
.lock-card {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 22px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.lock-logo { font-size: 40px; }
.lock-card h1 { font-size: 20px; margin: 8px 0 4px; }
.lock-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.lock-card input[type=password] {
  width: 100%; padding: 13px 14px; margin-bottom: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text); font-size: 16px;
}
.lock-card input:focus { outline: none; border-color: var(--accent); }
.lock-card button[type=submit] {
  width: 100%; padding: 13px; border: none; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #04130d; font-weight: 600; font-size: 16px;
}
.lock-card button:disabled { opacity: .6; cursor: progress; }
.lock-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }
.lock-note { color: var(--muted); font-size: 11px; margin: 16px 0 0; line-height: 1.5; }

/* ---- header ---- */
.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; background: var(--header); border-bottom: 1px solid var(--border);
  padding-top: max(10px, env(safe-area-inset-top));
}
.chat-title { font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border: none; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 18px; line-height: 1;
}
.icon-btn:active { background: var(--input-bg); }
.icon-btn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* #4 — prominent lock button */
.lock-btn {
  border: none; border-radius: 20px; cursor: pointer; padding: 8px 16px; font-size: 14px;
  font-weight: 700; background: var(--danger); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.lock-btn:active { transform: scale(.96); }

.chat-error {
  background: var(--danger); color: #fff; font-size: 13px; text-align: center; padding: 8px 12px;
}

/* ---- messages ---- */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; align-items: flex-end; gap: 4px; }
.msg.mine { justify-content: flex-end; }
.bubble {
  position: relative; max-width: 80%; background: var(--bubble); border-radius: 10px;
  padding: 7px 10px 5px; word-wrap: break-word; overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0,0,0,.15);
}
.msg.mine .bubble { background: var(--bubble-mine); }
.bubble .body { white-space: pre-wrap; font-size: 15px; line-height: 1.4; }
.bubble time { display: block; text-align: right; font-size: 10px; color: var(--muted); margin-top: 2px; }
.pub-tag { float: right; font-size: 11px; opacity: .85; margin-left: 6px; }
.file-chip { display: inline-block; color: var(--link); text-decoration: none; font-size: 14px; cursor: pointer; }
/* capped preview — never huge; keeps aspect ratio, tap to open full file via the ⬇ link */
.file-img { max-width: 240px; max-height: 300px; width: auto; height: auto; border-radius: 8px; display: block; margin-bottom: 4px; cursor: pointer; }
/* #2 — delete button (owner) */
.del-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px;
  padding: 2px 4px; align-self: center; opacity: .55;
}
.del-btn:active { opacity: 1; color: var(--danger); }

/* ---- composer ---- */
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  background: var(--header); border-top: 1px solid var(--border);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.pub-toggle {
  flex: none; height: 40px; display: flex; align-items: center; gap: 4px; padding: 0 10px;
  background: var(--input-bg); border-radius: 18px; color: var(--muted); font-size: 16px;
  cursor: pointer; user-select: none;
}
.pub-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.pub-toggle:has(input:checked) { background: var(--accent); color: #04130d; }
.attach-btn {
  flex: none; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: var(--input-bg); border-radius: 50%; color: var(--muted); font-size: 22px; cursor: pointer;
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px; padding: 10px 12px; border-radius: 18px;
  border: none; background: var(--input-bg); color: var(--text); font-size: 15px; line-height: 1.4;
  font-family: inherit;
}
.composer textarea:focus { outline: none; }
#send-btn {
  flex: none; width: 40px; height: 40px; border: none; border-radius: 50%;
  background: var(--accent); color: #04130d; font-size: 18px; cursor: pointer;
}

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-box {
  width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; box-shadow: 0 14px 44px rgba(0,0,0,.5);
}
.modal-box h3 { margin: 0 0 8px; font-size: 17px; }
.modal-msg { color: var(--muted); font-size: 14px; margin: 0 0 14px; line-height: 1.5; }
.modal-input {
  width: 100%; padding: 11px 12px; margin-bottom: 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text); font-size: 16px;
}
.modal-input:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-btn {
  border: none; border-radius: 9px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; background: var(--input-bg); color: var(--text);
}
.modal-btn.primary { background: var(--accent); color: #04130d; }
.modal-btn.danger { background: var(--danger); color: #fff; }
