/* My Apps Console — the same Apple look as the other apps (built from Our Contacts' styles): system colours,
   grouped rounded lists. The Console's own parts 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); }

/* ── 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 icon */
  content: ""; position: absolute; left: calc(16px + 2.1rem + 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; }

/* ── 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); }
.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; }
fieldset .link { align-self: flex-start; font-size: .9rem; font-weight: 500; }
.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; }
.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); }
    .list > * { width: calc(100% - 24px); }
  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; }
  .card-actions { flex-wrap: wrap; }
  .meta { width: 100%; flex-basis: 100%; order: 9; }
}

/* ── Printing ──
   With a contact open: just that contact's card. Otherwise: the whole list (or the search results)
   as a compact address book. Always light colours, whatever the screen is set to. */
@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, #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; }

}

/* 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; } }

/* Sign-in button waits 2s so it does not flash on reload */
#signin-btn { animation: signin-appear .25s ease 2s both; }
@keyframes signin-appear { from { opacity: 0; visibility: hidden; } to { opacity: 1; visibility: visible; } }

/* Big screens (an Apple Studio Display, say): roomier windows */
@media (min-width: 1200px) and (min-height: 700px) {
  dialog.card { width: min(760px, 92vw); }
    .help { width: min(760px, 92vw); }
  .import { width: min(900px, 92vw); }
}

