:root {
  /* Palette: atmosfera cinematografica, un solo accento "luce del proiettore" */
  --bg: #0a0b10;
  --bg-2: #13151f;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-solid: #171a25;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --muted-2: #6b7486;
  --accent: #ffbb55;
  --accent-strong: #ff9d2e;
  --accent-soft: rgba(255, 187, 85, 0.14);
  --accent-glow: rgba(255, 187, 85, 0.28);
  --user-bubble: #242a3a;
  --glow-accent: rgba(255, 187, 85, 0.1);
  --glow-cool: rgba(96, 120, 255, 0.08);

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow: 0 14px 44px rgba(0, 0, 0, 0.45);
  --shadow-accent: 0 10px 30px rgba(255, 157, 46, 0.28);

  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Sora", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Glow ambientali fissi: danno l'atmosfera senza toccare il layout */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(920px 560px at 84% -8%, var(--glow-accent), transparent 60%),
    radial-gradient(820px 720px at 2% 112%, var(--glow-cool), transparent 62%);
}

h1, h2, h3, .brand-name, .film-titl, .filter-text { font-family: var(--font-display); }

:focus-visible { outline: 2px solid var(--accent-glow); outline-offset: 2px; border-radius: 6px; }

/* --- Topbar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 3vw, 30px);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 21, 31, 0.85), rgba(10, 11, 16, 0.6));
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--accent);
  background: linear-gradient(150deg, var(--accent-soft), rgba(255, 187, 85, 0.04));
  border: 1px solid var(--line-strong);
  flex: none;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-weight: 700; font-size: 20px; letter-spacing: -0.2px; }
.brand-tag { color: var(--muted); font-size: 13px; margin-left: 2px; }
.badge {
  font-family: var(--font-body);
  font-size: 11px; font-weight: 600; letter-spacing: .4px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--line-strong);
  padding: 5px 11px; border-radius: 999px;
}

/* --- Layout --- */
.layout {
  display: grid; grid-template-columns: minmax(330px, 420px) 1fr;
  height: calc(100vh - 71px);
}
.chat-pane { display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-pane::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, var(--line), transparent);
}
.panel { display: flex; flex-direction: column; min-height: 0; }

