:root {
  --bg: #fff; --bg2: #f2f2f7; --cell: #fff; --sep: rgba(60,60,67,.18); --text: #000; --muted: #8e8e93; --muted2: #3c3c4399;
  --blue: #007aff; --green: #34c759; --red: #ff3b30; --orange: #ff9500; --bubble-in: #e9e9eb; --bar: rgba(249,249,249,.94);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --bg2: #000; --cell: #1c1c1e; --sep: rgba(84,84,88,.6); --text: #fff; --muted: #8e8e93; --muted2: #ebebf599;
    --blue: #0a84ff; --green: #30d158; --red: #ff453a; --bubble-in: #26252a; --bar: rgba(22,22,24,.94); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 17px/1.29 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body { overscroll-behavior: none; }
a { color: var(--blue); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
#app { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
#view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: var(--safe-t); }

/* Tabbalk */
#tabs { display: flex; background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: .5px solid var(--sep); padding: 6px 0 calc(var(--safe-b) + 4px); }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 10px; font-weight: 500; position: relative; }
#tabs svg { width: 27px; height: 27px; fill: currentColor; stroke: currentColor; }
#tabs a.on { color: var(--blue); }
.badge { position: absolute; top: -2px; left: 50%; margin-left: 6px; background: var(--red); color: #fff; font-style: normal;
  font-size: 12px; font-weight: 600; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: none; align-items: center; justify-content: center; }
.badge.show { display: flex; }

/* Koppen */
.nav { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 0; min-height: 44px; }
.nav .act { color: var(--blue); font-size: 17px; }
.large { font-size: 34px; font-weight: 700; letter-spacing: .37px; padding: 2px 16px 8px; margin: 0; }
.seg { display: inline-flex; background: rgba(118,118,128,.12); border-radius: 9px; padding: 2px; }
.seg button { font-size: 13px; font-weight: 600; padding: 5px 16px; border-radius: 7px; }
.seg button.on { background: var(--cell); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }
.search { margin: 0 16px 10px; background: rgba(118,118,128,.12); border-radius: 10px; display: flex; align-items: center; gap: 6px; padding: 7px 8px; color: var(--muted); }
.search input { border: 0; background: none; font: inherit; color: var(--text); flex: 1; outline: none; }
.section-h { color: var(--muted); font-size: 13px; text-transform: uppercase; padding: 18px 32px 6px; }

/* Lijsten */
.list { margin: 0; padding: 0; list-style: none; }
.list.inset { background: var(--cell); border-radius: 10px; margin: 0 16px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 0 0 0 16px; min-height: 60px; position: relative; }
.row .body { flex: 1; min-width: 0; padding: 10px 16px 10px 0; border-bottom: .5px solid var(--sep); align-self: stretch; display: flex; align-items: center; gap: 8px; }
.list > li:last-child .row .body { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t.missed { color: var(--red); }
.row .s { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s.two { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .meta { color: var(--muted); font-size: 15px; white-space: nowrap; }
.row .info { width: 23px; height: 23px; color: var(--blue); flex: none; }
.row.compact { min-height: 44px; }
.chev { color: #c4c4c6; font-size: 20px; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); position: absolute; left: 4px; }

/* Avatars */
.av { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 17px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 75%, #fff), var(--c)); }
.av.l { width: 60px; height: 60px; font-size: 26px; }
.av.xl { width: 100px; height: 100px; font-size: 44px; }
.av.xxl { width: 120px; height: 120px; font-size: 52px; }

/* Favorieten */
.fav-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 6px; padding: 12px 12px; }
.fav { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.fav .av { width: 74px; height: 74px; font-size: 32px; position: relative; }
.fav .n { font-size: 13px; }
.fav .r { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.fav .r svg { width: 11px; height: 11px; fill: var(--muted); }

/* Contactkaart */
.card-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 16px 14px; text-align: center; }
.card-head h2 { margin: 6px 0 0; font-size: 28px; font-weight: 400; }
.card-head p { margin: 0; color: var(--muted); font-size: 15px; }
.quick { display: flex; gap: 8px; padding: 0 16px 16px; }
.quick button, .quick a { flex: 1; background: var(--cell); border-radius: 10px; padding: 9px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--blue); font-size: 11px; }
.quick svg { width: 24px; height: 24px; fill: var(--blue); }
.quick .off { opacity: .4; pointer-events: none; }
.field { padding: 10px 16px; border-bottom: .5px solid var(--sep); }
.field:last-child { border-bottom: 0; }
.field small { display: block; font-size: 15px; color: var(--text); }
.field div { color: var(--muted); font-size: 15px; }
.field.link div { color: var(--blue); }
.page-bg { background: var(--bg2); min-height: 100%; padding-bottom: 30px; }

/* Lampjes */
.light { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 25%, transparent); flex: none; }
.light.ok { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.light.unk { background: #c7c7cc; box-shadow: none; }
.lamps-mini { display: flex; gap: 4px; }
.lamps-mini .light { width: 7px; height: 7px; box-shadow: none; }

/* Chat (iMessage) */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-head { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; padding: 4px 8px 8px; background: var(--bar); border-bottom: .5px solid var(--sep);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.chat-head .who { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; }
.chat-head .who .av { width: 50px; height: 50px; font-size: 22px; }
.chat-head .back { color: var(--blue); font-size: 17px; display: flex; align-items: center; gap: 2px; }
.chat-head .call { justify-self: end; color: var(--blue); }
.chat-head .call svg { width: 26px; height: 26px; fill: var(--blue); }
.msgs { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.b.in + .b.out, .b.out + .b.in { margin-top: 6px; }   /* wisseling van afzender: 8px gap + 6px = 14px tussenruimte */
.stamp { text-align: center; color: var(--muted); font-size: 11px; margin: 12px 0 6px; }
.stamp b { font-weight: 600; }
.b { max-width: 78%; padding: 7px 12px; border-radius: 18px; font-size: 17px; line-height: 1.3; white-space: pre-wrap; word-wrap: break-word; }
.b.in { background: var(--bubble-in); align-self: flex-start; border-bottom-left-radius: 6px; }
.b.out { background: var(--blue); color: #fff; align-self: flex-end; border-bottom-right-radius: 6px; }
.b a { color: inherit; text-decoration: underline; }
.b .tk { display: inline-block; font-size: 12px; opacity: .7; margin-top: 2px; }
.b.call-note { background: none; border: 1px solid var(--sep); color: var(--muted); font-size: 14px; align-self: center; text-align: center; max-width: 90%; }
.typing { align-self: flex-start; background: var(--bubble-in); border-radius: 18px; padding: 10px 14px; display: none; gap: 4px; }
.typing.show { display: flex; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: #8e8e93; animation: dot 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(var(--safe-b) + 8px); background: var(--bar); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--sep); border-radius: 18px; padding: 7px 14px; font: inherit; background: var(--bg);
  color: var(--text); max-height: 120px; outline: none; }
.composer button { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; margin-bottom: 2px; }
.composer button:disabled { background: #c7c7cc; }
.composer button svg { width: 18px; height: 18px; fill: #fff; }
.quickreplies { display: flex; gap: 6px; padding: 0 10px 6px; overflow-x: auto; background: var(--bar); }
.quickreplies button { border: 1px solid var(--blue); color: var(--blue); border-radius: 16px; padding: 4px 12px; font-size: 15px; white-space: nowrap; }

/* Inkomend / actief gesprek */
.callscreen { position: fixed; inset: 0; z-index: 50; color: #fff; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--safe-t) + 60px) 24px calc(var(--safe-b) + 40px); background: #1c1c1e; overflow: hidden; }
.callscreen::before { content: ''; position: absolute; inset: -40%; background: radial-gradient(circle at 30% 20%, var(--c), transparent 55%),
  radial-gradient(circle at 80% 80%, color-mix(in srgb, var(--c) 60%, #000), transparent 60%); filter: blur(60px); opacity: .75; z-index: -1; }
.callscreen .sub { font-size: 17px; opacity: .8; }
.callscreen h1 { font-size: 36px; font-weight: 400; margin: 6px 0 4px; letter-spacing: .3px; text-align: center; }
.callscreen .q { margin-top: 22px; background: rgba(255,255,255,.14); border-radius: 16px; padding: 12px 14px; font-size: 15px; max-width: 420px; max-height: 26vh; overflow: auto;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.callscreen .spacer { flex: 1; }
.callscreen .opts { display: flex; justify-content: space-around; width: 100%; max-width: 360px; margin-bottom: 36px; }
.callscreen .opts button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 15px; }
.callscreen .opts svg { width: 26px; height: 26px; fill: #fff; }
.callscreen .main-btns { display: flex; justify-content: space-between; width: 100%; max-width: 300px; }
.cbtn { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 15px; }
.cbtn span { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; }
.cbtn svg { width: 34px; height: 34px; fill: #fff; }
.cbtn.red span { background: #ff3b30; } .cbtn.green span { background: #34c759; }
.cbtn.green span { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,199,89,.6); } 70% { box-shadow: 0 0 0 18px rgba(52,199,89,0); } 100% { box-shadow: 0 0 0 0 rgba(52,199,89,0); } }
.grid6 { display: grid; grid-template-columns: repeat(3, 76px); gap: 22px 30px; margin: 10px 0 34px; }
.grid6 button { display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 13px; }
.grid6 button i { width: 76px; height: 76px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.grid6 button.on i { background: #fff; } .grid6 button.on svg { fill: #000; }
.grid6 button:disabled { opacity: .35; }
.grid6 svg { width: 30px; height: 30px; fill: #fff; }
.transcript { width: 100%; max-width: 440px; flex: 1; overflow-y: auto; margin: 16px 0 8px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.transcript .l { padding: 6px 10px; border-radius: 14px; max-width: 85%; background: rgba(255,255,255,.16); }
.transcript .l.me { align-self: flex-end; background: rgba(0,122,255,.55); }
.transcript .l.partial { opacity: .65; }
.level { height: 4px; width: 120px; background: rgba(255,255,255,.2); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.level i { display: block; height: 100%; width: 0; background: #34c759; transition: width .08s; }
.typebar { display: none; width: 100%; max-width: 440px; gap: 8px; margin-bottom: 14px; }
.typebar.show { display: flex; }
.typebar input { flex: 1; min-width: 0; border: 0; border-radius: 18px; padding: 9px 14px; font: inherit; background: rgba(255,255,255,.9); color: #000; }
.typebar button { flex: none; background: #007aff; color: #fff; border-radius: 18px; padding: 0 14px; }

/* Actie-sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 80; display: flex; flex-direction: column; justify-content: flex-end; padding: 8px 8px calc(var(--safe-b) + 8px); }
.sheet { background: rgba(250,250,250,.96); border-radius: 14px; overflow: hidden; margin-bottom: 8px; }
@media (prefers-color-scheme: dark) { .sheet { background: rgba(40,40,42,.96); } }
.sheet .h { text-align: center; font-size: 13px; color: var(--muted); padding: 14px 16px; border-bottom: .5px solid var(--sep); }
.sheet button { display: block; width: 100%; padding: 17px; font-size: 20px; color: var(--blue); border-bottom: .5px solid var(--sep); }
.sheet button:last-child { border-bottom: 0; }
.sheet button.danger { color: var(--red); }
.sheet.cancel button { font-weight: 600; }

/* Diversen */
.empty { text-align: center; color: var(--muted); padding: 60px 30px; font-size: 15px; }
.empty b { display: block; color: var(--text); font-size: 20px; margin-bottom: 6px; }
#toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 10px); transform: translate(-50%, -150%); background: var(--cell); color: var(--text);
  box-shadow: 0 8px 30px rgba(0,0,0,.2); border-radius: 14px; padding: 10px 14px; font-size: 15px; z-index: 100; transition: transform .3s; max-width: 92vw; display: flex; gap: 10px; align-items: center; }
#toast.show { transform: translate(-50%, 0); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: rgba(118,118,128,.14); color: var(--muted2); white-space: nowrap; }
.pill.warn { background: color-mix(in srgb, var(--orange) 20%, transparent); color: var(--orange); }
.pill.bad { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.pill.good { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.vm-play { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); display: grid; place-items: center; flex: none; }
.vm-play svg { width: 16px; height: 16px; fill: #fff; }
.vm-text { font-size: 15px; color: var(--text); padding: 4px 16px 12px 16px; white-space: pre-wrap; }
.vm-actions { display: flex; gap: 10px; padding: 0 16px 14px; }
.vm-actions button { flex: 1; background: rgba(118,118,128,.12); border-radius: 10px; padding: 9px; color: var(--blue); font-size: 15px; font-weight: 600; }
select.ios, input.ios { font: inherit; color: var(--muted); background: none; border: 0; text-align: right; outline: none; }
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: rgba(120,120,128,.16); position: relative; transition: background .2s; flex: none; }
.switch::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,.15); transition: left .2s; }
.switch:checked { background: var(--green); } .switch:checked::after { left: 22px; }
.pair { padding: 50px 26px; text-align: center; }
.pair .av { margin: 0 auto 18px; }
.pair h1 { font-size: 28px; margin: 0 0 10px; }
.pair p { color: var(--muted); }
.btn { display: inline-block; background: var(--blue); color: #fff; border-radius: 12px; padding: 13px 22px; font-weight: 600; margin-top: 10px; }

/* Bijlagen bij berichten */
.composer button.clip { background: none; width: 30px; }
.composer button.clip svg { width: 24px; height: 24px; fill: var(--blue); }
.att-tray { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; background: var(--bar); }
.att-tray:not(:empty) { padding: 8px 10px 0; }
.att-tray .chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; background: var(--bubble-in); border-radius: 14px; padding: 4px 6px 4px 12px; font-size: 14px; }
.att-tray .chip button { width: 22px; height: 22px; border-radius: 50%; background: rgba(120,120,128,.25); color: var(--text); font-size: 11px; }
.b .att-img { display: block; margin: -1px -6px 4px; }
.b .att-img img { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; }
.b .att-file { display: block; text-decoration: none; margin-bottom: 3px; }
.b .att-file small { opacity: .7; }
