* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font-ui);
  background: #000; color: var(--c-text);
  display: flex; justify-content: center;
}

/* portrait mobile frame, centered on larger screens; clips the slide panels */
#frame {
  position: relative; overflow: hidden;
  width: 100%; max-width: 480px; height: 100dvh;
  background: var(--c-bg);
}

/* main app is a column: header / card / scrolling chat / composer */
#app { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
#app[hidden] { display: none; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--c-surface); border-bottom: 1px solid var(--c-line);
}
.topbar .title { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.icon {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--c-line);
  background: var(--c-bg); color: var(--c-text); font-size: 17px; cursor: pointer;
}

.todocard {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 24px);
  margin: 12px; padding: 13px 15px; text-align: left;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0,0,0,.05);
  font: inherit; color: inherit; cursor: pointer;
}
.todocard .todoic { width: 34px; height: 34px; border-radius: 9px; background: var(--c-primary); opacity: .9; flex: none; }
/* when tags exist, the square becomes a little cluster of up to 4 tag emojis */
.todocard .todoic.emoji { background: none; opacity: 1; border-radius: 0;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center; }
.todocard .todoic.emoji i { font-style: normal; width: 18px; height: 18px; font-size: 15px;
  line-height: 1; display: flex; align-items: center; justify-content: center; }
.todocard .todoic.emoji:has(i:only-child) i { width: 34px; height: 34px; font-size: 26px; }
.todocard .todotext { flex: 1; display: flex; flex-direction: column; }
.todocard .todotext b { font-size: 15px; }
.todocard .todotext small { color: var(--c-muted); }
.todocard .chev { color: var(--c-muted); font-size: 22px; }

.chat {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px 12px 12px;
}
.bub {
  max-width: 78%; padding: 9px 13px; border-radius: var(--radius); font-size: 15px; line-height: 1.35;
  word-wrap: break-word; white-space: pre-wrap;
}
.bub.them { background: var(--c-bubble-other); color: var(--c-text); align-self: flex-start; border-bottom-left-radius: 5px; }
.bub.me   { background: var(--c-bubble-self);  color: var(--c-on-primary); align-self: flex-end; border-bottom-right-radius: 5px; }

.composer {
  display: flex; gap: 9px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--c-surface); border-top: 1px solid var(--c-line);
}
.composer input {
  flex: 1; padding: 11px 15px; border: 1px solid var(--c-line); border-radius: 999px;
  background: var(--c-bg); color: var(--c-text); font: inherit;
}
.composer button {
  padding: 11px 18px; border: 0; border-radius: 999px;
  background: var(--c-primary); color: var(--c-on-primary); font: inherit; font-weight: 600; cursor: pointer;
}

/* landing (no token yet) */
.landing { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--c-bg); padding: 24px; }
.landing[hidden] { display: none; }
.landingcard { position: relative; width: 100%; max-width: 320px; text-align: center; }
.landingcard .flag {
  position: absolute; top: -8px; right: 0; width: auto; padding: 6px 8px;
  background: transparent; border: 1px solid var(--c-line); border-radius: 10px;
  font-size: 20px; line-height: 1; cursor: pointer;
}
.landingcard h1 { font-family: var(--font-display); font-size: 30px; margin: 0 0 12px; }
.landingcard p { color: var(--c-muted); margin: 0 0 26px; line-height: 1.5; font-size: 16px; }
.landingcard button {
  width: 100%; padding: 14px; border: 0; border-radius: 14px;
  background: var(--c-primary); color: var(--c-on-primary); font: inherit; font-weight: 600; cursor: pointer;
}

/* pincode gate */
.lock { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--c-bg); padding: 24px; }
.lock[hidden] { display: none; }
.lockcard { width: 100%; max-width: 300px; text-align: center; }
.lockcard h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 4px; }

