/* Kinmate — iOS-native feel, Signal calm. Tokens first, then layout, then components. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Inter, system-ui, sans-serif;
  --bg: #ffffff;
  --bg-grouped: #f2f2f7;
  --bg-elevated: #ffffff;
  --fill: #e9e9eb;
  --fill-2: rgba(120, 120, 128, 0.16);
  --fill-3: rgba(120, 120, 128, 0.1);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.29);
  --blue: #007aff; --green: #34c759; --orange: #ff9500; --purple: #af52de; --pink: #ff2d55; --teal: #32ade6; --indigo: #5856d6; --red: #ff3b30; --yellow: #ffcc00;
  --accent: var(--blue);
  --bubble-out: #007aff;
  --bubble-in: #e9e9eb;
  --bubble-in-text: #000;
  --glass: rgba(249, 249, 249, 0.86);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --nav-h: 52px;
  --tab-h: 50px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --bg-grouped: #000000; --bg-elevated: #1c1c1e; --fill: #2c2c2e; --fill-2: rgba(120, 120, 128, 0.24); --fill-3: rgba(120, 120, 128, 0.18);
    --label: #ffffff; --label-2: rgba(235, 235, 245, 0.6); --label-3: rgba(235, 235, 245, 0.3); --sep: rgba(84, 84, 88, 0.65);
    --blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --purple: #bf5af2; --pink: #ff375f; --teal: #64d2ff; --indigo: #5e5ce6; --red: #ff453a; --yellow: #ffd60a;
    --bubble-out: #0a84ff; --bubble-in: #26252a; --bubble-in-text: #fff; --glass: rgba(20, 20, 20, 0.82); --shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --bg-grouped: #000000; --bg-elevated: #1c1c1e; --fill: #2c2c2e; --fill-2: rgba(120, 120, 128, 0.24); --fill-3: rgba(120, 120, 128, 0.18);
  --label: #ffffff; --label-2: rgba(235, 235, 245, 0.6); --label-3: rgba(235, 235, 245, 0.3); --sep: rgba(84, 84, 88, 0.65);
  --blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --purple: #bf5af2; --pink: #ff375f; --teal: #64d2ff; --indigo: #5e5ce6; --red: #ff453a; --yellow: #ffd60a;
  --bubble-out: #0a84ff; --bubble-in: #26252a; --bubble-in-text: #fff; --glass: rgba(20, 20, 20, 0.82); --shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.3; color: var(--label); background: var(--bg-grouped); -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- app frame ---------- */