/* Dark mode: windows (a domain's card, a contact) stand out from the page behind them:
   a lighter window, lighter groups inside it, a thin light edge and a darker backdrop. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) dialog { box-shadow: 0 0 0 1px rgba(255, 255, 255, .16), 0 24px 70px rgba(0, 0, 0, .7); }
  :root:not([data-theme="light"]) dialog::backdrop { background: rgba(0, 0, 0, .62); }
  :root:not([data-theme="light"]) dialog.card { background: var(--surface); }
  :root:not([data-theme="light"]) dialog.card .group { background: var(--raised); }
}
:root[data-theme="dark"] dialog { box-shadow: 0 0 0 1px rgba(255, 255, 255, .16), 0 24px 70px rgba(0, 0, 0, .7); }
:root[data-theme="dark"] dialog::backdrop { background: rgba(0, 0, 0, .62); }
:root[data-theme="dark"] dialog.card { background: var(--surface); }
:root[data-theme="dark"] dialog.card .group { background: var(--raised); }

/* ════════════════ My Apps Console ════════════════ */
.list { padding-bottom: 70px; }
.summary { margin-top: 16px !important; padding: 18px 20px; border-radius: 16px; background: var(--surface); }
.sum-head { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.s-green { color: #248a3d; } .s-red { color: var(--warn); } .s-muted { color: var(--muted); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .s-green { color: #30d158; } }
:root[data-theme="dark"] .s-green { color: #30d158; }
.sum-sub { margin-top: 2px; font-size: .88rem; color: var(--muted); }
.sum-list { margin: 10px 0 0; font-size: .9rem; }
.warn-note { margin-top: 10px !important; background: color-mix(in srgb, var(--warn) 12%, var(--surface)) !important; }

.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; margin-top: 14px !important; }
.list > .apps { width: min(1100px, calc(100% - 40px)); }
.app-card { background: var(--surface); border-radius: 16px; padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: inset 0 0 0 1px transparent; }
.app-card.needs { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--warn) 55%, transparent); }
.app-head { display: flex; align-items: center; gap: 12px; }
.app-icon { width: 44px; height: 44px; 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); background: var(--fill); }
.app-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-name b { font-size: 1.05rem; }
.app-name a { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.needs-line { margin: 0; font-size: .85rem; font-weight: 600; color: var(--warn); }
.kvs { display: flex; flex-direction: column; }
.kv { display: grid; grid-template-columns: 7.6em 1fr; gap: 10px; padding: 6px 0; border-top: var(--hair) solid var(--line); font-size: .9rem; align-items: baseline; }
.kv .k { color: var(--muted); font-size: .82rem; }
.kv .v { min-width: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.panel .kvs { padding: 4px 16px 2px; }
.panel .kv:first-child { border-top: 0; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.p-green { color: #248a3d; background: color-mix(in srgb, #34c759 16%, var(--surface)); }
.p-red { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.p-amber { color: #b25000; background: color-mix(in srgb, var(--amber) 18%, var(--surface)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .p-green { color: #30d158; } :root:not([data-theme="light"]) .p-amber { color: #ffb340; } }
:root[data-theme="dark"] .p-green { color: #30d158; } :root[data-theme="dark"] .p-amber { color: #ffb340; }
.use { display: flex; align-items: center; gap: 8px; width: 100%; }
.small { font-size: .78rem; }
.meter { flex: none; width: 70px; height: 7px; border-radius: 99px; background: var(--fill); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; }
.m-green > span { background: #34c759; } .m-amber > span { background: var(--amber); } .m-red > span { background: var(--warn); }
.app-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.panel .app-links { padding: 4px 16px 14px; }
.btn { display: inline-block; padding: 5px 12px; border-radius: 99px; background: var(--fill); font-size: .82rem; font-weight: 600; }
.btn:hover { text-decoration: none; filter: brightness(.96); }
#check-btn { border-radius: 99px; padding: 7px 16px; }
#check-btn:disabled { opacity: .7; }
.panel { padding: 4px 0; }
.pad { margin: 8px 16px 12px; font-size: .88rem; }
.runs { display: flex; flex-direction: column; }
.run { display: flex; justify-content: space-between; gap: 12px; padding: 8px 16px; font-size: .92rem; }
.run + .run { border-top: var(--hair) solid var(--line); }
.run-at { font-size: .85rem; white-space: nowrap; }
.lines summary { cursor: pointer; color: var(--accent); font-size: .85rem; margin-top: 4px; }
.lines div { font-size: .82rem; color: var(--muted); padding: 2px 0; }
.lines .bad { color: var(--warn); }
code { background: var(--fill); padding: 1px 6px; border-radius: 5px; }
@media (max-width: 760px) {
  .list > .apps { width: calc(100% - 24px); }
  .apps { grid-template-columns: 1fr; }
  .bar { flex-wrap: nowrap; }
  .tools { width: auto; }
  .app-title { font-size: 1.45rem; }
  .run { flex-direction: column; gap: 0; }
}

/* Everything the same width as the cards */
.list > * { width: min(1100px, calc(100% - 40px)); }
.use { white-space: nowrap; }
.use .meter { width: 56px; }
.app-head kbd { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
#check-btn.checking .ci { display: inline-block; animation: ptr-spin .8s linear infinite; }
@media (max-width: 760px) {
  .list > * { width: calc(100% - 24px); }
  #check-btn { width: 38px; height: 34px; padding: 0; }
  #check-btn .ct { display: none; }
  .app-title { font-size: 1.35rem; min-width: 0; }
  .app-title button { overflow: hidden; text-overflow: ellipsis; }
}
.sum-list { padding-left: 1.1em; }
.sum-list li { margin: 2px 0; }

/* The lower panels: one under another on narrow screens, side by side on wide ones */
.lower { display: grid; grid-template-columns: 1fr; gap: 0 16px; align-items: start; }
.lower .lh { position: static; }
@media (min-width: 1300px) {
  .lower { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .8fr); }
}
/* The Studio Display (Chrome maximized, about 2560 wide): use nearly the whole width */
@media (min-width: 1600px) {
  .list > *, .list > .apps { width: min(2400px, calc(100% - 64px)); }
  .apps { grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 16px; }
  .summary { display: flex; align-items: baseline; gap: 10px 28px; flex-wrap: wrap; }
  .summary .sum-list { flex-basis: 100%; columns: 2; column-gap: 40px; }
}

/* Check now: Apple's yellow while it's checking (with dark text, readable on yellow) */
#check-btn.checking, #check-btn.checking:disabled { background: #ffcc00; color: #1d1d1f; opacity: 1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #check-btn.checking { background: #ffd60a; } }
:root[data-theme="dark"] #check-btn.checking { background: #ffd60a; }