.pindots { display: flex; gap: 16px; justify-content: center; margin: 22px 0 30px; }
.pindots i {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--c-muted);
  transition: background .1s, border-color .1s, transform .1s;
}
.pindots i.on { background: var(--c-primary); border-color: var(--c-primary); transform: scale(1.1); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 280px; margin: 0 auto; }
.keypad button {
  aspect-ratio: 1; border: 1px solid var(--c-line); border-radius: 50%;
  background: var(--c-surface); color: var(--c-text);
  font-family: var(--font-ui); font-size: 26px; cursor: pointer;
  transition: background .1s, transform .05s;
}
.keypad button:active { background: var(--c-bg); transform: scale(.95); }
.keypad button.back { border: 0; background: transparent; font-size: 22px; }
.keypad span { visibility: hidden; }
.msg { margin-top: 12px; font-size: 14px; min-height: 1.2em; }
.msg.err { color: #c0392b; }
.textlink { display: inline-block; margin-top: 18px; color: var(--c-muted); font-size: 14px; text-decoration: none; }
.textlink[hidden] { display: none; }
.textlink:hover { color: var(--c-text); }

/* slide-in panels (edit todo, settings) */
.panel {
  position: absolute; inset: 0; z-index: 20;
  background: var(--c-bg); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s ease;
}
.panel.open { transform: translateX(0); }
.panelhead {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; background: var(--c-surface); border-bottom: 1px solid var(--c-line);
}
.panelhead .title { font-family: var(--font-display); font-weight: 700; font-size: 18px; flex: 1; text-align: center; }
.panelhead .icon { font-size: 22px; }
.panelhead .spacer { width: 36px; }
.panelbody { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }
.panelfoot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--c-line); background: var(--c-surface); }
.panelfoot button, .modalbtns button {
  width: 100%; padding: 13px; border: 0; border-radius: 14px;
  background: var(--c-primary); color: var(--c-on-primary); font: inherit; font-weight: 600; cursor: pointer;
}

#todoDesc {
  width: 100%; min-height: 120px; padding: 12px; resize: vertical;
  border: 1px solid var(--c-line); border-radius: var(--radius);
  background: var(--c-surface); color: var(--c-text); font: inherit;
}
.seclabel { font-size: 13px; color: var(--c-muted); margin: 18px 0 8px; font-weight: 600; }

/* selectable chips (suggested time, single) + pills (tags, multi) */
.chips, .pills { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .pill {
  border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-text);
  border-radius: 999px; padding: 7px 13px; font-size: 14px; cursor: pointer; user-select: none;
}
.chip.on, .pill.on { background: var(--c-accent); color: var(--c-on-primary); border-color: transparent; }
.pill.add { border-style: dashed; color: var(--c-muted); font-weight: 600; padding-inline: 15px; }
/* tag editor */
.pilledit { display: flex; gap: 8px; margin-bottom: 18px; }
.pilledit input {
  padding: 12px; border: 1px solid var(--c-line); border-radius: 12px; font: inherit;
  background: var(--c-bg); color: var(--c-text); box-sizing: border-box;
}
.pilledit .pe-emoji { width: 64px; text-align: center; flex: none; }
.pilledit .pe-emoji::placeholder { opacity: 0.4; }  /* faint cloud hint until an emoji is set */
.pe-cats { margin: 14px 0 0; }  /* category toggle pills above the button row */
.pe-cats[hidden] { display: none; }  /* .chips' display:flex otherwise beats the hidden attr */
.modalbtns .pe-dice { margin-right: auto; font-size: 18px; padding-inline: 14px; }  /* far left */
.pilledit .pe-label { flex: 1; min-width: 0; }
.pe-desc {
  width: 100%; box-sizing: border-box; padding: 12px; resize: vertical;
  border: 1px solid var(--c-line); border-radius: 12px; font: inherit;
  background: var(--c-bg); color: var(--c-text);
}
.modalbtns .ghost.danger { color: #c0392b; margin-right: auto; }
.pilltitle { font-family: var(--font-display); margin: 0 0 12px; }
.modalcard .pill.hasdesc { cursor: pointer; }
.modalcard .pill.hasdesc::after { content: "ⓘ"; margin-left: 5px; opacity: .7; }

/* view modal */
.modal { position: absolute; inset: 0; z-index: 30; display: none; place-items: center;
  background: rgba(0,0,0,.4); padding: 20px; }
.modal.open { display: grid; }
.modalcard {
  width: 100%; max-width: 380px; background: var(--c-surface); color: var(--c-text);
  border-radius: var(--radius); padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.dialogmsg { font-size: 16px; line-height: 1.45; }
.viewdesc { font-size: 16px; line-height: 1.45; }
.viewdesc h1, .viewdesc h2, .viewdesc h3 { margin: .4em 0; }
/* links follow the selected accent; visited ("walked") is a muted blend of it */
.viewdesc a { color: var(--c-accent); text-decoration: underline; }
.viewdesc a:visited { color: color-mix(in srgb, var(--c-accent) 55%, var(--c-muted)); }
.viewtime { color: var(--c-muted); margin: 12px 0; }
.modalcard .pill { cursor: default; }
.modalbtns { display: flex; gap: 10px; margin-top: 18px; }  /* uniform gap above the buttons */
.modalbtns .ghost { background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-line); }

/* settings */
.setcard {
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.setlabel { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); margin: 0 0 10px; }
/* a second sub-label in a card (e.g. Language under Appearance) needs space above it */
.setlabel:not(:first-child) { margin-top: 18px; }
.fld { display: flex; flex-direction: column; font-size: 13px; color: var(--c-muted); margin-bottom: 10px; gap: 4px; }
.fld:last-child { margin-bottom: 0; }
.fld input {
  padding: 11px 12px; border: 1px solid var(--c-line); border-radius: 12px;
  background: var(--c-bg); color: var(--c-text); font: inherit;
}
.fld input:disabled { opacity: .6; }
.setcard p { color: var(--c-muted); margin: 0 0 10px; font-size: 14px; }
.setcard .partner-name { font-size: 16px; font-weight: 600; }
.setcard input.invitelink {
  width: 100%; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--c-line); border-radius: 12px;
  background: var(--c-bg); color: var(--c-text); font: inherit; font-size: 13px;
}
.setcard button.invite, .setcard button.share {
  width: 100%; padding: 11px; margin-top: 8px; border: 0; border-radius: 12px;
  background: var(--c-primary); color: var(--c-on-primary); font: inherit; font-weight: 600; cursor: pointer;
}

