/* My Domains — built on Our Contacts' stylesheet (Apple's system colours, grouped rounded lists,
   coloured initials, a card with quick actions), so the four apps look and behave alike.
   My Domains' own additions are at the end. */
:root {
  /* Apple's light-mode system colours */
  --bg: #f2f2f7;          /* grouped background */
  --surface: #ffffff;     /* grouped cells */
  --raised: #ffffff;
  --fill: rgba(118, 118, 128, .12);   /* search fields, inputs, segmented controls */
  --hover: #ebebf0;
  --ink: #1d1d1f;
  --muted: #55555a;       /* secondary label (same grey as Our Calendar and Our Flights) */
  --line: #e0e0e5;        /* separators */
  --accent: #007aff;      /* systemBlue */
  --on-accent: #ffffff;
  --mark: #ffe58a;
  --warn: #ff3b30;        /* systemRed */
  --amber: #ff9500;
  --bar: rgba(249, 249, 251, .86);
  --shadow: 0 12px 40px rgba(0, 0, 0, .18);
  --av-blue: #007aff; --av-green: #34c759; --av-indigo: #5856d6; --av-orange: #ff9500;
  --av-pink: #ff2d55; --av-purple: #af52de; --av-red: #ff3b30; --av-teal: #30b0c7;
  --av-yellow: #f2b300; --av-mint: #00c7be; --av-brown: #a2845e; --av-cyan: #32ade6;
  color-scheme: light;
}
/* Dark colours: used when the device is in dark mode (unless Light was chosen under ? → Appearance),
   or always when Dark was chosen. Keep the two blocks below identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1c1c1e; --raised: #2c2c2e; --fill: rgba(118, 118, 128, .24); --hover: #2c2c2e;
    --ink: #f5f5f7; --muted: #b5b5ba; --line: #38383a;
    --accent: #0a84ff; --on-accent: #ffffff; --mark: #6b5a12; --warn: #ff453a; --amber: #ff9f0a;
    --bar: rgba(22, 22, 24, .86); --shadow: 0 12px 40px rgba(0, 0, 0, .6);
    --av-blue: #0a84ff; --av-green: #30d158; --av-indigo: #5e5ce6; --av-orange: #ff9f0a;
    --av-pink: #ff375f; --av-purple: #bf5af2; --av-red: #ff453a; --av-teal: #40c8e0;
    --av-yellow: #e6b800; --av-mint: #63e6e2; --av-brown: #ac8e68; --av-cyan: #64d2ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --raised: #2c2c2e; --fill: rgba(118, 118, 128, .24); --hover: #2c2c2e;
  --ink: #f5f5f7; --muted: #b5b5ba; --line: #38383a;
  --accent: #0a84ff; --on-accent: #ffffff; --mark: #6b5a12; --warn: #ff453a; --amber: #ff9f0a;
  --bar: rgba(22, 22, 24, .86); --shadow: 0 12px 40px rgba(0, 0, 0, .6);
  --av-blue: #0a84ff; --av-green: #30d158; --av-indigo: #5e5ce6; --av-orange: #ff9f0a;
  --av-pink: #ff375f; --av-purple: #bf5af2; --av-red: #ff453a; --av-teal: #40c8e0;
  --av-yellow: #e6b800; --av-mint: #63e6e2; --av-brown: #ac8e68; --av-cyan: #64d2ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
:root { --hair: 1px; }
@media (min-resolution: 2dppx) { :root { --hair: .5px; } }
html, body { margin: 0; height: 100%; }
/* Everything sized in rem scales from here. Text size (? → slider): Small · Medium (default) · Large · Extra large · Largest */
html { font-size: 16.5px; }
html[data-size="small"] { font-size: 15.5px; }
html[data-size="large"] { font-size: 18.5px; }
html[data-size="xlarge"] { font-size: 20.5px; }
html[data-size="xxlarge"] { font-size: 22.5px; }
@media (max-width: 760px) {   /* phones: Medium = iPhone standard reading size */
  html { font-size: 17px; }
  html[data-size="small"] { font-size: 16px; }
  html[data-size="large"] { font-size: 19px; }
  html[data-size="xlarge"] { font-size: 21px; }
  html[data-size="xxlarge"] { font-size: 23px; }
}
body {
  font: 400 1rem/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -.01em;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Buttons: soft grey fill by default, solid blue for the main action, plain blue text for links */
button {
  font: inherit; font-weight: 500; color: var(--accent); background: var(--fill);
  border: 0; border-radius: 10px; padding: 7px 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:hover { filter: brightness(.96); }
button:active { opacity: .7; }
button.primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.icon { width: 34px; height: 34px; padding: 0; font-size: 1.1rem; line-height: 1; flex: none; border-radius: 50%; font-weight: 600; }
button.link { background: none; padding: 2px 0; color: var(--accent); text-align: left; border-radius: 0; }
button.link:hover { background: none; text-decoration: underline; filter: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

input, textarea, select {
  font: inherit; color: var(--ink); background: var(--fill);
  border: 0; border-radius: 10px; padding: 8px 11px; min-width: 0;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { resize: vertical; line-height: 1.45; }

/* ── Screens ── */
.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 16px; color: var(--muted); }
.signin-card {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
  padding: 36px 28px; text-align: center; max-width: 360px; width: 100%; color: var(--ink);
}
.signin-card h1 { margin: 0 0 6px; font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.signin-card p { color: var(--muted); margin: 0 0 22px; }
.signin-card .primary { padding: 10px 22px; border-radius: 99px; }

#app { display: flex; flex-direction: column; height: 100dvh; }
main { flex: 1; min-height: 0; position: relative; display: flex; overflow: hidden; }
/* Pull-to-refresh (home-screen app on phones) */
.ptr { position: absolute; top: 0; left: 50%; width: 30px; height: 30px; margin-left: -15px; z-index: 5;
  opacity: 0; transform: translateY(-40px); pointer-events: none; }
.ptr-ring { width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.15); box-sizing: border-box; }
.ptr.spinning .ptr-ring { animation: ptr-spin .7s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
.ptr.settle, .list.settle { transition: transform .25s ease, opacity .25s ease; }

/* ── Header: translucent bar with a large title, like iOS ── */
.bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: var(--hair) solid var(--line); position: relative; z-index: 3;
}
.app-title { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -.025em; flex: 1; min-width: 0; }
.app-title button { font: inherit; font-weight: 700; color: var(--ink); background: none; border: 0; padding: 0; border-radius: 0;
  display: inline-flex; align-items: center; gap: 10px; }
.app-title button:hover { filter: none; }
.title-icon { width: 32px; height: 32px; border-radius: 22.5%; box-shadow: 0 0 0 .5px var(--line), 0 1px 3px rgba(0,0,0,.12); }
.tools { display: flex; align-items: center; gap: 8px; }
.search { position: relative; }
#search { width: 300px; padding: 8px 12px 8px 32px; }
/* Magnifying glass inside the search box, like Apple's search fields */
.search-icon { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  color: var(--muted); pointer-events: none; }
#new-btn { border-radius: 99px; padding: 7px 16px; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 20px; font-size: .88rem;
  background: color-mix(in srgb, var(--amber) 16%, var(--surface)); border-bottom: var(--hair) solid var(--line);
}
.banner span { flex: 1; min-width: 12rem; }
.banner.update { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.banner.offline { background: var(--surface); color: var(--muted); }
.banner button { padding: 4px 12px; font-size: .85rem; border-radius: 99px; background: var(--surface); }
.banner button.primary { background: var(--accent); }
.banner button.icon { width: 26px; height: 26px; padding: 0; background: var(--fill); color: var(--muted); }

/* ── Avatars: initials on a coloured gradient circle ── */
.avatar {
  --c: var(--av-blue);
  flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: .92rem; font-weight: 600; letter-spacing: .02em; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 72%, #fff), var(--c));
  box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .06);
  user-select: none;
}
.av-glyph { width: 58%; height: 58%; }
.avatar.xl { width: 6rem; height: 6rem; font-size: 2.35rem; font-weight: 600; box-shadow: 0 6px 18px color-mix(in srgb, var(--c) 35%, transparent); }
.av-blue { --c: var(--av-blue); } .av-green { --c: var(--av-green); } .av-indigo { --c: var(--av-indigo); }
.av-orange { --c: var(--av-orange); } .av-pink { --c: var(--av-pink); } .av-purple { --c: var(--av-purple); }
.av-red { --c: var(--av-red); } .av-teal { --c: var(--av-teal); } .av-yellow { --c: var(--av-yellow); }
.av-mint { --c: var(--av-mint); } .av-brown { --c: var(--av-brown); } .av-cyan { --c: var(--av-cyan); }

/* ── List: inset grouped sections, one per letter ── */
.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 0 56px; }
.list > * { width: min(780px, calc(100% - 40px)); margin-left: auto; margin-right: auto; }
.lh {
  position: sticky; top: 0; z-index: 2; margin: 0 auto; padding: 14px 16px 6px;
  font-size: .8rem; font-weight: 600; letter-spacing: .02em; color: var(--muted);
  background: var(--bg);
}
.group { background: var(--surface); border-radius: 12px; overflow: hidden; margin-bottom: 6px; }
.row {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; border-radius: 0; padding: 9px 16px; background: var(--surface); color: var(--ink); font-weight: 400;
}
.row:not(:last-child)::after {   /* hairline separator, inset past the avatar */
  content: ""; position: absolute; left: calc(16px + 2.4rem + 12px); right: 0; bottom: 0; height: var(--hair); background: var(--line);
}
.row:hover { background: var(--hover); filter: none; }
.row:active { opacity: 1; background: var(--hover); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rn { flex: 1; min-width: 0; }
.rn b { font-weight: 600; }
.rc { display: block; font-size: .8rem; color: var(--muted); margin-top: 1px; }
.rd { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.empty, .count { padding: 24px 16px; color: var(--muted); }
.count .link, .empty .link { margin-left: 6px; font-size: inherit; }
.rc.in-notes { font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { padding: 12px 16px 6px; font-size: .82rem; }

.letters {
  display: flex; flex-direction: column; justify-content: center; padding: 4px 4px; gap: 0; overflow-y: auto;
}
.letters button { background: none; padding: 1px 6px; font-size: .7rem; font-weight: 600; color: var(--accent); border-radius: 4px; }
.letters button:hover { background: var(--fill); }
.letters:empty { display: none; }

/* ── Dialogs ── */
dialog {
  border: 0; border-radius: 16px; padding: 20px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  width: min(600px, 94vw);
}
dialog::backdrop { background: rgba(0, 0, 0, .32); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 12px; font-size: 1.2rem; font-weight: 700; letter-spacing: -.015em; }
dialog h2[tabindex="-1"]:focus { outline: none; }

/* ── Contact card: centred avatar and name, quick actions, grouped details ── */
.card { width: min(560px, 94vw); max-height: 92vh; background: var(--bg); padding: 14px 20px 20px; }
.card-top { display: flex; justify-content: space-between; align-items: center; margin: 0 -8px 2px; }
.nav-btn { background: none; padding: 6px 8px; font-size: 1rem; font-weight: 500; color: var(--accent); }
.nav-btn:hover { background: var(--fill); filter: none; }
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 0 6px; }
.hero h2 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.025em; margin: 12px 0 0; overflow-wrap: anywhere; }
.sub { margin: 3px 0 0; color: var(--muted); }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; margin-top: 18px; }
.quick-actions:empty { display: none; }
.qa {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px;
  background: var(--surface); border-radius: 12px; color: var(--accent); font-size: .72rem; font-weight: 500;
}
.qa:hover { text-decoration: none; background: var(--hover); }
.qa svg { width: 1.35rem; height: 1.35rem; }
.qa.off { color: var(--muted); opacity: .45; }
.view-body { margin: 16px 0 4px; display: flex; flex-direction: column; gap: 14px; }
.view-body .group, .mini .group, .hv-text .group { margin: 0; }
.cell { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 9px 16px 10px; overflow-wrap: anywhere; }
.cell + .cell::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; height: var(--hair); background: var(--line); }
.cell .lbl { font-size: .8rem; color: var(--ink); text-transform: lowercase; }
.cell .val { font-size: 1rem; }
.notes { display: block; white-space: normal; font-size: .95rem; max-height: 40vh; overflow-y: auto; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.card-actions.sticky { position: sticky; bottom: -20px; background: var(--bg); padding: 12px 0 4px; margin-bottom: -4px; border-top: var(--hair) solid var(--line); }
.meta { flex: 1; font-size: .8rem; color: var(--muted); }
#delete-btn { color: var(--warn); }
.note {
  font-size: .85rem; padding: 9px 12px; border-radius: 10px; margin: 0;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

/* Edit form: white grouped fields on the grey card background */
#edit { display: flex; flex-direction: column; gap: 12px; }
#edit h2 { margin-bottom: 0; }
#edit label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
#edit label > input:not([type="radio"]), #edit label > textarea { font-size: 1rem; color: var(--ink); width: 100%; }
#edit input, #edit textarea, #edit select { background: var(--surface); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
legend { font-size: .8rem; color: var(--muted); padding: 0; margin-bottom: 4px; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.frow { display: flex; gap: 6px; align-items: flex-start; }
.frow .lab { width: 7.5em; flex: none; font-size: .9rem; color: var(--accent); }
.frow .val { flex: 1 1 0; min-width: 0; width: 100%; }
.frow .rm { width: 30px; height: 30px; margin-top: 3px; background: none; color: var(--warn); font-size: 1.3rem; }
fieldset .link { align-self: flex-start; font-size: .9rem; font-weight: 500; }
.bday { flex-direction: row; flex-wrap: wrap; align-items: center; }
.bday legend { width: 100%; }
#f-bday { width: 6em; }
#f-byear { width: 10em; }

.conflict { border-radius: 12px; padding: 14px; background: color-mix(in srgb, var(--amber) 12%, var(--surface)); }
.conflict > p { margin: 0 0 10px; font-weight: 600; }
.cf { margin-bottom: 12px; }
.cf h4 { margin: 0 0 6px; font-size: .85rem; }
.cf label { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 2px solid transparent; border-radius: 10px; margin-bottom: 4px; background: var(--surface); color: var(--ink) !important; font-size: .9rem !important; flex-direction: row !important; cursor: pointer; }
.cf label:has(input:checked) { border-color: var(--accent); }
.cf input { accent-color: var(--accent); }
.cf .v .lbl { color: var(--muted); margin-right: 8px; }
.cf .v { display: block; font-size: .88rem; max-height: 8rem; overflow: auto; }
.conflict-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.history-wrap:has(#history-btn[hidden]) { display: none; }
.history-wrap { margin-top: 10px; }
.history { margin-top: 8px; max-height: 40vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.hv { border-radius: 12px; padding: 10px 12px; background: var(--surface); font-size: .85rem; }
.hv summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.hv-text { margin: 8px 0; }
.hv-text .group { background: var(--bg); }

/* ── Help & import ── */
.help { width: min(640px, 94vw); max-height: 88vh; }
.help h3 { margin: 20px 0 8px; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
/* Title row with a Close button that stays pinned while the panel scrolls */
.dialog-head { position: sticky; top: -20px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: -20px -20px 0; padding: 16px 20px 12px; background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-bottom: var(--hair) solid var(--line); }
.dialog-head h2 { margin: 0; }
#help-close-top { background: none; font-weight: 600; }
/* Appearance choice: an iOS segmented control */
.theme-seg { display: inline-flex; border-radius: 9px; padding: 2px; background: var(--fill); }
.theme-seg button { background: transparent; padding: 5px 16px; font-size: .9rem; font-weight: 500; color: var(--ink); border-radius: 7px; }
.theme-seg button.on { background: var(--raised); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .04); }
/* Text size slider, like iOS: small A — track — big A */
.size-slider { display: flex; align-items: center; gap: 12px; max-width: 360px; }
.size-slider input { flex: 1; accent-color: var(--accent); height: 28px; margin: 0; padding: 0; border: 0; background: none; }
.size-a { font-weight: 700; line-height: 1; color: var(--ink); }
.size-a.small { font-size: 13px; } .size-a.big { font-size: 24px; }
.size-name { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.keys { border-collapse: collapse; font-size: .9rem; }
.keys td { padding: 4px 12px 4px 0; vertical-align: top; }
.keys td:first-child { white-space: nowrap; }
kbd {
  display: inline-block; min-width: 1.6em; text-align: center; font: 600 .8rem ui-monospace, "SF Mono", Menlo, monospace;
  border-radius: 5px; padding: 1px 5px; margin-right: 2px; background: var(--fill); box-shadow: inset 0 -1px 0 var(--line);
}
code { font: .8rem ui-monospace, "SF Mono", Menlo, monospace; }
.toggle { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); }
.toggle input { accent-color: var(--accent); }
.help-actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 20px; }

.import { width: min(760px, 94vw); max-height: 90vh; }
.import p { margin: 0 0 12px; font-size: .9rem; }
#import-file { font: inherit; margin-bottom: 8px; max-width: 100%; border: 0; padding: 0; background: none; }
.import-preview { font-size: .9rem; }
.import-preview ul { padding-left: 20px; margin: 8px 0 12px; }
.import-preview li { margin-bottom: 4px; }
.import-preview .warn { color: var(--warn); }
.import-preview .summary { font-size: .95rem; margin-top: 8px; }
.mapping, .samples { margin: 8px 0; }
.mapping summary, .samples summary { cursor: pointer; color: var(--accent); }
.mapping table { border-collapse: collapse; margin-top: 8px; font-size: .85rem; width: 100%; }
.mapping td { padding: 3px 8px 3px 0; vertical-align: middle; }
.mapping td:last-child { overflow-wrap: anywhere; }
.mapping select { padding: 4px 8px; font-size: .85rem; }
.mini { border-radius: 12px; padding: 10px 12px; margin-top: 8px; background: var(--bg); }
.mini .group { margin-top: 6px; }
.mini .notes { max-height: 6rem; }
#import-progress { width: 100%; margin: 8px 0; accent-color: var(--accent); }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50; bottom: 32px;
  border-radius: 99px; padding: 10px 18px; box-shadow: var(--shadow);
  background: color-mix(in srgb, var(--raised) 92%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  font-size: .9rem; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 14px;
}
.toast[hidden] { display: none; }
.toast-btn { white-space: nowrap; background: none; padding: 2px 4px; color: var(--accent); font-weight: 700; }
.toast-btn:hover { background: none; text-decoration: underline; filter: none; }
.toast.error { color: var(--warn); border-radius: 14px; }

/* ── Desktop / mobile switch ── */
@media (min-width: 761px) { .mobile-only { display: none !important; } }
@media (max-width: 760px) {
  .desktop-only { display: none !important; }
  /* Extra room at the top so the title clears the iPhone clock / Dynamic Island area. */
  .bar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; padding-top: calc(max(10px, env(safe-area-inset-top)) + 14px); }
  .app-title { font-size: 1.75rem; }
  .title-icon { width: 30px; height: 30px; }
  .tools { width: 100%; }
  .search { flex: 1; min-width: 0; }
  #search { width: 100%; font-size: max(16px, 1rem); } /* 16px+ stops iOS zooming */
  input, textarea, select { font-size: max(16px, 1rem); }
  .rd { display: none; }
  .list > * { width: calc(100% - 24px); }
  .letters { padding: 2px 1px; }
  .letters button { padding: 0 4px; font-size: .64rem; }
  dialog.card {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    margin: 0; border-radius: 0; padding: 12px 16px 16px;
    padding-top: calc(max(12px, env(safe-area-inset-top)) + 10px); padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .grid2 { grid-template-columns: 1fr; }
  .frow .lab { width: 6em; }
  .card-actions { flex-wrap: wrap; }
  .meta { width: 100%; flex-basis: 100%; order: 9; }
}

/* ── Printing ──
   With a domain open: just that domain's card. Otherwise: the whole list. Always light colours. */
@page { margin: 0.5in; }
@media print {
  html:root:not([data-print-dark]) {
    --bg: #fff; --surface: #fff; --raised: #fff; --fill: #f2f2f7; --hover: #fff;
    --ink: #000; --muted: #55555a; --line: #c7c7cc;
    --accent: #0062cc; --on-accent: #fff; --mark: #ffe58a; --warn: #d70015; --amber: #c96f00;
    --bar: #fff; --shadow: none; --hair: 1px;
    --av-blue: #007aff; --av-green: #34c759; --av-indigo: #5856d6; --av-orange: #ff9500;
    --av-pink: #ff2d55; --av-purple: #af52de; --av-red: #ff3b30; --av-teal: #30b0c7;
    --av-yellow: #f2b300; --av-mint: #00c7be; --av-brown: #a2845e; --av-cyan: #32ade6;
    color-scheme: light;
    font-size: 10.5pt;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body, #app { height: auto !important; background: #fff !important; }
  #app { display: block; }
  main { display: block; overflow: visible; }
  /* Screen-only things */
  .tools, .banner, .ptr, .toast, .letters, #help, #import, .link, .count .link { display: none !important; }
  .list > * { width: auto !important; }
  .bar { padding: 0 0 8px !important; flex-wrap: nowrap !important; border-bottom: 2px solid var(--ink); background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .app-title { font-size: 1.6rem; }
  .title-icon { width: 26px; height: 26px; box-shadow: none; }
  /* The list: every contact on one line, phone and email in full, never split across pages */
  .list { overflow: visible; padding: 0; }
  .list > * { width: auto; }
  .lh { position: static; padding: 12px 0 2px; font-size: 1rem; font-weight: 700; color: var(--accent); background: none;
    border-bottom: 1px solid var(--line); break-after: avoid; page-break-after: avoid; }
  .group { border-radius: 0; overflow: visible; margin: 0; }
  .row { padding: 4px 0; gap: 10px; break-inside: avoid; page-break-inside: avoid; }
  .row::after { left: 0 !important; }
  .row .avatar { width: 1.7rem; height: 1.7rem; font-size: .7rem; box-shadow: none; }
  .rd { display: block !important; max-width: 60%; white-space: normal; overflow: visible; text-align: right; color: var(--ink); font-size: .9rem; }
  .rc.in-notes { white-space: normal; }

  /* A contact is open: print only its card */
  body:has(#card[open]) #app { display: none !important; }
  dialog#card[open] { position: static; inset: auto; transform: none; width: 100% !important; max-width: 6.5in !important; height: auto !important; max-height: none !important;
    overflow: visible; margin: 0 !important; padding: 0 !important; border: 0; border-radius: 0; box-shadow: none; background: #fff; }
  dialog::backdrop { background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  #card .card-top, #card .card-actions, #card .history-wrap, #card .quick-actions { display: none !important; }
  #card .hero { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; justify-items: start; align-items: center; text-align: left; padding: 0 0 12px; border-bottom: 2px solid var(--ink); }
  #card .hero .avatar { grid-row: span 2; }
  #card .hero h2 { margin: 0; font-size: 2rem; }
  #card .avatar.xl { width: 4.2rem; height: 4.2rem; font-size: 1.6rem; box-shadow: none; }
  #card .view-body { gap: 10px; }
  #card .view-body .group { border: 1px solid var(--line); border-radius: 10px; break-inside: avoid; page-break-inside: avoid; }
  #card .notes { max-height: none; overflow: visible; }
  #card a { color: var(--ink); text-decoration: none; }
}

/* Help panel footer (same in all three apps): Sign out, the web address and version, Close */
.help-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.help-who { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.help-meta { font-size: .8rem; color: var(--muted); }

/* Sign-in screen, as in Our Calendar */
.signin-card { border-radius: 22px; padding: 36px 30px 30px; }
.signin-icon { width: 76px; height: 76px; border-radius: 22.5%; box-shadow: 0 2px 10px rgba(0,0,0,.15); margin-bottom: 14px; }
.signin-card .primary { width: 100%; padding: 11px 16px; }

/* Help panel: the app's logo, name and author at the top (same in all three apps) */
.help-hero { display: flex; align-items: center; gap: 14px; margin: 18px 0 4px; }
.help-hero-icon { width: 58px; height: 58px; border-radius: 22.5%; box-shadow: 0 0 0 .5px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.14); flex: none; }
.help-hero-name { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; }
.help-hero-by { font-size: .9rem; color: var(--muted); margin-top: 1px; }
/* Sign out: Apple's red on the grey capsule, the same in all three apps */
#signout-btn2 { color: #ff3b30; font-weight: 600; }

/* Sign-in screen: identical in Our Calendar, Our Contacts and Our Flights (fixed sizes, centred in the window) */
#signin .signin-card { box-sizing: border-box; width: 100%; max-width: 360px; padding: 36px 30px 30px; border-radius: 22px; text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  font-size: 16.5px; font-weight: 500; line-height: 1.4; letter-spacing: -.005em; }
#signin .signin-icon { display: block; width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 22.5%; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
#signin .signin-card h1 { margin: 0 0 6px; font-size: 29px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
#signin .signin-card p { margin: 0 0 22px; font-size: 16.5px; color: var(--muted); }
#signin .signin-card button { width: 100%; padding: 11px 16px; border: 0; border-radius: 999px; font: inherit; font-weight: 600;
  display: block; text-align: center; }
/* Same spot for the card (and its logo) in every app, however long the line under the name is */
#signin { align-items: start !important; justify-items: center; padding-top: max(16px, calc(50dvh - 150px)) !important; }

/* ── Header: the same in all three apps (logo + name left, search · New · ? right) ── */
.app-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.1; }
.app-title button { gap: 10px; white-space: nowrap; }
.title-icon { width: 34px; height: 34px; border-radius: 22.5%; flex: none; box-shadow: 0 0 0 .5px rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.12); }
#search { width: 260px; }
@media (max-width: 760px) { #search { width: 100%; } .title-icon { width: 30px; height: 30px; } }


/* ═════════════ My Domains additions ═════════════ */

/* Status colours: green all good, orange something to look at, red act soon, grey not checked yet */
.st-green { --c: var(--av-green); } .st-amber { --c: var(--av-orange); } .st-red { --c: var(--av-red); } .st-grey { --c: #8e8e93; }
.st-blue { --c: var(--accent); } .st-purple { --c: var(--av-purple); }

/* Smart lists across the top, like Reminders: tap one to show just those domains */
.smart { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px !important; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 9px; background: var(--surface); border-radius: 12px;
  color: var(--ink); text-align: left; font-weight: 400; }
.tile:hover { background: var(--hover); filter: none; }
.tile-top { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.tile-ico { width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--c); }
.tile-ico svg { width: 1.05rem; height: 1.05rem; }
.tile-n { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.tile-l { font-size: .86rem; font-weight: 600; color: var(--muted); }
.tile.on { background: var(--c); }
.tile.on .tile-n, .tile.on .tile-l { color: #fff; }
.tile.on .tile-ico { background: #fff; color: var(--c); }

/* Sort control and count above the list */
.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 4px 0; }
.list-tools .count { padding: 0; }
.sort-seg button { padding: 4px 12px; font-size: .82rem; }

/* Rows: a short status on the right, coloured by how urgent it is, and Apple's grey chevron */
.row .rd { max-width: 40%; text-align: right; }
.rd.red { color: var(--warn); font-weight: 500; } .rd.amber { color: var(--amber); font-weight: 500; } .rd.green { color: var(--av-green); }
.group.first { margin-top: 14px; }
.rs { display: block; font-size: .8rem; margin-top: 1px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs.red { color: var(--warn); } .rs.amber { color: var(--amber); } .rs.green { color: var(--av-green); }
.chev { color: var(--muted); opacity: .45; font-size: 1.25rem; line-height: 1; margin-left: -4px; }
.row .rc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-card { text-align: center; padding: 34px 20px; background: var(--surface); border-radius: 12px; margin-top: 16px !important; }
.empty-card h2 { margin: 0 0 6px; font-size: 1.2rem; }
.empty-card p { color: var(--muted); margin: 0 0 16px; }
.empty-card .primary { border-radius: 99px; padding: 9px 20px; }

/* Card: grouped sections with a small heading, like Settings */
.sect-h { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 0 0 -8px 16px; }
.cell.two { flex-direction: row; align-items: baseline; justify-content: space-between; gap: 14px; }
.cell.two .lbl { flex: none; font-size: .95rem; color: var(--ink); text-transform: none; }
.cell.two .val { text-align: right; color: var(--muted); font-size: .95rem; min-width: 0; }
.cell.two .val.ok { color: var(--av-green); } .cell.two .val.bad { color: var(--warn); } .cell.two .val.warn { color: var(--amber); }
.cell .sm { font-size: .8rem; color: var(--muted); }
.mono { font: .82rem ui-monospace, "SF Mono", Menlo, monospace; overflow-wrap: anywhere; }
.issue { flex-direction: row !important; gap: 10px; align-items: flex-start; }
.issue .dot { width: .62rem; height: .62rem; border-radius: 50%; margin-top: .42em; flex: none; background: var(--c); }
.issue .fix { display: block; font-size: .84rem; color: var(--muted); margin-top: 2px; }
.all-good { display: flex; gap: 10px; align-items: center; padding: 11px 16px; color: var(--av-green); font-weight: 500; }
.change { flex-direction: row !important; justify-content: space-between; gap: 12px; }
.change .when { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.quick-actions .qa { border: 0; font: inherit; font-size: .72rem; font-weight: 500; cursor: pointer; }
.qa.busy svg { animation: ptr-spin 1s linear infinite; }
.confirm-del { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.confirm-del span { color: var(--warn); font-size: .88rem; font-weight: 500; }

/* Edit form: selects match the text fields */
#edit label > select { font-size: 1rem; color: var(--ink); width: 100%; background: var(--surface); }
#edit .group-fields { gap: 10px; }
#edit .group-fields legend { margin-bottom: 0; }
#edit #f-name[readonly] { color: var(--muted); background: transparent; padding-left: 0; }

/* Header: the check-all button, which spins while checking */
.refresh-glyph { width: 18px; height: 18px; display: block; margin: auto; }
#check-all.spinning .refresh-glyph { animation: ptr-spin 1s linear infinite; }
#check-banner progress { width: 140px; accent-color: var(--accent); }

.help-list { padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: .93rem; }
.small-print { font-size: .8rem; margin-top: 14px; }

/* Table view: a Numbers-style grid with sortable columns and the domain column pinned on the left */
.list.wide > * { width: min(1500px, calc(100% - 40px)); }
.seg-pair { display: inline-flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.tbl-wrap { margin-top: 14px !important; background: var(--surface); border-radius: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .86rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 12px; white-space: nowrap; text-align: left; vertical-align: middle; border-bottom: var(--hair) solid var(--line); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl th { background: var(--surface); padding: 0; }
.tbl th button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 4px; width: 100%; padding: 10px 12px 8px;
  font-size: .74rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.tbl th button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl th.on button { color: var(--accent); }
.tbl th .arr { font-size: .6rem; }
.tbl tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--fill) 35%, var(--surface)); }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl td.sticky, .tbl th.sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: inset -1px 0 0 var(--line); }
.t-name { display: inline-flex; align-items: center; gap: 9px; }
.t-clip { display: inline-block; max-width: 17rem; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.avatar.sm { width: 1.45rem; height: 1.45rem; font-size: .68rem; }
.t-ok { color: var(--av-green); } .t-bad, .t-red { color: var(--warn); } .t-amber { color: var(--amber); } .t-dim { color: var(--muted); }
.t-green { color: var(--av-green); }
.t-red, .t-amber { font-weight: 500; }

@media (max-width: 760px) {
  .smart { grid-template-columns: 1fr 1fr; }
  .list.wide > * { width: calc(100% - 24px); }
  .row .rd { display: none; }
  .cell.two { flex-wrap: wrap; }
}
@media print {
  .smart, .list-tools .sort-seg, #check-banner, #demo-banner { display: none !important; }
  .chev { display: none; }
}
