/* Logbook: message ledger. Paper, ink, one accent. No bubbles, no rounded corners. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", Helvetica, Arial, sans-serif; background: #fdfcf6; color: #201a15; }
#app { display: flex; height: 100vh; }

#sidebar { width: 300px; min-width: 260px; background: #fdfcf6; border-right: 2px solid #201a15; display: flex; flex-direction: column; }
.side-header { padding: 18px 16px 14px; border-bottom: 2px solid #201a15; }
.brand { display: flex; align-items: center; gap: 10px; font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 700; line-height: 1; }
.brand-logo { width: 30px; height: 30px; }
.tagline { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: #c2410c; margin-top: 6px; }
.me { margin-top: 12px; font-size: 13.5px; color: #7a7264; }
.me button { margin-left: 8px; border: 0; background: none; color: #c2410c; cursor: pointer; font-size: 13px; text-decoration: underline; padding: 0; }
.new-room { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid #ddd5c2; }
.new-room input { flex: 1; border: 1px solid #201a15; border-radius: 0; background: #fff; padding: 9px 10px; font-size: 14px; }
.new-room button { border: 1px solid #201a15; background: #201a15; color: #fdfcf6; border-radius: 0; padding: 9px 12px; cursor: pointer; font-size: 14px; }
#roomList { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#roomList li { padding: 11px 14px; cursor: pointer; border-bottom: 1px solid #ddd5c2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
#roomList li:hover { background: #f2edde; }
#roomList li.active { background: #201a15; color: #fdfcf6; }
#status { padding: 10px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #7a7264; }

#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px 12px; border-bottom: 2px solid #201a15; }
#roomName { font-family: Georgia, "Times New Roman", serif; font-size: 21px; font-weight: 700; }
#roomUsers { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #7a7264; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
#roomPin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #c2410c; margin-top: 3px; }
#deleteRoomBtn { display: none; border: 1px solid #c2410c; background: transparent; color: #c2410c; border-radius: 0; padding: 8px 12px; cursor: pointer; font-size: 14px; white-space: nowrap; }
body.admin #deleteRoomBtn, body.roomadmin #deleteRoomBtn { display: inline-block; }
#messages { flex: 1; overflow-y: auto; padding: 4px 24px 20px; }
.msg { padding: 13px 0 13px 12px; border-bottom: 1px solid #ddd5c2; border-left: 3px solid transparent; overflow-wrap: break-word; }
.msg.own { border-left-color: #c2410c; }
.msg-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.msg .who { font-size: 13.5px; font-weight: 700; }
.msg.own .who { color: #c2410c; }
.msg .time { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #7a7264; }
.msg .body { font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.55; }
.msg img.attached { max-width: 100%; border: 1px solid #201a15; display: block; margin-top: 8px; }
.file-card { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 9px 12px; border: 1px solid #201a15; background: #fff; font-size: 13.5px; }
.file-card .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.file-card .file-size { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #7a7264; white-space: nowrap; }
.file-card a { color: #c2410c; font-weight: 700; white-space: nowrap; }
.del-msg { display: none; }
body.admin .del-msg, body.roomadmin .del-msg { display: inline-block; border: 0; background: none; color: #c2410c; cursor: pointer; font-size: 12px; text-decoration: underline; padding: 0; margin-top: 6px; }

#fileChip { display: flex; align-items: center; gap: 10px; background: #f2edde; border-top: 1px solid #ddd5c2; padding: 10px 16px; font-size: 14px; }
#fileChip img { max-height: 64px; border: 1px solid #201a15; }
#fileChip button { border: 0; background: none; color: #c2410c; cursor: pointer; font-size: 13px; text-decoration: underline; padding: 0; }
#sendForm { display: flex; gap: 10px; background: #fdfcf6; border-top: 2px solid #201a15; padding: 12px 16px; }
#sendForm input[type="text"] { flex: 1; border: 1px solid #201a15; border-radius: 0; background: #fff; padding: 11px 14px; font-size: 15px; outline: none; }
#sendForm button { border-radius: 0; padding: 11px 18px; cursor: pointer; font-size: 15px; }
#sendForm button[type="submit"] { border: 1px solid #201a15; background: #201a15; color: #fdfcf6; }
#attachBtn { border: 1px solid #201a15; background: transparent; color: #201a15; }
.hidden { display: none !important; }

#nameOverlay, #roomGate, #roomPinOverlay, #roomCreatedOverlay { position: fixed; inset: 0; background: rgba(32,26,21,.55); display: flex; align-items: center; justify-content: center; }
#nameOverlay.hidden, #roomGate.hidden, #roomPinOverlay.hidden, #roomCreatedOverlay.hidden { display: none; }
#nameOverlay .card, #roomGate .card, #roomPinOverlay .card, #roomCreatedOverlay .card { background: #fdfcf6; border: 2px solid #201a15; border-radius: 0; box-shadow: 6px 6px 0 #201a15; padding: 24px; width: 320px; max-width: 90vw; }
#nameOverlay h2, #roomGate h2, #roomPinOverlay h2, #roomCreatedOverlay h2 { margin: 0 0 6px; font-family: Georgia, "Times New Roman", serif; font-size: 21px; }
#nameOverlay p, #roomGate p, #roomPinOverlay p, #roomCreatedOverlay p { margin: 0 0 14px; color: #7a7264; font-size: 14px; }
#nameOverlay input, #roomGate input, #roomPinOverlay input { width: 100%; border: 1px solid #201a15; border-radius: 0; padding: 10px 12px; font-size: 15px; margin-bottom: 12px; }
#nameOverlay button, #roomGate button, #roomPinOverlay button, #roomCreatedOverlay button { border: 1px solid #201a15; background: #201a15; color: #fdfcf6; border-radius: 0; padding: 10px 18px; cursor: pointer; font-size: 15px; }
#authError, #roomPinError, #gatePinError, #sidePinError { color: #c2410c; font-size: 14px; min-height: 18px; margin-bottom: 8px; }
#sidePinError { padding: 0 12px 8px; }
#gateRoomList { list-style: none; margin: 8px 0 0; padding: 0; max-height: 40vh; overflow-y: auto; }
#gateRoomList li { padding: 11px 2px; cursor: pointer; border-bottom: 1px solid #ddd5c2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
#gateRoomList li:hover { background: #f2edde; }
#roomCreatedPin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 32px; letter-spacing: 6px; color: #c2410c; margin: 4px 0 18px; }
.row-btns { display: flex; gap: 10px; }
.row-btns .btn-cancel { background: transparent; color: #201a15; }
/* Lapisan overlay: layar PIN dan PIN room selalu di atas gate, gate di atas chat. */
#nameOverlay { z-index: 30; }
#roomGate { z-index: 20; }
#roomPinOverlay, #roomCreatedOverlay { z-index: 40; }

@media (max-width: 700px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; height: 38%; border-right: 0; border-bottom: 2px solid #201a15; }
  #messages { padding: 4px 14px 16px; }
}