.seg { display: flex; border: 1px solid var(--c-line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; padding: 10px; border: 0; background: var(--c-bg); color: var(--c-text); font: inherit; cursor: pointer; }
.seg button.on { background: var(--c-primary); color: var(--c-on-primary); }

.accent { display: flex; gap: 10px; margin-top: 12px; }
.accent .sw { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.accent .sw.on { border-color: var(--c-text); }
.accent .sw.default { background: var(--c-bg); border: 2px dashed var(--c-line); position: relative; }

.logout {
  width: 100%; padding: 13px; margin-top: 4px; border: 1px solid var(--c-line); border-radius: 14px;
  background: var(--c-surface); color: #c0392b; font: inherit; font-weight: 600; cursor: pointer;
}

/* superuser page */
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.switchrow input { width: 20px; height: 20px; accent-color: var(--c-primary); flex: none; }
#suNewInvite { width: 100%; margin-top: 10px; padding: 11px; border: 1px solid var(--c-line);
  border-radius: 12px; background: var(--c-bg); color: var(--c-text); font: inherit; font-weight: 600; cursor: pointer; }
.sumuted { color: var(--c-muted); margin: 0 0 8px; font-size: 14px; }
.invrow { display: flex; align-items: center; gap: 8px; padding: 8px 0; flex-wrap: wrap;
  border-top: 1px solid var(--c-line); }
.invrow:first-child { border-top: 0; }
.invrow code { font-family: ui-monospace, monospace; font-size: 13px; background: var(--c-bg);
  border: 1px solid var(--c-line); border-radius: 8px; padding: 3px 7px; }
.invrow.used code { opacity: .5; text-decoration: line-through; }
.invrow .subadge { font-size: 12px; color: var(--c-muted); }
.invrow button.small { width: auto; margin: 0; padding: 5px 10px; font-size: 13px; border-radius: 9px;
  border: 1px solid var(--c-line); background: var(--c-bg); color: var(--c-text); font: inherit; cursor: pointer; }
.invrow button.small.danger { color: #c0392b; margin-left: auto; }
.accrow { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; font-size: 14px;
  border-top: 1px solid var(--c-line); }
.accrow:first-child { border-top: 0; }
.accrow span { flex: 1; }
.accrow small { color: var(--c-muted); font-size: 12px; }
