/* Geist, self-hosted (SIL Open Font License, see /fonts/LICENSE.txt): no requests to Google. */
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@property --angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

:root {
  --bg: #fbfbfd;
  --sidebar: #f4f4f7;
  --surface: #ffffff;
  --raised: #ffffff;
  --bubble: #eeeef2;
  --text: #0f0f12;
  --muted: #6e6e78;
  --faint: #a1a1aa;
  --border: rgba(15, 15, 20, 0.08);
  --border-strong: rgba(15, 15, 20, 0.14);
  --hover: rgba(15, 15, 20, 0.045);
  --active: rgba(15, 15, 20, 0.07);
  --tint: #0a84ff;
  --tint-soft: rgba(10, 132, 255, 0.1);
  --shadow-sm: 0 1px 2px rgba(15, 15, 20, 0.05);
  --shadow: 0 1px 2px rgba(15, 15, 20, 0.04), 0 8px 24px -6px rgba(15, 15, 20, 0.1);
  --shadow-lg: 0 2px 4px rgba(15, 15, 20, 0.04), 0 24px 48px -12px rgba(15, 15, 20, 0.18);
  --glow-opacity: 0.22;

  --ai: conic-gradient(from var(--angle), #0894ff, #c959dd, #ff2e54, #ff9004, #0894ff);
  --ai-linear: linear-gradient(90deg, #0894ff, #c959dd 40%, #ff2e54 70%, #ff9004);

  --sidebar-w: 280px;
  --content-w: 740px;
  --font: "Geist", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0e;
    --sidebar: #111114;
    --surface: #17171b;
    --raised: #1c1c21;
    --bubble: #232329;
    --text: #f5f5f7;
    --muted: #8e8e98;
    --faint: #5c5c66;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.13);
    --hover: rgba(255, 255, 255, 0.05);
    --active: rgba(255, 255, 255, 0.08);
    --tint: #3b9bff;
    --tint-soft: rgba(59, 155, 255, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 24px 48px -12px rgba(0, 0, 0, 0.7);
    --glow-opacity: 0.35;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--tint); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--tint-soft); }

/* ---------- Orb (the AI's face) ---------- */

.orb {
  --size: 28px;
  position: relative;
  flex-shrink: 0;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--ai);
  animation: spin 9s linear infinite;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.25);
}
.orb::before {
  /* soft inner sheen */
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.25) 45%, transparent 72%);
  filter: blur(1.5px);
}
.orb::after {
  /* halo */
  content: "";
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  background: inherit;
  filter: blur(calc(var(--size) / 4));
  opacity: 0.35;
  z-index: -1;
}
.is-thinking { animation-duration: 1.6s; }

/* ---------- Avatar: memoji inside the orb's gradient ring ---------- */

.avatar {
  --size: 28px;
  position: relative;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
}
.avatar > * { grid-area: 1 / 1; }
.avatar .orb { --size: inherit; }
.avatar img { display: none; }
.avatar--xs { --size: 30px; }
.avatar--lg { --size: 72px; }

/* Inner disc inside the gradient ring; the memoji sits on it whole, never clipped. */
html.has-memoji .avatar::before {
  content: "";
  grid-area: 1 / 1;
  width: calc(var(--size) - 4px);
  height: calc(var(--size) - 4px);
  border-radius: 50%;
  background: var(--raised);
  z-index: 1;
}
html.has-memoji .avatar img {
  display: block;
  position: relative;
  z-index: 2;
  height: calc(var(--size) * 0.74);
  width: auto;
  margin-top: calc(var(--size) * 0.02);
}
html.has-memoji .avatar--lg::before { display: none; }
/* On the welcome screen the memoji floats over the glowing orb, uncropped. */
html.has-memoji .avatar--lg { --size: 120px; }
html.has-memoji .avatar--lg .orb { --size: 88px; filter: blur(16px); opacity: 0.75; }
html.has-memoji .avatar--lg img {
  width: 120px;
  height: 120px;
  border-radius: 0;
  background: none;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.25));
  animation: float 6s ease-in-out infinite;
}
.is-thinking::after { opacity: 0.7; animation: pulse 1.6s ease-in-out infinite; }

/* ---------- Layout ---------- */

.app { display: flex; height: 100dvh; }
html[data-mode="machine"] .app { display: none; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}

