:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #e9e9e9;
  color: #111;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { background: #d9dadb; overscroll-behavior-y: none; }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app-shell { min-height: 100dvh; }

.unlock-screen {
  min-height: 100dvh;
  padding: max(52px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  color: #fff;
  background:
    radial-gradient(circle at 92% 6%, rgba(151, 239, 204, .24), transparent 31%),
    radial-gradient(circle at 2% 92%, rgba(99, 165, 255, .2), transparent 37%),
    linear-gradient(151deg, #151a28 0%, #253247 57%, #141b29 100%);
}
.unlock-hero { padding: 0 8px 28px; }
.logo-mark {
  width: 54px; height: 54px; margin-bottom: 25px; border-radius: 19px;
  background: linear-gradient(145deg, #30cf93, #05a768); box-shadow: 0 15px 30px rgba(0, 207, 147, .22);
  display: grid; grid-template-columns: repeat(2, 9px); gap: 4px; place-content: center;
}
.logo-mark span { display: block; aspect-ratio: 1; border-radius: 2px; background: #fff; }
.logo-mark span:last-child { opacity: .62; }
.unlock-hero h1 { margin: 0; font-size: 37px; letter-spacing: 1px; line-height: 1.15; }
.unlock-card {
  width: min(100%, 440px); align-self: center; padding: 23px 20px 20px; border-radius: 20px;
  background: rgba(255,255,255,.98); color: #1f2831; box-shadow: 0 20px 45px rgba(0, 0, 0, .18);
}
.unlock-card h2, .burn-dialog h2 { margin: 0; font-size: 18px; line-height: 1.4; }
.access-copy { margin: 7px 0 0; color: #59636d; font-size: 13px; line-height: 1.65; }
.unlock-status { margin: 13px 0 0; padding: 8px 10px; border-radius: 8px; background: #e9f6ef; color: #285b43; font-size: 13px; line-height: 1.5; }
.entry-link { display: block; width: fit-content; margin: 4px auto 0; padding: 10px 6px; color: #08704c; font-size: 13px; text-underline-offset: 3px; }
.audit-disclosure { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: #f2f0e7; color: #624f22; font-size: 12px; line-height: 1.6; }
.audit-disclosure p { margin: 2px 0 0; }
.room-entry-fields { margin-top: 17px; }
.field-label { display: flex; margin: 0 0 7px; font-size: 13px; font-weight: 650; color: #48525e; }
.field-label:not(:first-child) { margin-top: 17px; }
.field-label em { margin-left: 7px; color: #abb3ba; font-size: 11px; font-style: normal; font-weight: 400; }
.unlock-card input:not([type="file"]) {
  width: 100%; height: 46px; border: 1px solid #e2e6e8; border-radius: 10px; padding: 0 13px; outline: none; background: #f8f9f9; font-size: 14px; transition: border-color .2s, box-shadow .2s;
}
.unlock-card input:focus { border-color: #1bbb79; box-shadow: 0 0 0 3px rgba(27,187,121,.14); background: #fff; }
.password-row { position: relative; }
.password-row input { padding-right: 46px !important; }
.eye-button { position: absolute; right: 1px; top: 1px; height: 44px; width: 42px; border: 0; color: #8b959e; background: transparent; cursor: pointer; }
.form-error { margin: 9px 0 0; color: #a72e2e; font-size: 12px; line-height: 1.5; }
.form-error:empty { margin: 0; }
.primary-button { width: 100%; min-height: 48px; margin-top: 15px; border: 0; border-radius: 11px; background: #087e52; color: #fff; font-weight: 650; cursor: pointer; box-shadow: 0 6px 13px rgba(9, 182, 110, .24); }
.primary-button:disabled, .send-button:disabled { opacity: .56; cursor: wait; }
.edit-password-button { display: block; min-height: 40px; margin: 5px auto 0; border: 0; background: transparent; color: #59636d; font-size: 13px; cursor: pointer; }
.lock-note { margin: auto 4px 0; padding-top: 25px; text-align: center; font-size: 11px; color: rgba(255,255,255,.62); line-height: 1.6; }

.chat-screen { width: 100%; height: 100dvh; max-width: 760px; margin: auto; position: relative; overflow: hidden; background: #ededed; display: flex; flex-direction: column; transition: background .25s ease; }
.chat-screen[data-background="dawn"] { background: linear-gradient(160deg, #fff2df 0%, #f8ddcb 49%, #dfeafb 100%); }
.chat-screen[data-background="mint"] { background: linear-gradient(155deg, #e5f8ee 0%, #d9f0ec 47%, #e5effa 100%); }
.chat-screen[data-background="night"] { background: radial-gradient(circle at 92% 8%, #344966 0, transparent 36%), linear-gradient(150deg, #192634 0%, #263b4d 100%); }
.chat-screen[data-background="custom"] { background: #24303d; }
.chat-header { min-height: calc(56px + env(safe-area-inset-top)); padding: max(10px, env(safe-area-inset-top)) 17px 9px; display: flex; align-items: center; justify-content: space-between; background: rgba(247,247,247,.94); border-bottom: 1px solid #ddd; flex: 0 0 auto; }
.header-title { display: flex; align-items: center; gap: 10px; }
.header-title strong { display: block; font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.header-title small { display: block; margin-top: 3px; color: #838383; font-size: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #b8bec3; box-shadow: 0 0 0 3px #edf0f1; }
.status-dot.connected { background: #11ba70; box-shadow: 0 0 0 3px #d9f4e7; }
.header-actions { display: flex; align-items: center; gap: 2px; }
.background-button, .lock-button { border: 0; padding: 8px 3px 8px 11px; background: transparent; color: #68727b; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.background-button:first-letter, .lock-button:first-letter { font-size: 20px; }
.room-share-button { min-height: 36px; border: 0; border-radius: 7px; padding: 0 9px; background: #e0f3e8; color: #176344; cursor: pointer; font-size: 13px; font-weight: 650; white-space: nowrap; }
.room-share-panel { flex: 0 0 auto; padding: 10px 16px 11px; border-bottom: 1px solid #cde6d9; background: #eff9f4; color: #244c3b; }
.room-share-panel label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; }
.room-share-row { display: flex; gap: 7px; }
.room-share-row input { flex: 1; min-width: 0; min-height: 38px; padding: 0 8px; border: 1px solid #b9d7ca; border-radius: 7px; background: #fff; color: #315044; font-family: ui-monospace, monospace; font-size: 12px; }
.room-share-row button { min-height: 38px; padding: 0 9px; border: 0; border-radius: 7px; background: #087e52; color: #fff; font-size: 12px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.room-share-panel p { margin: 6px 0 0; color: #456859; font-size: 12px; line-height: 1.5; }
.burn-button { width: 100%; min-height: 44px; margin-top: 9px; border: 1px solid #ecc1c1; border-radius: 7px; background: #fceaea; color: #9a2222; font-size: 14px; font-weight: 650; cursor: pointer; }
.burn-button:hover { background: #f8dcdc; }
.burn-dialog { width: min(calc(100% - 32px), 410px); padding: 22px; border: 0; border-radius: 16px; color: #1f2831; box-shadow: 0 22px 58px rgba(0,0,0,.25); }
.burn-dialog::backdrop { background: rgba(17,24,31,.65); }
.burn-dialog p:not(.form-error) { margin: 9px 0 0; color: #59636d; font-size: 14px; line-height: 1.65; }
.burn-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.burn-actions button { min-height: 42px; padding: 0 12px; border: 0; border-radius: 8px; background: #eee; color: #3e4851; font-size: 13px; font-weight: 650; cursor: pointer; }
.burn-actions .danger-button { background: #a72e2e; color: #fff; }
.burn-actions button:disabled { opacity: .55; cursor: wait; }
.background-panel { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; border-bottom: 1px solid #d9d9d9; background: rgba(250,250,250,.97); color: #6d767b; font-size: 12px; flex: 0 0 auto; }
.background-options { display: flex; gap: 9px; }
.background-choice { width: 28px; height: 28px; padding: 3px; border: 1px solid transparent; border-radius: 50%; background: transparent; cursor: pointer; }
.background-choice i { display: block; width: 100%; height: 100%; border-radius: 50%; }
.background-choice[data-background="classic"] i { background: #e8e8e8; }
.background-choice[data-background="dawn"] i { background: linear-gradient(135deg, #ffd6a4, #d8e8fa); }
.background-choice[data-background="mint"] i { background: linear-gradient(135deg, #b9eed0, #cae2f7); }
.background-choice[data-background="night"] i { background: linear-gradient(135deg, #1d2c3e, #577796); }
.background-choice.is-selected { border-color: #10b768; box-shadow: 0 0 0 2px rgba(16,183,104,.15); }
.background-upload { min-height: 27px; padding: 5px 8px; border-radius: 5px; background: #e5f5ed; color: #087e4d; font-size: 11px; font-weight: 650; cursor: pointer; }
.background-upload input { display: none; }
.background-upload.is-selected { box-shadow: 0 0 0 2px rgba(16,183,104,.2); }
.typing-indicator { display: flex; align-items: center; gap: 8px; margin: 7px 13px -1px; padding: 8px 11px; border-radius: 9px; background: linear-gradient(90deg, #e0faec, #f3fffa); color: #078750; font-size: 13px; box-shadow: 0 2px 9px rgba(8,155,91,.12); flex: 0 0 auto; }
.typing-indicator strong { font-weight: 700; letter-spacing: .2px; }
.typing-dots { display: flex; align-items: end; gap: 3px; height: 13px; }
.typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: #0bae68; animation: typing-bounce 1s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .42; } 30% { transform: translateY(-5px); opacity: 1; } }
.notice { margin: 8px 16px 0; padding: 8px 11px; border-radius: 8px; background: #fff3d9; color: #956b24; font-size: 12px; line-height: 1.4; z-index: 2; }
.messages { flex: 1 1 auto; overflow-y: auto; padding: 17px 13px 16px; scroll-behavior: smooth; }
.chat-screen[data-background="night"] .messages { color: #eef5fb; }
.chat-screen[data-background="night"] .message-meta { color: #c0ccd6; }
.chat-screen[data-background="night"] .empty-state { color: #b9c5ce; }
.chat-screen[data-background="night"] .empty-state strong { color: #e4edf3; }
.chat-screen[data-background="night"] .empty-lock { background: rgba(255,255,255,.13); color: #c2d1dc; }
.chat-screen[data-background="custom"] .messages { background-image: linear-gradient(rgba(16,31,41,.13), rgba(16,31,41,.13)), var(--shared-background-image); background-position: center; background-size: cover; background-attachment: local; }
.chat-screen[data-background="custom"] .message-meta { color: rgba(255,255,255,.86); text-shadow: 0 1px 2px rgba(0,0,0,.45); }
.chat-screen[data-background="custom"] .empty-state { color: rgba(255,255,255,.8); text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.chat-screen[data-background="custom"] .empty-state strong { color: #fff; }
.chat-screen[data-background="custom"] .empty-lock { background: rgba(255,255,255,.2); color: #fff; }
.empty-state { position: absolute; top: 46%; left: 20px; right: 20px; transform: translateY(-50%); display: flex; align-items: center; flex-direction: column; gap: 8px; pointer-events: none; color: #9a9a9a; font-size: 12px; }
.empty-state strong { color: #777; font-size: 14px; font-weight: 550; margin-top: 3px; }
.empty-state.is-hidden { display: none; }
.empty-lock { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: #dfdfdf; color: #8b9396; font-size: 22px; }
.message-row { display: flex; gap: 9px; margin: 0 0 15px; align-items: flex-start; }
.message-row.mine { flex-direction: row-reverse; }
.avatar { width: 35px; height: 35px; flex: 0 0 35px; border-radius: 5px; display: grid; place-items: center; font-size: 13px; color: #fff; background: linear-gradient(145deg, #5f93dc, #6c74ca); }
.mine .avatar { background: linear-gradient(145deg, #00b96b, #08a35e); }
.message-content { min-width: 0; max-width: min(75vw, 510px); }
.message-meta { margin: 1px 2px 4px; color: #999; font-size: 10px; line-height: 1.2; }
.mine .message-meta { text-align: right; }
.bubble { position: relative; padding: 9px 11px; border-radius: 4px; background: #fff; color: #171717; font-size: 15px; line-height: 1.48; box-shadow: 0 1px 1px rgba(0,0,0,.025); word-break: break-word; white-space: pre-wrap; }
.bubble::before { content: ""; position: absolute; left: -6px; top: 10px; width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-right: 7px solid #fff; }
.mine .bubble { background: #a8e869; }
.mine .bubble::before { left: auto; right: -6px; border-right: 0; border-left: 7px solid #a8e869; }
.attachment-card { margin-top: 8px; min-width: 160px; max-width: 255px; overflow: hidden; border-radius: 5px; background: rgba(255,255,255,.48); }
.attachment-load { width: 100%; border: 0; padding: 10px; background: transparent; color: #28715a; text-align: left; cursor: pointer; font-size: 13px; }
.attachment-card img, .attachment-card video { display: block; width: 100%; max-height: 300px; object-fit: contain; background: #222; }
.file-link { display: flex; align-items: center; gap: 8px; padding: 11px; color: #275f95; text-decoration: none; font-size: 13px; word-break: break-all; }
.file-link::before { content: "▣"; color: #4f98dc; font-size: 21px; }
.composer { flex: 0 0 auto; padding: 7px 11px max(9px, env(safe-area-inset-bottom)); border-top: 1px solid #d6d6d6; background: #f7f7f7; }
.composer textarea { display: block; width: 100%; height: 38px; max-height: 104px; padding: 8px 10px; border: 0; border-radius: 6px; outline: none; resize: none; background: #fff; color: #202020; font-size: 15px; line-height: 22px; }
.composer textarea:focus { box-shadow: 0 0 0 1px #75cfa3; }
.composer-actions { min-height: 31px; margin-top: 6px; display: flex; align-items: center; justify-content: space-between; }
.attachment-actions { display: flex; align-items: center; gap: 1px; }
.attach-button { width: 36px; height: 30px; display: grid; place-items: center; color: #737d84; font-size: 21px; cursor: pointer; }
.attach-button input { display: none; }
.send-button { min-width: 58px; height: 30px; padding: 0 12px; border: 0; border-radius: 4px; background: #10b768; color: #fff; font-size: 13px; cursor: pointer; }
.file-preview { display: flex; overflow-x: auto; gap: 7px; margin: 0 0 7px; padding-bottom: 1px; }
.file-chip { max-width: 170px; flex: 0 0 auto; display: flex; align-items: center; gap: 5px; padding: 5px 6px 5px 9px; border-radius: 5px; color: #555; background: #e4e7e7; font-size: 11px; white-space: nowrap; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; }
.file-chip button { border: 0; padding: 0 2px; background: none; color: #888; cursor: pointer; font-size: 16px; }
.toast { position: fixed; left: 50%; bottom: calc(85px + env(safe-area-inset-bottom)); z-index: 10; max-width: calc(100vw - 44px); padding: 9px 13px; border-radius: 18px; transform: translate(-50%, 20px); opacity: 0; background: rgba(26,31,34,.9); color: #fff; font-size: 12px; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 760px) {
  body { background: radial-gradient(circle at 50% 0, #f7f7f7, #cbd0d2); }
  .chat-screen { box-shadow: 0 0 40px rgba(30,40,46,.18); }
  .unlock-screen { align-items: center; }
  .unlock-hero { width: 440px; }
}
