* { box-sizing: border-box; margin: 0; padding: 0; }
:root { --bg:#faf5f2; --card:#fff; --accent:#e4557a; --muted:#9a8f8a; --line:#eadfdb; }
body { font-family: system-ui, sans-serif; background: var(--bg); color: #2b2320;
  min-height: 100vh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
#app { max-width: 560px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin-bottom: 16px; }
.header { display:flex; align-items:center; gap:12px; margin-bottom:16px; }
.header .spacer { flex:1; }
button { font: inherit; cursor: pointer; border: none; border-radius: 10px;
  background: var(--accent); color:#fff; padding: 12px 16px; }
button.ghost { background: transparent; color: var(--accent); padding: 8px; }
input { font: inherit; width: 100%; padding: 12px; border:1px solid var(--line);
  border-radius: 10px; background: var(--card); }
.field { margin-bottom: 12px; }
.card { background: var(--card); border:1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-bottom: 10px; display:flex; align-items:center; gap:12px; }
.card .grow { flex:1; }
.row-add { display:flex; gap:8px; position: sticky; bottom: 8px; margin-top: 12px; }
.row-add input { flex:1; }
.item.checked .grow { text-decoration: line-through; color: var(--muted); }
.chk { width: 24px; height: 24px; flex: none; accent-color: var(--accent); cursor: pointer; }
.switch { cursor: pointer; }
.hub { cursor: pointer; }
.ico { width: 1.15em; height: 1.15em; vertical-align: -0.18em; }
.hub-ico { flex: none; color: var(--accent); display: inline-flex; }
.hub-ico .ico { width: 26px; height: 26px; }
.row-ico { color: var(--accent); display: inline-flex; vertical-align: -0.2em; }
.btn-ico { display: inline-flex; vertical-align: -0.2em; }
.chevron { color: var(--muted); display: inline-flex; }
.card.total { background: transparent; border-style: dashed; }
.card.total.grand { border-style: solid; border-color: var(--accent); }
.amount { white-space: nowrap; }
.exp-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.exp-row { display: flex; gap: 8px; }
select { font: inherit; width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-actions { display: flex; gap: 8px; margin-top: 16px; }
.cal-actions button { flex: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: .72rem; color: var(--muted); padding: 4px 0; }
.cal-cell { position: relative; aspect-ratio: 1; display: flex; align-items: center;
  justify-content: center; border-radius: 10px; background: var(--card);
  border: 1px solid var(--line); cursor: pointer; font-size: .9rem; }
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.selected { background: var(--accent); color: #fff; }
.cal-cell .dot { position: absolute; bottom: 6px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent); }
.cal-cell.selected .dot { background: #fff; }
.day-title { font-size: 1.1rem; margin: 18px 0 10px; }
.month-head { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 18px 2px 8px; }
.month-head:first-child { margin-top: 4px; }
.date-chip { flex: none; width: 44px; height: 44px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); display: flex;
  flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.date-chip b { font-size: 1.1rem; }
.date-chip small { font-size: .62rem; color: var(--muted); text-transform: uppercase; }
.mini { flex: 1; font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
input[type=date], input[type=time] { font: inherit; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); width: 100%; }
.seg { display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; background: transparent; color: var(--muted); padding: 10px; border-radius: 9px; }
.seg button.active { background: var(--accent); color: #fff; }
.sched-day { margin-bottom: 12px; }
.sched-day-head { display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; margin-bottom: 6px; }
.sched-day-head .wd-today { color: var(--accent); }
.sched-day-head .add-slot { padding: 4px; }
.sched-slots { display: flex; flex-direction: column; gap: 6px; }
.slot { display: flex; gap: 10px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.slot-ov { border-left-style: dashed; }
.slot-time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: .85rem; white-space: nowrap; }
.slot-title { flex: 1; }
.danger { color: #c0392b; }

/* Chat */
#chat-fab[hidden], #chat-panel[hidden], #rec-bar[hidden], #chat-file[hidden], #sel-bar[hidden] { display: none !important; }
#sel-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--card); border-bottom: 1px solid var(--line); }
#sel-bar .spacer { flex: 1; }
#sel-bar button { padding: 8px 12px; }
#sel-bar .danger { background: transparent; }
#chat-panel.selecting .msg { cursor: pointer; }
.msg.selected .bubble { outline: 2px solid var(--accent); outline-offset: 2px; }
#chat-panel.selecting .msg-media { pointer-events: none; }
#chat-fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  z-index: 50; padding: 0; }
#chat-fab .ico { width: 26px; height: 26px; }
#chat-panel { position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
.chat-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
#chat-msgs { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; flex-direction: column; max-width: 78%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }
.msg-who { font-size: .7rem; color: var(--muted); margin: 0 6px 2px; }
.bubble { padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  word-break: break-word; }
.msg.me .bubble { background: var(--accent); color: #fff; border-color: var(--accent); }
.msg-media { max-width: 100%; border-radius: 10px; display: block; }
.msg.pending .bubble { opacity: .75; }
.msg-status { font-size: .65rem; margin-top: 4px; opacity: .85; }
.msg-status.fail { color: #ffe08a; font-weight: 600; opacity: 1; }
.msg .bubble audio { width: 220px; max-width: 60vw; }
.chat-input { display: flex; align-items: center; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--line); background: var(--card); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.chat-input input#chat-text { flex: 1; }
.chat-input button:not(.ghost) { padding: 10px 12px; }
#rec-bar { padding: 8px 16px; background: #fdecef; color: #c0392b; display: flex; gap: 10px; align-items: center; }
#rec-bar button { padding: 6px 10px; }
.error { color:#c0392b; margin-bottom:12px; min-height:1.2em; }
.meta { font-size:.72rem; color: var(--muted); }
.grow .meta { display:block; margin-top:2px; }
.clickable { cursor:pointer; }
#install-btn { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); }