#app { height: 100dvh; display: flex; flex-direction: column; }
.frame { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg-grouped); }
.screen.plain { background: var(--bg); }
.content { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.content.pad { padding-bottom: 32px; }

.nav { flex: none; padding-top: var(--sat); background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: 0.5px solid var(--sep); z-index: 5; }
.nav-row { height: var(--nav-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 8px; }
.nav-row > :first-child { justify-self: start; }
.nav-row > :last-child { justify-self: end; }
.nav-title { font-size: 17px; font-weight: 600; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
.nav-title small { font-size: 12px; font-weight: 400; color: var(--label-2); }
.nav-btn { display: inline-flex; align-items: center; gap: 2px; height: 44px; padding: 0 8px; color: var(--accent); font-size: 17px; border-radius: 10px; }
.nav-btn:active { opacity: 0.5; }
.nav-btn.bold { font-weight: 600; }
.nav-btn:disabled { color: var(--label-3); }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: 0.37px; padding: 2px 16px 10px; }

.tabbar { flex: none; display: flex; height: calc(var(--tab-h) + var(--sab)); padding-bottom: var(--sab); background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 0.5px solid var(--sep); z-index: 5; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 500; color: var(--label-2); position: relative; }
.tab.active { color: var(--accent); }
.tab .badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }

@media (min-width: 900px) {
  #app { flex-direction: row; max-width: 1200px; margin: 0 auto; }
  .frame { flex-direction: row-reverse; }
  .tabbar { flex-direction: column; height: auto; width: 220px; padding: calc(var(--sat) + 16px) 12px 16px; border-top: 0; border-right: 0.5px solid var(--sep); gap: 2px; justify-content: flex-start; }
  .tab { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 15px; }
  .tab.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .tab .badge { position: static; margin-left: auto; }
  .screen { max-width: 820px; }
}

/* ---------- avatars, chips, buttons ---------- */
.avatar { flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; letter-spacing: 0.5px; background: var(--c, var(--blue)); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.c-blue { --c: var(--blue); } .c-green { --c: var(--green); } .c-orange { --c: var(--orange); } .c-purple { --c: var(--purple); } .c-pink { --c: var(--pink); } .c-teal { --c: var(--teal); } .c-indigo { --c: var(--indigo); } .c-red { --c: var(--red); } .c-gray { --c: #8e8e93; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 17px; font-weight: 600; color: var(--accent); min-height: 44px; padding: 0 16px; border-radius: 12px; transition: opacity 0.15s, transform 0.1s; }
.btn:active { opacity: 0.6; transform: scale(0.98); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.filled { background: var(--accent); color: #fff; width: 100%; min-height: 50px; }
.btn.gray { background: var(--fill); color: var(--label); }
.btn.tinted { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.btn.danger { color: var(--red); }
.btn.danger.filled { background: var(--red); color: #fff; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 15px; border-radius: 16px; }
.btn.green { --accent: var(--green); }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; padding: 8px 16px; }
.btn-row .btn { flex: 1; }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--fill); color: var(--label-2); white-space: nowrap; }
.chip.blue { background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); }
.chip.green { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.chip.orange { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.chip.red { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.chip.purple { background: color-mix(in srgb, var(--purple) 16%, transparent); color: var(--purple); }

.segmented { display: flex; background: var(--fill-2); border-radius: 9px; padding: 2px; margin: 12px 16px; }
.segmented button { flex: 1; height: 30px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--label); }
.segmented button.active { background: var(--bg-elevated); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); font-weight: 600; }

/* ---------- grouped lists ---------- */
.group { margin: 0 16px 8px; background: var(--bg-elevated); border-radius: var(--radius); overflow: hidden; }
.group-title { font-size: 13px; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.3px; padding: 24px 32px 7px; }
.group-title:first-child { padding-top: 16px; }
.group-foot { font-size: 13px; color: var(--label-2); padding: 6px 32px 8px; line-height: 1.35; }
.row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 16px; position: relative; width: 100%; text-align: left; color: var(--label); }
.row + .row::before, .row + .row-stack::before, .row-stack + .row::before, .row-stack + .row-stack::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; border-top: 0.5px solid var(--sep); }
.row.ind + .row::before, .row.ind + .row-stack::before { left: 56px; }
.row.tap:active { background: var(--fill-3); }
.row .ico { flex: none; width: 29px; height: 29px; border-radius: 7px; display: grid; place-items: center; color: #fff; background: var(--c, var(--blue)); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 14px; color: var(--label-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub.wrap { white-space: normal; }
.row .value { color: var(--label-2); font-size: 17px; flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--label-3); flex: none; margin-right: -4px; }
.row.danger { color: var(--red); }
.row.accent { color: var(--accent); }
.row-stack { padding: 10px 16px; position: relative; }

/* forms */
.frow { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; position: relative; }
.frow + .frow::before, .frow + .row::before, .row + .frow::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; border-top: 0.5px solid var(--sep); }
.frow label { flex: none; width: 108px; font-size: 17px; }
.frow input, .frow select { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; font-size: 17px; padding: 10px 0; color: var(--label); text-align: left; appearance: none; -webkit-appearance: none; }
.frow input::placeholder, textarea::placeholder { color: var(--label-3); }
.frow input[type="date"], .frow input[type="time"], .frow input[type="datetime-local"] { text-align: right; }
.frow select { text-align: right; direction: rtl; }
.frow select option { direction: ltr; }
.frow .inline-val { margin-left: auto; color: var(--label-2); }
.farea { padding: 10px 16px; position: relative; }
.farea + .farea::before, .frow + .farea::before, .farea + .frow::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; border-top: 0.5px solid var(--sep); }
.farea textarea { width: 100%; border: 0; background: transparent; outline: 0; font-size: 17px; resize: none; min-height: 88px; color: var(--label); }
.toggle { position: relative; width: 51px; height: 31px; border-radius: 16px; background: var(--fill-2); transition: background 0.2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.2s; }
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(20px); }
.field-err { color: var(--red); font-size: 14px; padding: 6px 32px; }