.sidebar__top { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 12px; }
.sidebar .sidebar__close { display: none; }

.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none !important; min-width: 0; }
.brand__text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand__name { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.brand__role { font-size: 12.5px; color: var(--muted); }

.new-chat {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-weight: 500; font-size: 14px;
  transition: border-color 0.15s, transform 0.15s;
}
.new-chat:hover { border-color: var(--border-strong); }
.new-chat:active { transform: scale(0.985); }
.new-chat kbd {
  margin-left: auto; font: 11px var(--mono); color: var(--faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}

.sidebar__nav { flex: 1; overflow-y: auto; margin: 8px -4px 0; padding: 0 4px; }
.sidebar__label { margin: 18px 10px 6px; font-size: 11.5px; font-weight: 500; color: var(--faint); letter-spacing: 0.01em; }
/* minmax(0, 1fr): long titles must not stretch the rows past the sidebar */
.sidebar__nav ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.sidebar__nav li button {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 9px;
  font-size: 14px; text-align: left; color: var(--muted);
  transition: background 0.12s, color 0.12s;
}
.sidebar__nav li button span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__nav li button span.is-renamed { animation: renamed 0.5s ease both; }
.sidebar__nav li button svg { width: 16px; height: 16px; opacity: 0.8; }
.sidebar__nav li button:hover { background: var(--hover); color: var(--text); }
.sidebar__nav li button[aria-current="true"] { background: var(--active); color: var(--text); font-weight: 500; }

.sidebar__bottom {
  display: flex; flex-wrap: wrap; align-items: center;
  padding: 10px 4px 2px;
  border-top: 1px solid var(--border);
}
.socials { display: flex; gap: 2px; }
.socials a { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--muted); }
.socials a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.socials svg { width: 17px; height: 17px; }
/* VAT number must appear on the home page (art. 35 DPR 633/72). */
.legal { flex-basis: 100%; margin: 6px 0 0; padding: 0 6px; font-size: 11.5px; color: var(--faint); }
.legal a { color: inherit; }
.legal a:hover { color: var(--text); text-decoration: none; }
.only-mobile-inline { display: none; }
.disclaimer a, .contact__note a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.disclaimer a:hover, .contact__note a:hover { color: var(--text); }
.socials svg.logo { width: 16px; height: 16px; fill: currentColor; stroke: none; }

/* Delete button on the visitor's own chats */
.sidebar__nav li.chat-item { position: relative; }
.sidebar__nav li.chat-item > button[data-user-chat] { padding-right: 36px; }
/* Same specificity as the generic sidebar button rule, declared later, so it wins. */
.sidebar__nav li .chat-del {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 28px; height: 28px; padding: 0; border-radius: 7px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.sidebar__nav li .chat-del svg { width: 15px; height: 15px; opacity: 1; }
.sidebar__nav li.chat-item:hover .chat-del,
.sidebar__nav li .chat-del:focus-visible { opacity: 1; }
.sidebar__nav li .chat-del:hover { background: var(--active); color: #ff453a; }
@media (hover: none) { .sidebar__nav li .chat-del { opacity: 0.7; } }

/* iOS-style segmented control, used for language and mode */
.segmented {
  position: relative;
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--active);
}
.segmented button {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 12px; font-weight: 500;
  color: var(--muted);
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.segmented button[aria-checked="true"] { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 0.5px var(--border); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; }

/* Ambient glow behind the welcome screen */
.main::before {
  content: "";
  position: absolute;
  left: 50%; top: 18%;
  width: min(720px, 90%); height: 360px;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side at 30% 50%, rgba(8, 148, 255, 0.18), transparent),
    radial-gradient(closest-side at 55% 45%, rgba(201, 89, 221, 0.16), transparent),
    radial-gradient(closest-side at 75% 55%, rgba(255, 144, 4, 0.12), transparent);
  filter: blur(40px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.main.is-empty::before { opacity: 1; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 16px;
  position: relative; z-index: 2;
}
.topbar__title { flex: 1; font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .only-mobile { display: none; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 11.5px var(--mono); color: var(--muted);
  padding: 4px 9px; border-radius: 99px;
  border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #30d158; box-shadow: 0 0 6px #30d158; }

.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }

/* ---------- Thread ---------- */

.thread { flex: 1; overflow-y: auto; padding: 12px 20px 32px; position: relative; z-index: 1; scroll-behavior: smooth; }
.thread:empty { display: none; }
.thread > * { max-width: var(--content-w); margin-left: auto; margin-right: auto; }

.msg { margin-bottom: 30px; animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.msg--user { display: flex; justify-content: flex-end; }
.msg--user .msg__body {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 20px 20px 6px 20px;
  background: var(--bubble);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--assistant { display: flex; gap: 16px; }
.msg--assistant .avatar { margin-top: -1px; }
.msg--assistant .msg__body { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 1px; }
.msg__body p { margin: 0 0 14px; }
.msg__body p:last-child { margin-bottom: 0; }
.msg__body strong { font-weight: 600; }
.msg__body ul, .msg__body ol { margin: 0 0 14px; padding-left: 20px; }
.msg__body li { margin: 4px 0; }
.msg__body li::marker { color: var(--faint); }
.msg__body code { font: 0.86em var(--mono); background: var(--hover); border: 1px solid var(--border); padding: 1px 5px; border-radius: 6px; }
.msg__body pre { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; overflow-x: auto; }
.msg__body pre code { background: none; border: 0; padding: 0; }
.msg--error .msg__body { color: #ff453a; }

.shimmer {
  display: inline-block;
  font-size: 14px;
  background: linear-gradient(90deg, var(--faint) 0%, var(--text) 50%, var(--faint) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.6s linear infinite;
}

/* App Store style project card */
.card {
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 10px;
  padding: 12px 14px 12px 12px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-decoration: none !important;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s, border-color 0.2s;
}
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
a.card:active { transform: scale(0.99); }
.card__icon {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 54px; height: 54px;
  border-radius: 13px; /* iOS squircle proportion */
  background: var(--icon, linear-gradient(135deg, #8e8e93, #48484a));
  color: #fff;
  font-weight: 700; font-size: 24px; letter-spacing: -0.03em;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.2), 0 2px 6px rgba(0, 0, 0, 0.12);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}
/* Real app icon over the gradient fallback; the hairline keeps white icons visible. */
.card__icon img { width: 100%; height: 100%; object-fit: cover; }
.card__icon:has(img)::after {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.1);
}
.card__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.card__name { font-weight: 600; font-size: 15px; letter-spacing: -0.015em; }
.card__desc { color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.card__tags { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.card__tags span { font: 500 10.5px var(--mono); padding: 2px 7px; border-radius: 6px; background: var(--hover); color: var(--muted); }
.card__go {
  flex-shrink: 0;
  padding: 5px 16px;
  border-radius: 99px;
  background: var(--tint-soft);
  color: var(--tint);
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* [[all-projects]]: reveals the remaining project cards */
.all-projects { margin: 0 0 12px; }
.all-projects__btn {
  display: block; width: 100%;
  padding: 11px 16px;
  border-radius: 14px;
  border: 0;
  background: var(--tint-soft);
  color: var(--tint);
  font: 600 14.5px var(--font); letter-spacing: -0.01em;
  cursor: pointer;
  transition: filter 0.15s, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.all-projects__btn:hover { filter: brightness(0.96); }
.all-projects__btn:active { transform: scale(0.98); }
.all-projects__list > p:first-child { margin-top: 0; }

/* Contact form, rendered inside a chat message */
.contact {
  display: grid; gap: 12px;
  margin: 4px 0 12px;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.contact__head { display: flex; align-items: center; gap: 12px; }
.contact__icon {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--tint-soft); color: var(--tint);
}
.contact__text { display: flex; flex-direction: column; line-height: 1.35; }
.contact__text strong { font-weight: 600; }
.contact__text span { color: var(--muted); font-size: 13.5px; }

.contact__topics { display: flex; flex-wrap: wrap; gap: 6px; }
.contact__topics label { cursor: pointer; }
.contact__topics input { position: absolute; opacity: 0; pointer-events: none; }
.contact__topics span {
  display: block;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.contact__topics input:checked + span { background: var(--tint-soft); border-color: transparent; color: var(--tint); font-weight: 500; }
.contact__topics input:focus-visible + span { outline: 2px solid var(--tint); outline-offset: 2px; }

.contact__row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.contact input:not([type="radio"]), .contact textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit; font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.contact textarea { resize: vertical; min-height: 96px; }
.contact input::placeholder, .contact textarea::placeholder { color: var(--faint); }
.contact input:focus, .contact textarea:focus { border-color: var(--tint); box-shadow: 0 0 0 3px var(--tint-soft); }
.contact [aria-invalid="true"] { border-color: #ff453a; box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.15); }
.contact .contact__hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.contact__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.contact__note { font-size: 12px; color: var(--faint); }
.contact__send {
  flex-shrink: 0;
  padding: 8px 20px;
  border-radius: 99px;
  background: var(--tint); color: #fff;
  font-weight: 600; font-size: 14px;
  transition: transform 0.15s, opacity 0.15s;
}
.contact__send:hover:not(:disabled) { transform: scale(1.03); }
.contact__send:disabled { opacity: 0.5; cursor: default; }
.contact__error { margin: 0; font-size: 13px; color: #ff453a; }

.contact--sent { display: flex; align-items: center; gap: 12px; animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.contact__check {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: #30d158; color: #fff;
}
.contact__check svg { stroke-width: 2.6; }
.contact--sent { flex-wrap: wrap; }
.contact__again {
  margin-left: auto;
  padding: 7px 14px;
  border-radius: 99px;
  background: var(--tint-soft); color: var(--tint);
  font-size: 13px; font-weight: 500;
}
.contact__again:hover { filter: brightness(1.1); }

.noscript { max-width: var(--content-w); margin: 0 auto 24px; padding: 0 20px; color: var(--muted); position: relative; z-index: 1; }

/* Easter egg: clicking the big memoji */
.welcome .avatar--lg { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
html.has-memoji .avatar--lg.is-poked img { animation: poke 0.4s ease, float 6s ease-in-out 0.4s infinite; }
.bubble {
  position: absolute; z-index: 3;
  bottom: calc(100% + 4px); left: 50%;
  translate: -50% 0;
  padding: 8px 14px;
  border-radius: 18px;
  background: var(--tint); color: #fff;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow);
  animation: bubble-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
@keyframes poke { 30% { transform: rotate(-8deg) scale(0.96); } 60% { transform: rotate(6deg); } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px) scale(0.8); } }

/* [[guinness]]: a pint poured in ~6s. Base styles are the poured pint; the keyframes
   start from the empty glass, so with reduced motion you just see the full pint. */
.pint { display: flex; align-items: center; gap: 18px; margin: 4px 0 14px; }
.pint svg { width: 84px; height: 140px; flex-shrink: 0; overflow: visible; }
.pint figcaption { color: var(--muted); font-size: 14px; max-width: 280px; animation: pint-fade 0.6s ease 5s both; }
.pint__glass { fill: rgba(255, 255, 255, 0.04); stroke: var(--border-strong); stroke-width: 2; }
.pint__stout, .pint__surge, .pint__head { transform-box: fill-box; transform-origin: 50% 100%; }
.pint__stout { animation: pint-stout 4.4s cubic-bezier(0.4, 0, 0.3, 1) both; }
.pint__surge { opacity: 0; animation: pint-surge 3.8s linear both; }
.pint__bubble { opacity: 0; animation: pint-bubble 1.4s ease-in 2 both; }
.pint__head { transform-origin: 50% 0; animation: pint-head 5s ease both; }
.pint__harp { opacity: 0.95; }
.pint.is-poured * { animation: none !important; }
@keyframes pint-stout { 0% { transform: scaleY(0); } 36% { transform: scaleY(0.82); } 80% { transform: scaleY(0.82); } 100% { transform: scaleY(1); } }
@keyframes pint-surge { 0% { transform: scaleY(0); opacity: 1; } 42% { transform: scaleY(0.82); opacity: 1; } 92% { transform: scaleY(0.82); opacity: 0; } 100% { transform: scaleY(0.82); opacity: 0; } }
@keyframes pint-bubble { 0% { opacity: 0; transform: translateY(-6px); } 30% { opacity: 0.9; } 100% { opacity: 0; transform: translateY(16px); } }
@keyframes pint-head { 0%, 72% { opacity: 0; transform: scaleY(0.2) translateY(26px); } 88% { opacity: 0.85; } 100% { opacity: 1; transform: none; } }
@keyframes pint-fade { from { opacity: 0; transform: translateY(4px); } }

/* ---------- Welcome ---------- */

.welcome { display: none; position: relative; z-index: 1; text-align: center; padding: 0 20px 32px; }
.main.is-empty .welcome { display: block; margin-top: auto; }
.main.is-empty .composer-wrap { margin-bottom: auto; }
.welcome .avatar { display: grid; margin: 0 auto 28px; }
.welcome__title {
  margin: 0 0 10px;
  font-size: clamp(30px, 5.4vw, 46px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.04em;
}
.welcome__title .grad {
  background: var(--ai-linear);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome__sub { margin: 0; color: var(--muted); font-size: 16px; }

/* ---------- Composer ---------- */

.composer-wrap { position: relative; z-index: 1; width: 100%; max-width: calc(var(--content-w) + 40px); margin: 0 auto; padding: 0 20px 14px; }

.composer-shell { position: relative; isolation: isolate; border-radius: 26px; }
/* gradient ring */
.composer-shell::before {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: var(--ai);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 2;
}
/* soft glow under the composer */
.composer-shell::after {
  content: "";
  position: absolute; inset: 6px 10px -4px;
  border-radius: inherit;
  background: var(--ai);
  filter: blur(22px);
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: -1;
}
.composer-shell:focus-within::before { opacity: 0.85; }
.composer-shell:focus-within::after { opacity: calc(var(--glow-opacity) * 0.7); }
.main.is-streaming .composer-shell::before { opacity: 1; animation: spin 2.4s linear infinite; }
.main.is-streaming .composer-shell::after { opacity: var(--glow-opacity); animation: spin 2.4s linear infinite; }

.composer {
  position: relative; z-index: 1;
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 10px 10px 20px;
  border-radius: inherit;
  background: var(--raised);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 15.5px; color: var(--text);
  padding: 7px 0; max-height: 200px;
}
.composer textarea::placeholder { color: var(--faint); }
.send {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--text); color: var(--bg);
  transition: transform 0.15s, opacity 0.15s;
}
.send:not(:disabled):hover { transform: scale(1.05); }
.send:disabled { opacity: 0.18; cursor: default; }
.send svg { width: 18px; height: 18px; stroke-width: 2.3; }

.suggestions {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.main.is-empty .suggestions { display: grid; }
.suggestions button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border);
  font-size: 14px; text-align: left; color: var(--muted);
  backdrop-filter: blur(12px);
  transition: color 0.15s, border-color 0.15s, transform 0.15s, background 0.15s;
}
.suggestions button svg { width: 15px; height: 15px; opacity: 0; transform: translateX(-4px); transition: opacity 0.15s, transform 0.15s; }
.suggestions button:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
.suggestions button:hover svg { opacity: 0.7; transform: none; }

.composer-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; padding: 0 6px;
}
.disclaimer { margin: 0; font-size: 12px; color: var(--faint); }

.mode-toggle { font-family: var(--mono); }
.mode-toggle .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.mode-toggle button[aria-checked="true"] .dot { background: #30d158; box-shadow: 0 0 6px #30d158; }

/* ---------- iOS-style alert ---------- */

.alert {
  width: 280px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: color-mix(in srgb, var(--raised) 88%, transparent);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  color: var(--text);
  box-shadow: var(--shadow-lg), 0 0 0 0.5px var(--border-strong);
  overflow: hidden;
}
.alert:focus { outline: none; }
.alert__actions button:focus { outline: none; }
.alert__actions button:focus-visible { outline: none; background: var(--active); }
.alert[open] { animation: alert-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.alert::backdrop { background: rgba(0, 0, 0, 0.35); animation: fade-in 0.2s ease both; }
.alert__body { padding: 20px 18px 18px; text-align: center; }
.alert__title { margin: 0 0 4px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.alert__msg { margin: 0; font-size: 13px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.alert__actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 0.5px solid var(--border-strong); }
.alert__actions button { padding: 11px; font-size: 16px; color: var(--tint); }
.alert__actions button + button { border-left: 0.5px solid var(--border-strong); }
.alert__actions button:hover { background: var(--hover); }
.alert__actions .alert__danger { color: #ff453a; font-weight: 600; }

/* ---------- macOS-style window (Machine view, privacy page) ---------- */

.window {
  --window-top: 48px;
  --window-bottom: 110px;
  display: flex;
  flex-direction: column;
  max-width: 820px;
  max-height: calc(100dvh - var(--window-top) - var(--window-bottom));
  margin: 0 auto;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
/* The content scrolls inside the window, so the title bar never leaves the screen. */
.window__content { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
/* Yellow: only the content collapses, the title bar stays put (height animated in window.js) */
.window.is-min .window__content { height: 0; overflow: hidden; }
.window.is-min .window__bar { border-bottom-color: transparent; }
/* Green: full screen */
.window.is-max {
  position: fixed; inset: 0; z-index: 50;
  max-width: none; max-height: none;
  border-radius: 0; border: 0;
  animation: term-zoom 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.window__bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar);
  font: 12.5px var(--mono); color: var(--muted);
  user-select: none;
  transition: border-color 0.3s;
}
.window__bar span { flex: 1; text-align: center; margin-right: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lights { display: flex; gap: 10px; margin-right: 8px; }
.light {
  position: relative;
  display: grid; place-items: center;
  width: 16px; height: 16px; border-radius: 50%;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.12);
}
/* Invisible, larger hit area so the lights are easy to click */
.light::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; }
.light--close { background: #ff5f57; }
.light--min { background: #febc2e; }
.light--max { background: #28c840; }
/* Like macOS: the symbols appear when hovering the group */
.light svg { width: 10px; height: 10px; stroke: rgba(0, 0, 0, 0.55); stroke-width: 1.4; opacity: 0; transition: opacity 0.1s; }
.light--max svg { fill: rgba(0, 0, 0, 0.55); stroke: none; }
.lights:hover svg, .light:focus-visible svg { opacity: 1; }
.light:active { filter: brightness(0.85); }

/* Full screen always wins over page-specific window sizes */
html .window.is-max { max-width: none; max-height: none; width: auto; }

/* ---------- Window over the chat (same pages, opened in place) ---------- */

.sheet {
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  margin: 0; padding: 24px 20px;
  border: 0;
  background: transparent;
  color: var(--text);
}
.sheet[open] { display: grid; place-items: center; }
.sheet::backdrop {
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  animation: fade-in 0.25s ease both;
}
.sheet .window {
  --window-top: 24px; --window-bottom: 24px;
  width: 100%; max-width: 760px;
}
.sheet[open] .window:not(.is-max) { animation: window-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1) both; }
.sheet__loading { padding: 48px; text-align: center; color: var(--muted); }
#sheet-content:focus { outline: none; }

/* ---------- Documents inside windows ---------- */

.doc { max-width: 680px; margin: 0 auto; padding: 32px 28px 56px; }
.window.is-max .doc { padding-top: 48px; }
.doc h1 { font-size: clamp(30px, 6vw, 40px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; margin: 0 0 8px; }
.doc .updated { color: var(--faint); font-size: 13px; margin: 0 0 32px; }
.doc h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; margin: 36px 0 10px; }
.doc p, .doc li { color: var(--muted); line-height: 1.7; }
.doc p { margin: 0 0 12px; }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { margin: 4px 0; }
.doc li::marker { color: var(--faint); }
.doc strong { color: var(--text); font-weight: 600; }
.doc .lead { font-size: 16.5px; color: var(--text); }
.doc .box { padding: 16px 18px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); margin: 0 0 12px; }
.doc .box p { margin: 0; }
[data-lang-section][hidden] { display: none; }

/* Project page (/progetti/<id>): App Store product page */
.app-hero { display: flex; align-items: center; gap: 20px; margin: 0 0 24px; }
.app-hero__icon.card__icon { width: 112px; height: 112px; border-radius: 26px; font-size: 48px; }
.app-hero__text { min-width: 0; }
.doc .app-hero h1 { font-size: clamp(26px, 5vw, 32px); margin: 0 0 4px; }
.doc .app-hero__desc { color: var(--muted); font-size: 15px; line-height: 1.45; margin: 0 0 14px; }
.app-hero__links { display: flex; flex-wrap: wrap; gap: 8px; }
.app-hero__btn {
  padding: 6px 18px;
  border-radius: 99px;
  background: var(--tint); color: #fff;
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase;
  text-decoration: none !important;
  transition: filter 0.15s;
}
.app-hero__btn:hover { filter: brightness(1.08); }
.app-hero__btn--ghost { background: var(--tint-soft); color: var(--tint); }
.app-hero__btn--ghost:hover { filter: brightness(0.96); }
.app-info {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(118px, 1fr);
  margin: 0 0 28px; padding: 14px 0;
  /* Scrolls sideways on narrow screens, like the App Store info row. */
  overflow-x: auto; scrollbar-width: none;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.app-info > div { padding: 0 12px; text-align: center; min-width: 0; }
.app-info > div + div { border-left: 1px solid var(--border); }
.app-info dt { font: 600 10.5px var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); margin: 0 0 4px; white-space: nowrap; }
.app-info dd { margin: 0; font-size: 13.5px; font-weight: 500; color: var(--text); white-space: nowrap; }
.app-info::-webkit-scrollbar { display: none; }
.app-ask {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; margin: 32px 0 0; padding: 13px 18px;
  border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: 600 15px var(--font); letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.2s;
}
.app-ask:hover { border-color: var(--border-strong); }
.app-ask:active { transform: scale(0.98); }
.app-ask .orb { --size: 20px; }
@media (max-width: 520px) {
  .app-hero { gap: 16px; align-items: flex-start; }
  .app-hero__icon.card__icon { width: 84px; height: 84px; border-radius: 19px; font-size: 36px; }
}

/* ---------- Machine view ---------- */

.machine { display: none; min-height: 100dvh; padding: 48px 20px 0; }
html[data-mode="machine"] .machine { display: block; }
.machine .window { --window-bottom: 140px; }
.machine__body { margin: 0; padding: 24px 28px; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.75 var(--mono); }
.window.is-max .machine__body { max-width: 820px; margin: 0 auto; padding-bottom: 110px; }
.machine__note { max-width: 820px; margin: 16px auto 0; color: var(--faint); font: 12px var(--mono); text-align: center; }
.mode-toggle--floating {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: color-mix(in srgb, var(--raised) 80%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg), 0 0 0 0.5px var(--border-strong);
  padding: 3px;
}

/* ---------- Mobile ---------- */

.scrim { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar .sidebar__close { display: grid; }
  .app.sidebar-open .sidebar { transform: none; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 10;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
  }
  .app.sidebar-open .scrim { opacity: 1; pointer-events: auto; }

  .topbar { padding: 0 8px; padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
  .topbar .only-mobile { display: grid; }
  .topbar .badge { display: none; }
  .topbar__title { text-align: center; }

  .thread { padding: 8px 16px 24px; }
  .msg--assistant { gap: 12px; }
  .msg--user .msg__body { max-width: 88%; }
  .composer-wrap { padding: 0 12px max(10px, env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 16px; } /* prevents iOS zoom on focus */
  .suggestions { grid-template-columns: 1fr; gap: 8px; }
  .suggestions button { padding: 11px 14px; }
  .composer-foot { flex-direction: column-reverse; gap: 8px; }
  .new-chat kbd { display: none; }
  .card__go { padding: 5px 13px; }
  .only-mobile-inline { display: inline; }
  .sheet { padding: 12px 10px; }
  .sheet .window { --window-top: 12px; --window-bottom: 12px; }
  .doc { padding: 24px 18px 40px; }
  .machine { padding: 16px 10px 0; }
  .machine .window { --window-top: 16px; --window-bottom: 110px; }
  .machine__body { padding: 18px 16px; }
  .contact__row { grid-template-columns: 1fr; }
  .contact__foot { flex-direction: column; align-items: stretch; }
  .contact__send { padding: 10px; }
  .contact input:not([type="radio"]), .contact textarea { font-size: 16px; } /* prevents iOS zoom */
}

@keyframes spin { to { --angle: 360deg; } }
@keyframes pulse { 50% { transform: scale(1.25); } }
@keyframes alert-in { from { opacity: 0; transform: scale(1.12); } }
@keyframes window-in { from { opacity: 0; transform: scale(0.94) translateY(8px); } }
@keyframes term-zoom { from { opacity: 0.4; transform: scale(0.96); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes renamed { from { opacity: 0; filter: blur(3px); } }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
