:root{
  --accent: #3f4cdb;
  --accent-soft: #e8e9fb;
  --today: #e23a3a;
  --bg: #ffffff;
  --fg: #1b1d27;
  --muted: #767c88;
  --grid-line: #ecedf2;
  --weekend-bg: #fafafe;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark){
  :root{
    --accent: #6c7bff;
    --accent-soft: #23263a;
    --today: #ff5a5a;
    --bg: #101119;
    --fg: #f1f2fa;
    --muted: #9196a8;
    --grid-line: #232534;
    --weekend-bg: #15172200;
  }
}
*{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html,body{ height:100%; margin:0; }
body{
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overflow: hidden;
}

#calendar{ height:100%; display:flex; flex-direction:column; padding: 14px 10px; }
#cal-header{ display:flex; align-items:center; justify-content:space-between; padding: 6px 4px 10px; }
#cal-header h1{
  font-size: 18px; font-weight:600; margin:0; cursor:pointer; user-select:none;
  padding: 6px 14px; border-radius: 10px;
}
#cal-header h1:active{ background: var(--accent-soft); }
.nav-btn{
  border:none; background:none; color: var(--accent); font-size:24px; line-height:1;
  width:40px; height:40px; border-radius:50%; cursor:pointer;
}
.nav-btn:active{ background: var(--accent-soft); }

#weekdays{ display:grid; grid-template-columns: repeat(7,1fr); text-align:center; color:var(--muted); font-size:12px; padding: 4px 0; flex-shrink:0; }
#grid{ flex:1; display:grid; grid-template-columns: repeat(7,1fr); grid-auto-rows: 1fr; gap:2px; min-height:0; }

.day-cell{
  position:relative; border-radius:10px; display:flex; flex-direction:column;
  align-items:center; justify-content:flex-start; padding-top:6px; cursor:pointer;
  font-size:14px; color:var(--fg);
}
.day-cell:active{ background: var(--accent-soft); }
.day-cell.other-month{ color: var(--muted); opacity:0.45; }
.day-cell.today .day-num{
  background: var(--today); color:#fff; border-radius:50%;
  width:26px; height:26px; display:flex; align-items:center; justify-content:center;
}
.day-dot{ width:5px; height:5px; border-radius:50%; background:var(--accent); margin-top:3px; }

/* sheets / overlays */
.sheet{ position:fixed; inset:0; z-index:20; display:flex; align-items:flex-end; }
.sheet.hidden{ display:none; }
.sheet.full{ align-items:stretch; background: var(--bg); }
.sheet:not(.full){ background: rgba(0,0,0,0.25); }
.sheet-card{
  background: var(--bg); width:100%; border-radius: 18px 18px 0 0; padding: 16px 18px 22px;
  max-height: 80vh; overflow-y:auto;
}
.sheet-head{ display:flex; align-items:center; justify-content:space-between; font-weight:600; font-size:15px; padding: 2px 2px 10px; }
.icon-btn{ background:none; border:none; color:var(--muted); font-size:18px; cursor:pointer; padding:6px 8px; }
.hint{ color:var(--muted); font-size:13px; line-height:1.4; }
.error{ color:#e5534b; font-size:13px; min-height:16px; }

.sheet-row{ display:flex; gap:8px; margin-top:8px; }
.sheet-row input{ flex:1; }
input[type="text"], input[type="number"]{
  border:1px solid var(--grid-line); border-radius:10px; padding:10px 12px; font-size:14px;
  background: var(--bg); color: var(--fg); font-family: var(--font);
}
.pill-btn{
  border:none; border-radius:999px; padding:10px 20px; font-size:14px; font-weight:600;
  background: var(--accent); color:#fff; cursor:pointer;
}
.pill-btn:disabled{ opacity:0.5; }

.setup-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; margin:12px 0; }
.setup-grid label{ display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--muted); }

#existingEvents .ev-row{ display:flex; justify-content:space-between; align-items:center; padding:6px 2px; font-size:14px; border-bottom:1px solid var(--grid-line); }
#existingEvents .ev-row button{ border:none; background:none; color:var(--muted); cursor:pointer; }

/* messaging space */
#msgSpace{ flex-direction:column; }
.pane{ flex:1; display:flex; flex-direction:column; overflow:hidden; }
.pane.hidden{ display:none; }

#pseudoScreen, #encScreen{ align-items:center; justify-content:center; gap:14px; padding:24px; text-align:center; }
#pseudoInput, #encInput{ width:240px; text-align:center; font-size:16px; letter-spacing:2px; }

#contactsScreen:not(.hidden){ overflow-y:auto; padding-bottom:10px; }
.home-section{ padding:12px 16px 4px; border-bottom:1px solid var(--grid-line); }
.home-title{ font-size:12px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:0.04em; padding:6px 0; }
#requestsList, #discussionsList{ min-height:0; }
.contact-row{ display:flex; align-items:center; gap:10px; padding:10px 2px; cursor:pointer; }
.contact-row:active{ background: var(--accent-soft); }
.contact-row .ghost-btn, .contact-row .pill-btn{ font-size:12px; padding:7px 12px; }
.ghost-btn{ border:1px solid var(--grid-line); background:none; color:var(--fg); border-radius:999px; cursor:pointer; }
.avatar{ width:34px; height:34px; border-radius:50%; background:var(--accent); color:#fff; display:flex; align-items:center; justify-content:center; font-size:14px; font-weight:600; flex-shrink:0; }
.empty-note{ text-align:center; color:var(--muted); font-size:13px; padding:16px 10px; }

/* best-effort privacy guard: blurs the moment the app loses focus or is
   backgrounded (reduces exposure in app-switcher previews, over-the-shoulder
   glances). This does NOT and CANNOT block an actual OS-level screenshot —
   no web standard exposes that control to a page. */
#msgSpace{ -webkit-user-select:none; user-select:none; }
#msgSpace.privacy-blur{ filter: blur(22px); transition: filter 0.12s ease; }

.thread-head{ display:flex; align-items:center; gap:6px; padding: 10px 10px; border-bottom:1px solid var(--grid-line); font-weight:600; flex-shrink:0; }
#thread{ flex:1; overflow-y:auto; padding:12px 14px; display:flex; flex-direction:column; gap:7px; }
.bubble{ max-width:78%; padding:9px 13px; border-radius:16px; font-size:14px; line-height:1.35; word-break:break-word; white-space:pre-wrap; }
.bubble.mine{ align-self:flex-end; background:var(--accent); color:#fff; border-bottom-right-radius:4px; }
.bubble.theirs{ align-self:flex-start; background:var(--accent-soft); color:var(--fg); border-bottom-left-radius:4px; }
#composer{ display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--grid-line); flex-shrink:0; }
#composer input{ flex:1; }

/* desktop: keep the phone-shaped layout centered instead of stretching edge to edge */
@media (min-width: 640px){
  body{ background: var(--weekend-bg, var(--bg)); display:flex; align-items:center; justify-content:center; }
  #calendar{
    width:420px; height:780px; max-height:92vh;
    border-radius:28px; box-shadow:0 20px 60px rgba(0,0,0,0.18);
    background: var(--bg); overflow:hidden;
  }
  #msgSpace, #dayEditor, #setupSheet{
    /* these overlays are fixed to the viewport; pin them to the same
       centered frame instead of covering the whole monitor */
    position:absolute; inset:auto; width:420px; height:780px; max-height:92vh;
    left:50%; top:50%; transform:translate(-50%,-50%);
    border-radius:28px; overflow:hidden; box-shadow:0 20px 60px rgba(0,0,0,0.18);
  }
}