/* ---------- sheets, action sheets, toasts ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s ease-out; }
.sheet { width: 100%; max-width: 600px; max-height: calc(100dvh - var(--sat) - 12px); background: var(--bg-grouped); border-radius: 14px 14px 0 0; display: flex; flex-direction: column; animation: up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: var(--shadow); }
.sheet.plain { background: var(--bg); }
.sheet-nav { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 8px; min-height: 52px; border-bottom: 0.5px solid var(--sep); }
.sheet-nav > :first-child { justify-self: start; }
.sheet-nav > :last-child { justify-self: end; }
.sheet-nav .nav-title { font-size: 17px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 0 calc(24px + var(--sab)); }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 0; }
@media (min-width: 700px) {
  .sheet-bg { align-items: center; padding: 24px; }
  .sheet { border-radius: 14px; max-height: calc(100dvh - 48px); }
  .sheet .grabber { display: none; }
}
.action-bg { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.35); display: flex; align-items: flex-end; justify-content: center; padding: 8px; padding-bottom: calc(8px + var(--sab)); animation: fade 0.15s; }
.action { width: 100%; max-width: 420px; animation: up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.action .acts, .action .cancel { background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 13px; overflow: hidden; }
.action .acts { margin-bottom: 8px; }
.action .msg { padding: 14px 16px; text-align: center; font-size: 13px; color: var(--label-2); border-bottom: 0.5px solid var(--sep); }
.action .msg b { display: block; font-size: 15px; color: var(--label); margin-bottom: 2px; }
.action button { display: block; width: 100%; height: 57px; font-size: 20px; color: var(--accent); border-top: 0.5px solid var(--sep); }
.action button:first-child { border-top: 0; }
.action button:active { background: var(--fill-3); }
.action button.danger { color: var(--red); }
.action .cancel button { font-weight: 600; border: 0; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--sab) + 16px); transform: translateX(-50%); background: var(--label); color: var(--bg); padding: 10px 16px; border-radius: 20px; font-size: 15px; font-weight: 500; z-index: 100; box-shadow: var(--shadow); animation: up 0.25s; max-width: calc(100% - 32px); text-align: center; }
.toast.error { background: var(--red); color: #fff; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }

/* ---------- empty / onboarding ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 32px; color: var(--label-2); gap: 8px; min-height: 60%; }
.empty .ei { width: 72px; height: 72px; border-radius: 50%; background: var(--fill-2); display: grid; place-items: center; color: var(--label-2); margin-bottom: 8px; }
.empty h3 { margin: 0; font-size: 20px; font-weight: 600; color: var(--label); }
.empty p { margin: 0; font-size: 15px; max-width: 320px; }
.onboard { flex: 1; overflow-y: auto; padding: calc(var(--sat) + 48px) 24px 40px; max-width: 480px; margin: 0 auto; width: 100%; }
.onboard .logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 20px; box-shadow: 0 10px 30px rgba(0, 122, 255, 0.3); }
.onboard h1 { font-size: 30px; font-weight: 700; text-align: center; margin: 0 0 6px; letter-spacing: -0.3px; }
.onboard .lead { text-align: center; color: var(--label-2); margin: 0 0 28px; font-size: 16px; }
.onboard .group { margin-left: 0; margin-right: 0; }
.onboard .group-title { padding-left: 16px; }
.onboard .btn.filled { margin-top: 20px; }
.onboard .hint { text-align: center; font-size: 13px; color: var(--label-2); margin-top: 16px; }
.color-picker { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 16px; }
.color-picker button { width: 34px; height: 34px; border-radius: 50%; background: var(--c); position: relative; }
.color-picker button.sel::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); }

/* ---------- messages ---------- */
.thread { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg); padding: 8px 12px 4px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.thread .spacer { flex: 1; }
.msg { display: flex; flex-direction: column; max-width: 78%; margin-top: 2px; position: relative; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.gap { margin-top: 10px; }
.bubble { position: relative; padding: 7px 12px 8px; border-radius: 18px; font-size: 17px; line-height: 1.28; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.out .bubble { background: var(--bubble-out); color: #fff; }
.in .bubble { background: var(--bubble-in); color: var(--bubble-in-text); }
.out .bubble a { color: #fff; text-decoration: underline; }
.tail .bubble::before { content: ""; position: absolute; bottom: 0; width: 20px; height: 25px; }
.tail .bubble::after { content: ""; position: absolute; bottom: 0; width: 26px; height: 25px; background: var(--bg); }
.out.tail .bubble::before { right: -7px; background: var(--bubble-out); border-bottom-left-radius: 16px 14px; }
.out.tail .bubble::after { right: -26px; border-bottom-left-radius: 10px; }
.in.tail .bubble::before { left: -7px; background: var(--bubble-in); border-bottom-right-radius: 16px 14px; }
.in.tail .bubble::after { left: -26px; border-bottom-right-radius: 10px; }
.bubble.emoji-only { background: transparent !important; font-size: 44px; padding: 2px 4px; line-height: 1.1; }
.tail .bubble.emoji-only::before, .tail .bubble.emoji-only::after { display: none; }
.bubble.img { padding: 0; overflow: hidden; background: var(--fill) !important; }
.bubble.img img { max-width: min(260px, 70vw); max-height: 320px; object-fit: cover; }
.bubble.img::before, .bubble.img::after { display: none; }
.msg.pressed .bubble { transform: scale(0.97); }
.meta { font-size: 11px; color: var(--label-2); margin: 3px 4px 0; font-weight: 500; }
.meta.receipt { font-size: 11px; margin-top: 2px; }
.msg .stamp { font-size: 11px; color: var(--label-2); margin: 2px 6px 0; }
.day-sep { text-align: center; font-size: 11px; font-weight: 600; color: var(--label-2); margin: 14px 0 4px; }
.day-sep span { font-weight: 400; }
.react { position: absolute; top: -12px; height: 24px; min-width: 24px; padding: 0 6px; border-radius: 12px; background: var(--bg-elevated); border: 1.5px solid var(--bg); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); font-size: 13px; display: flex; align-items: center; gap: 2px; z-index: 1; animation: pop 0.25s; }
.out .react { left: -8px; }
.in .react { right: -8px; }
.msg.has-react { margin-top: 14px; }
.file-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.file-card .fi { width: 36px; height: 36px; border-radius: 8px; background: rgba(255, 255, 255, 0.25); display: grid; place-items: center; flex: none; }
.in .file-card .fi { background: rgba(0, 0, 0, 0.08); }
.file-card .fn { font-size: 15px; font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .fs { font-size: 12px; opacity: 0.75; }
.card-msg { background: var(--bg-elevated); border: 0.5px solid var(--sep); border-radius: 16px; width: min(300px, 78vw); overflow: hidden; }
.card-msg .ch { display: flex; align-items: center; gap: 8px; padding: 10px 14px 6px; font-size: 13px; font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.3px; }
.card-msg .cb { padding: 0 14px 12px; font-size: 15px; }
.card-msg .cb b { font-size: 17px; }
.card-msg .cb .note { color: var(--label-2); margin-top: 4px; white-space: pre-wrap; }
.card-msg .cf { display: flex; gap: 8px; padding: 0 12px 12px; }
.card-msg .cf .btn { flex: 1; min-height: 36px; font-size: 15px; border-radius: 10px; }
.sys-msg { align-self: center; text-align: center; font-size: 12px; color: var(--label-2); margin: 10px 24px 2px; max-width: 90%; }
.typing { align-self: flex-start; margin: 10px 0 4px; }
.typing .bubble { display: flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--label-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; } .typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.35; } 30% { opacity: 1; } }
.new-pill { position: absolute; left: 50%; transform: translateX(-50%); bottom: 72px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 16px; box-shadow: var(--shadow); z-index: 4; }
.composer-wrap { flex: none; background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-top: 0.5px solid var(--sep); padding-bottom: var(--sab); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 6px 10px 7px; }
.composer .plus { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--fill); color: var(--label-2); display: grid; place-items: center; margin-bottom: 1px; }
.composer .field { flex: 1; display: flex; align-items: flex-end; border: 1px solid var(--sep); border-radius: 19px; min-height: 36px; padding: 0 3px 0 13px; background: var(--bg); }
.composer textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 17px; line-height: 22px; padding: 6px 0; max-height: 132px; resize: none; color: var(--label); }
.composer .send { flex: none; width: 29px; height: 29px; border-radius: 50%; background: var(--accent); color: #fff; margin: 3px 0; display: grid; place-items: center; transition: transform 0.15s, opacity 0.15s; }
.composer .send.hidden { transform: scale(0.4); opacity: 0; pointer-events: none; width: 0; margin: 0; }
.attach-strip { display: flex; gap: 8px; padding: 8px 12px 0; overflow-x: auto; }
.attach-strip .at { position: relative; flex: none; width: 64px; height: 64px; border-radius: 10px; background: var(--fill); overflow: hidden; display: grid; place-items: center; font-size: 10px; text-align: center; padding: 4px; }
.attach-strip .at img { width: 100%; height: 100%; object-fit: cover; }
.attach-strip .at .rm { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; display: grid; place-items: center; }
.tone { margin: 6px 12px 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--orange) 14%, var(--bg-elevated)); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.tone b { display: block; font-size: 14px; }
.tone .btn { min-height: 30px; padding: 0 10px; font-size: 14px; }
.react-bar { position: fixed; z-index: 70; display: flex; gap: 4px; padding: 6px; background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 24px; box-shadow: var(--shadow); animation: pop 0.2s; }
.react-bar button { width: 40px; height: 40px; border-radius: 50%; font-size: 24px; display: grid; place-items: center; }
.react-bar button.sel { background: var(--accent); }
.invite-card { margin: 12px; padding: 16px; border-radius: 16px; background: var(--bg-grouped); text-align: center; }
.invite-card h4 { margin: 8px 0 4px; font-size: 17px; }
.invite-card p { margin: 0 0 12px; font-size: 14px; color: var(--label-2); }
.search-bar { display: flex; align-items: center; gap: 6px; margin: 6px 12px 8px; padding: 0 10px; height: 36px; border-radius: 10px; background: var(--fill-2); color: var(--label-2); }
.search-bar input { flex: 1; border: 0; background: transparent; outline: 0; font-size: 17px; color: var(--label); }

