/* web-f5: AI, tracking and Activity, sync, Move Accounts to iPhone. The app's tokens
   (app.css :root), nothing written twice; no hover lift: colour only (DESIGN.md 1). */

/* ---- The AI glow (AIGlow.swift): three soft lights glide along the edge, inside it;
   brighter while the AI writes; still for those who ask for less motion. ---- */
@property --f5-turn { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.ai-glow { position: relative; }
.ai-glow::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1.5px;
    background: conic-gradient(from var(--f5-turn), transparent 0deg, #a855f7 30deg, #ec4899 60deg, transparent 100deg,
        transparent 130deg, #f97316 160deg, #eab308 190deg, transparent 230deg,
        transparent 250deg, #3b82f6 280deg, #14b8a6 310deg, transparent 350deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    filter: blur(1.2px); opacity: .62; transition: opacity .8s ease;
    animation: f5-turn 13s linear infinite;
}
.ai-glow.working::after { opacity: 1; filter: blur(0.8px); }
@keyframes f5-turn { to { --f5-turn: 360deg; } }
@media (prefers-reduced-motion: reduce) {
    .ai-glow::after { animation: none; }
    .ai-dots i { animation: none !important; opacity: .7; }
    .ai-placeholder { transition: none !important; }
}

/* The metal glass button (MetalGlassButtonStyle): graphite, lighter at the top. */
.metal {
    width: 32px; height: 32px; flex: none; border: 0; border-radius: 16px; color: #fff; display: inline-grid; place-items: center;
    background: linear-gradient(#3a3b40, #16171a); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 0 0 1px rgba(255, 255, 255, .06), 0 2px 8px rgba(0, 0, 0, .18);
    font-size: calc(12px * var(--text-scale)); font-weight: 600; transition: filter .15s;
}
.metal:hover { filter: brightness(1.15); }
.metal:active { filter: brightness(.9); }
.metal:disabled { color: rgba(255, 255, 255, .45); filter: none; }
.metal.capsule { width: auto; height: 30px; border-radius: 15px; padding: 0 14px; }

.ai-dots { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: f5-breathe 1.2s ease-in-out infinite; }
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes f5-breathe { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.ai-accent { color: var(--accent); }

/* ---- The Draft with AI screen (AIDraftView.swift) ---- */
.ai-draft { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ai-draft.empty { justify-content: center; align-items: center; padding: 0 40px 60px; }
.ai-welcome { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-3); }
.ai-title { margin: 8px 0 0; font-size: calc(22px * var(--text-scale)); font-weight: 500; color: var(--text); }
.ai-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.ai-turns { max-width: 760px; margin: 0 auto; padding: 26px 44px 20px; display: flex; flex-direction: column; gap: 14px; }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 6px; }
.ai-head-title { font-size: calc(17px * var(--text-scale)); font-weight: 500; }
.ai-request { display: flex; justify-content: flex-end; padding-left: 60px; }
.ai-request .bubble { background: var(--prominent); color: var(--prominent-text); padding: 12px 16px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: calc(14px * var(--text-scale)); }
.ai-reply { background: var(--pill); border-radius: 16px; display: flex; flex-direction: column; }
.ai-reply-tools { display: flex; justify-content: flex-end; gap: 2px; padding: 8px 8px 0; }
.ai-reply-tools .tool { color: var(--text-2); }
.ai-reply-tools .tool.on { color: var(--green); }
.ai-reply-text { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.ai-reply-tools + .ai-reply-text { padding-top: 0; }
.ai-to { font-size: calc(12px * var(--text-scale)); color: var(--text-2); }
.ai-subject { font-size: calc(15px * var(--text-scale)); font-weight: 600; }
.ai-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: calc(14px * var(--text-scale)); }
.ai-edit-subject, .ai-edit-body { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; padding: 0; width: 100%; }
.ai-edit-subject { font-size: calc(15px * var(--text-scale)); font-weight: 600; }
.ai-edit-body { resize: none; line-height: 1.5; font-size: calc(14px * var(--text-scale)); min-height: 120px; overflow: hidden; }
.ai-reply-foot { display: flex; justify-content: flex-end; padding: 0 12px 12px; }
.ai-reply-foot .key { opacity: .6; font-size: calc(11px * var(--text-scale)); }
.ai-thinking { padding: 8px 6px; }
.ai-failure { background: color-mix(in srgb, var(--red) 6%, transparent); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-failure p, .popover p { margin: 0; line-height: 1.45; }
.ai-failure p.bad, .popover p.bad, .fine.bad { color: var(--red); }
.ai-failure .actions, .popover .actions { display: flex; gap: 8px; }
.ai-bottom { flex: none; width: 100%; max-width: 760px; margin: 0 auto; padding: 14px 24px 10px; display: flex; flex-direction: column; gap: 8px; }
.ai-draft.empty .ai-bottom { max-width: 600px; padding: 18px 0 0; }
.ai-input { display: flex; align-items: flex-end; gap: 10px; padding: 7px 7px 7px 18px; border: 1px solid var(--outline); border-radius: 23px; background: var(--card); }
.ai-input-text { position: relative; flex: 1; min-width: 0; display: flex; }
.ai-input-field { flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: inherit; font-size: calc(14px * var(--text-scale)); line-height: 20px; padding: 6px 0; max-height: 164px; overflow-y: auto; }
.ai-placeholder { position: absolute; left: 0; top: 6px; color: var(--text-3); pointer-events: none; font-size: calc(14px * var(--text-scale)); line-height: 20px; transition: opacity .18s, transform .18s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ai-placeholder.turning { opacity: 0; transform: translateY(-6px); }
.ai-hints { display: flex; justify-content: center; gap: 14px; color: var(--text-3); font-size: calc(11px * var(--text-scale)); }
.ai-hints kbd { font: inherit; border: 1px solid var(--outline); border-radius: 4px; padding: 0 4px; margin-right: 2px; }
.streaming { animation: f5-fade-in .25s ease; }
@keyframes f5-fade-in { from { opacity: .6; } }

/* The sidebar's Draft with AI row is a plain row of the sidebar. */

/* ---- The composer's Draft with AI line ---- */
.format-bar > .spacer { flex: 1; }
.ai-pill { gap: 6px; height: 26px; padding: 0 11px; }
.ai-pill.on { background: var(--prominent); color: var(--prominent-text); }
.compose-ai-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--hairline); }
.compose-ai-bar .spinner { color: var(--text-3); }
.ai-line { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--outline); background: var(--card); }
.ai-line-icon { color: var(--accent); flex: none; }
.ai-line-field { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: calc(13px * var(--text-scale)); }
.ai-line-problem { padding: 6px 14px; color: var(--red); font-size: calc(12px * var(--text-scale)); }

/* ---- Quick reply: AI mode and Suggest Replies ---- */
.quick-reply .quick-ai.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.quick-reply .quick-ai:not(:disabled):hover { color: var(--text); }
.quick-reply .quick-suggest { justify-content: center; }
.quick-pills { display: flex; gap: 6px; align-items: center; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.quick-pill { height: 26px; padding: 0 11px; background: var(--pill); color: var(--text); border: 1px solid var(--outline); flex: none; }
.quick-suggesting { display: inline-flex; gap: 6px; align-items: center; height: 26px; color: var(--text-3); font-size: calc(12px * var(--text-scale)); }

/* ---- Popovers: the summary and Activity (the Mac's popovers) ---- */
.popover {
    position: fixed; z-index: 65; background: var(--card); color: var(--text); border: 1px solid var(--outline); border-radius: 12px;
    box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; outline: none;
    animation: fade .12s ease both;
}
.popover-head { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: calc(12px * var(--text-scale)); font-weight: 500; }
.summary-text p { font-size: calc(13px * var(--text-scale)); }
.f5-tools { margin-left: 2px; }

/* ---- Activity (ActivityView.swift) ---- */
.bell { position: relative; }
.bell .badge {
    position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
    background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center;
    font-variant-numeric: tabular-nums; box-shadow: 0 0 0 1.5px var(--card); pointer-events: none;
}
.popover.activity { padding: 0; gap: 0; height: 440px; }
.activity-head { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--hairline); flex: none; }
.activity-head h3 { margin: 0; font-size: calc(15px * var(--text-scale)); font-weight: 600; }
.activity-list { flex: 1; overflow-y: auto; }
.activity-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 0 32px; text-align: center; color: var(--text-2); font-size: calc(12px * var(--text-scale)); }
.activity-empty .i { color: var(--text-3); }
.activity-row { border-bottom: 1px solid var(--hairline); }
.activity-line { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 9px 12px; border: 0; background: none; text-align: left; color: var(--text); transition: background-color .12s; }
.activity-line:hover { background: var(--row-hover); }
.activity-line .dot { width: 28px; height: 28px; border-radius: 50%; color: #fff; display: grid; place-items: center; flex: none; }
.activity-line .dot.open { background: var(--accent); }
.activity-line .dot.click { background: #8b5cf6; }
.activity-line .dot.receipt { background: var(--green); }
.activity-line .what { font-size: calc(12px * var(--text-scale)); line-height: 1.35; }
.activity-line .when { font-size: calc(11px * var(--text-scale)); color: var(--text-3); margin-top: 3px; }
.activity-times { padding: 0 12px 9px 50px; display: flex; flex-direction: column; gap: 4px; font-size: calc(11px * var(--text-scale)); color: var(--text-2); }
.activity-times .fold { border: 0; background: none; padding: 0; color: var(--text-2); font-weight: 500; display: inline-flex; gap: 4px; align-items: center; align-self: flex-start; }
.activity-times .fold:hover { color: var(--text); }
.activity-times .time { display: flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.activity-times .time i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .6; }
.activity-times .via { color: var(--text-3); }

/* ---- Settings panes ---- */
.f5-pane { display: flex; flex-direction: column; gap: 10px; }
.f5-pane h4 { margin: 8px 0 0; font-size: calc(12px * var(--text-scale)); font-weight: 600; color: var(--text-2); }
.field-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 180px; }
.field-label { width: 96px; flex: none; color: var(--text-2); }
.field-row.presets { gap: 6px; }
.field-row .grow { flex: 1; color: var(--text-2); }
.settings-footer { margin: -4px 0 4px; color: var(--text-3); font-size: calc(11px * var(--text-scale)); line-height: 1.45; }
.fine.ok { color: var(--green); display: inline-flex; gap: 4px; align-items: center; }
.f5-status { display: flex; align-items: center; gap: 8px; }
.f5-status .grow { flex: 1; }
.f5-devices { display: flex; flex-direction: column; border: 1px solid var(--outline); border-radius: 8px; }
.f5-devices > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--hairline); }
.f5-devices > div:first-child { border-top: 0; }
.f5-devices .muted { color: var(--text-3); }
.f5-intro { display: flex; gap: 14px; align-items: center; }
.f5-intro .tile { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }

/* ---- Move Accounts to iPhone ---- */
.transfer { display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; padding: 6px 4px 2px; }
.transfer h2 { margin: 0; font-size: calc(17px * var(--text-scale)); }
.transfer p { margin: 0; color: var(--text-2); line-height: 1.45; }
.transfer canvas { width: 196px; height: 196px; padding: 8px; background: #fff; border-radius: 10px; image-rendering: pixelated; }
.transfer .clock { font-variant-numeric: tabular-nums; color: var(--text-3); font-size: calc(12px * var(--text-scale)); }
.transfer .buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.transfer .behind { font-size: calc(12px * var(--text-scale)); color: var(--text-3); }
.f5-code { width: 168px; height: 168px; padding: 8px; background: #fff; border-radius: 10px; image-rendering: pixelated; flex: none; }