/* --- Chat stream --- */
.stream { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { max-width: 86%; opacity: 0; transform: translateY(8px); animation: rise .32s ease forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.bubble {
  padding: 12px 15px; border-radius: var(--r);
  border: 1px solid var(--line);
  white-space: pre-wrap; word-wrap: break-word;
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}
.msg.user .bubble {
  background: linear-gradient(150deg, var(--accent-strong), var(--accent));
  color: #201400; border-color: transparent;
  box-shadow: var(--shadow-accent);
}
.msg.assistant .bubble { background: var(--panel-solid); }
.bubble p { margin: 0; }
.bubble p + p { margin-top: 8px; }
.cursor { display: inline-block; width: 7px; height: 1.05em; margin-left: 3px; vertical-align: text-bottom; background: var(--accent); border-radius: 2px; animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.tool-chip {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  backdrop-filter: blur(8px);
}
.tool-chip svg { width: 12px; height: 12px; color: var(--accent); }

/* --- Suggestions + composer --- */
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 22px 14px; }
.suggestions[aria-hidden="true"] { opacity: .6; }
.chip {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; cursor: pointer;
  transition: border-color .18s ease, color .18s ease, background .18s ease, transform .12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }

.composer { display: flex; gap: 10px; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: linear-gradient(180deg, transparent, rgba(19, 21, 31, 0.6)); backdrop-filter: blur(12px); }
.mic { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: grid; place-items: center; cursor: pointer; align-self: center; transition: color .18s ease, border-color .18s ease, background .18s ease; }
.mic svg { width: 19px; height: 19px; }
.mic:hover:not(:disabled) { color: var(--accent); border-color: var(--line-strong); }
.mic.rec { color: #fff; background: var(--accent-strong); border-color: transparent; }
.mic:disabled { opacity: .4; cursor: default; }
#input {
  flex: 1; font: inherit; color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 12px 18px; outline: none;
  transition: border-color .18s ease, background .18s ease;
}
#input::placeholder { color: var(--muted-2); }
#input:focus { border-color: var(--accent); background: var(--panel-solid); box-shadow: 0 0 0 3px var(--accent-soft); }
.send {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: none;
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  color: #201400; display: grid; place-items: center; cursor: pointer;
  box-shadow: var(--shadow-accent);
  transition: transform .14s ease, box-shadow .2s ease, opacity .2s ease;
}
.send svg { width: 19px; height: 19px; }
.send:hover:not(:disabled) { transform: translateY(-1px) scale(1.03); }
.send:disabled { opacity: .45; cursor: default; box-shadow: none; }

/* --- Filter bar --- */
.filterbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px clamp(16px, 2.4vw, 26px); border-bottom: 1px solid var(--line); }
.filter-text { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.filter-date {
  font-size: 12.5px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px;
}

/* --- Map --- */
.map { height: 42%; min-height: 220px; background: var(--panel-solid); border-bottom: 1px solid var(--line); }
.leaflet-container { background: var(--bg-2); }
.leaflet-popup-content-wrapper { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--panel-solid); }
.leaflet-popup-content { margin: 11px 14px; font-size: 13px; line-height: 1.4; }
.leaflet-popup-content strong { display: block; margin-bottom: 3px; font-family: var(--font-display); }
.ts-marker { background: transparent; border: none; }
.ts-marker-inner {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  color: #201400; border: 2px solid #1a1200;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  box-shadow: var(--shadow-accent);
}

/* --- Results list --- */
.results { flex: 1; overflow-y: auto; padding: 18px clamp(12px, 2vw, 22px) 28px; min-height: 0; }
.results-empty { padding: 52px 24px; text-align: center; color: var(--muted); }
.results-empty .empty-mark { width: 72px; height: 72px; color: var(--accent); opacity: .85; margin-bottom: 18px; }
.results-empty h3 { font-size: 18px; margin: 0 0 8px; color: var(--text); font-weight: 600; }
.results-empty p { max-width: 360px; margin: 0 auto; font-size: 14.5px; line-height: 1.55; }

/* --- Film cards (streaming-style) --- */
.film {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  margin: 12px 0; overflow: hidden;
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.film:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.film-head { display: flex; gap: 14px; padding: 14px; cursor: pointer; align-items: flex-start; }
.film-head:hover { background: rgba(255, 255, 255, 0.02); }
.poster {
  flex: none; width: 58px; height: 78px; border-radius: 12px;
  background: linear-gradient(150deg, var(--panel-2), #12161c);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: rgba(255, 255, 255, 0.92); font-weight: 700; font-size: 16px;
  letter-spacing: .5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.film-titl { font-weight: 600; font-size: 16.5px; letter-spacing: -0.2px; line-clamp: 2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.film-meta { color: var(--muted); font-size: 12.5px; margin-top: 7px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: rgba(255, 255, 255, 0.03); }
.tag.fmt { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.film-syn { color: var(--muted); font-size: 13.5px; line-height: 1.55; margin: 2px 14px 12px; display: none; }
.film.open .film-syn { display: block; }
.film-schedule { display: none; padding: 4px 14px 16px; border-top: 1px solid var(--line); margin-top: 4px; }
.film.open .film-schedule { display: block; }
.theater { padding: 12px 0 0; margin-top: 12px; }
.theater-name { font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.theater-name .dist { color: var(--muted); font-weight: 400; font-size: 12px; }
.times { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.time-btn {
  font: inherit; font-size: 12.5px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 6px;
  transition: border-color .18s ease, background .18s ease, transform .12s ease;
}
.time-btn:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.time-btn .fmt { color: var(--muted); font-size: 11.5px; }
.time-btn .price { color: var(--accent); font-weight: 700; }

/* --- Mobile --- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; height: calc(100vh - 71px); }
  .chat-pane { border-right: none; }
  .chat-pane::after { left: 0; right: auto; top: auto; bottom: 0; width: auto; height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); }
  .map { height: 46%; }
  .brand-tag { display: none; }
}
@media (max-width: 480px) {
  .layout { grid-template-rows: 1.1fr .9fr; }
  .msg { max-width: 94%; }
  .stream { padding: 16px; }
  .send, .mic { width: 44px; height: 44px; }
}