/* ---------- calendar ---------- */
.cal-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 4px; }
.cal-top .month { font-size: 20px; font-weight: 700; }
.cal-top .ctrls { display: flex; gap: 2px; }
.cal-top .ctrls button { width: 36px; height: 36px; border-radius: 18px; color: var(--accent); display: grid; place-items: center; }
.cal-top .ctrls button:active { background: var(--fill-3); }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 12px; color: var(--label-2); text-align: center; font-weight: 600; padding: 4px 10px 2px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; padding: 2px 10px 10px; }
.day { aspect-ratio: 1 / 1.12; border-radius: 10px; display: flex; flex-direction: column; align-items: center; padding-top: 4px; font-size: 16px; position: relative; background: var(--tint, var(--bg-elevated)); color: var(--label); overflow: hidden; }
.day.split { background: linear-gradient(100deg, var(--tint-a) 50%, var(--tint) 50%); }
.day.other { opacity: 0.32; }
.day .num { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-weight: 500; }
.day.today .num { background: var(--accent); color: #fff; font-weight: 700; }
.day.selected { outline: 2px solid var(--label); outline-offset: -2px; }
.day .dots { display: flex; gap: 3px; margin-top: auto; margin-bottom: 6px; }
.day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--label-2); }
.day .dot.g { background: transparent; border: 1.2px solid var(--label-2); }
.day .hol { position: absolute; left: 4px; right: 4px; bottom: 16px; font-size: 8px; line-height: 1; text-align: center; color: var(--label-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.day .ex { position: absolute; top: 3px; right: 4px; color: var(--label-2); }
.legend { display: flex; gap: 16px; justify-content: center; padding: 2px 16px 10px; font-size: 13px; color: var(--label-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 5px; background: var(--tint); }
.now-card { margin: 12px 16px 4px; padding: 14px 16px; border-radius: 16px; background: var(--bg-elevated); display: flex; align-items: center; gap: 12px; }
.now-card .nt { font-size: 17px; font-weight: 600; }
.now-card .ns { font-size: 14px; color: var(--label-2); margin-top: 2px; }
.now-card .nc { margin-left: auto; text-align: right; }
.agenda { padding: 4px 16px 24px; }
.agenda h4 { font-size: 13px; text-transform: uppercase; color: var(--label-2); margin: 16px 16px 6px; letter-spacing: 0.3px; }
.ev { display: flex; gap: 12px; padding: 10px 14px; background: var(--bg-elevated); border-radius: 12px; margin-bottom: 8px; align-items: center; width: 100%; text-align: left; color: var(--label); }
.ev .bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c, var(--accent)); flex: none; }
.ev .et { font-size: 16px; font-weight: 500; }
.ev .es { font-size: 13px; color: var(--label-2); margin-top: 2px; }
.ev .time { margin-left: auto; font-size: 14px; color: var(--label-2); flex: none; text-align: right; }
.ev.g { opacity: 0.8; border: 1px dashed var(--sep); background: transparent; }
.cycle-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 10px 16px; }
.cycle-grid .cd { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff; background: var(--c); }
.cycle-grid .cd span { font-size: 9px; font-weight: 500; opacity: 0.85; }
.wd-labels { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 11px; color: var(--label-2); text-align: center; padding: 0 16px; }
.preset { display: flex; align-items: center; gap: 12px; }
.fit { display: inline-block; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--indigo); }
.preset .pv { display: flex; gap: 2px; flex: none; }
.preset .pv i { width: 7px; height: 14px; border-radius: 2px; background: var(--c); }
.date-pick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px; }
.date-pick button { height: 32px; padding: 0 10px; border-radius: 16px; background: var(--fill); font-size: 14px; font-weight: 500; }
.date-pick button.sel { background: var(--accent); color: #fff; }

/* ---------- expenses ---------- */
.balance { margin: 12px 16px 4px; padding: 18px; border-radius: 18px; background: var(--bg-elevated); text-align: center; }
.balance .amt { font-size: 36px; font-weight: 700; letter-spacing: -0.5px; margin: 2px 0; }
.balance .lbl { font-size: 14px; color: var(--label-2); }
.balance.pos .amt { color: var(--green); }
.balance.neg .amt { color: var(--orange); }
.exp .amount { font-weight: 600; font-size: 17px; flex: none; }
.exp .amount.neg { color: var(--label-2); }
.month-h { font-size: 13px; text-transform: uppercase; color: var(--label-2); margin: 20px 32px 6px; letter-spacing: 0.3px; }
.split-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 8px 16px; background: var(--fill); }
.split-bar i { display: block; background: var(--c); }
.receipts { display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; }
.receipts img, .receipts .fd { width: 96px; height: 96px; border-radius: 10px; object-fit: cover; background: var(--fill); flex: none; display: grid; place-items: center; }

/* ---------- info ---------- */
.kid { display: flex; align-items: center; gap: 14px; padding: 12px 16px; width: 100%; text-align: left; color: var(--label); position: relative; }
.kid + .kid::before { content: ""; position: absolute; left: 76px; right: 0; top: 0; border-top: 0.5px solid var(--sep); }
.kid .kn { font-size: 17px; font-weight: 600; }
.kid .ks { font-size: 14px; color: var(--label-2); }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; padding: 8px 16px; }
.doc { background: var(--bg-elevated); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; color: var(--label); position: relative; }
.doc img, .doc .dp { width: 100%; aspect-ratio: 1; border-radius: 8px; object-fit: cover; background: var(--fill); display: grid; place-items: center; color: var(--label-2); }
.doc .dn { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }

/* ---------- journal, records ---------- */
.jentry { background: var(--bg-elevated); border-radius: 14px; margin: 0 16px 10px; padding: 12px 16px; text-align: left; width: calc(100% - 32px); color: var(--label); }
.jentry .jd { font-size: 13px; color: var(--label-2); font-weight: 600; margin-bottom: 4px; display: flex; gap: 8px; }
.jentry .jb { font-size: 16px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.jentry .jphotos { display: flex; gap: 6px; margin-top: 8px; }
.jentry .jphotos img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; }
.records { padding: 16px; font-size: 14px; }
.records h1 { font-size: 22px; margin: 0 0 4px; }
.records .r-meta { color: var(--label-2); margin-bottom: 16px; }
.records table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 13px; }
.records th, .records td { text-align: left; padding: 6px 8px; border-bottom: 0.5px solid var(--sep); vertical-align: top; }
.records th { font-size: 12px; text-transform: uppercase; color: var(--label-2); }
.records h2 { font-size: 16px; margin: 20px 0 8px; }
.records .rm { padding: 8px 0; border-bottom: 0.5px solid var(--sep); }
.records .rm .who { font-weight: 600; }
.records .rm .when { color: var(--label-2); font-size: 12px; }
.records .rm .txt { white-space: pre-wrap; margin-top: 2px; }
@media print {
  body { background: #fff; color: #000; }
  .nav, .tabbar, .no-print { display: none !important; }
  .content, .screen { overflow: visible !important; height: auto !important; }
  .records { font-size: 12px; }
}

/* ---------- misc ---------- */
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--fill-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; height: 100%; }
.muted { color: var(--label-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }
.p16 { padding: 16px; }
.hr { border-top: 0.5px solid var(--sep); margin: 8px 0; }
.offline { background: var(--orange); color: #fff; font-size: 12px; font-weight: 600; text-align: center; padding: 4px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 16px; font-size: 15px; position: relative; }
.kv + .kv::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; border-top: 0.5px solid var(--sep); }
.kv .k { color: var(--label-2); flex: none; }
.kv .v { text-align: right; white-space: pre-wrap; }
.lightbox { position: fixed; inset: 0; background: #000; z-index: 80; display: grid; place-items: center; animation: fade 0.2s; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .x { position: absolute; top: calc(var(--sat) + 12px); right: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); color: #fff; display: grid; place-items: center; }
.lightbox .dl { position: absolute; top: calc(var(--sat) + 12px); left: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); color: #fff; display: grid; place-items: center; }

/* segmented controls inside form rows take the remaining width */
.frow .segmented { flex: 1; margin: 6px 0; min-width: 0; }
.frow .segmented button { padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
