:root {
  --bg: #f5f5f7;
  --bg-soft: #fbfbfd;
  --card: #ffffff;
  --card-2: #f0f0f3;
  --border: rgba(0, 0, 0, 0.09);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #6d5bd0;
  --accent-2: #2b6cb0;
  --accent-soft: #f0eefc;
  --danger: #c0506a;
  --ok: #2f7d6b;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

[role="button"]:focus-visible,
.tl-node:focus-visible,
.tl-card:focus-visible,
.character:focus-visible,
.mini-item:focus-visible,
.issue-item:focus-visible,
.cd-moment:focus-visible,
.project-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
  background: rgba(251, 251, 253, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 0.9rem; }
.brand-mark {
  font-size: 1.8rem;
  color: var(--accent);
  filter: drop-shadow(0 0 12px rgba(109, 91, 208, 0.5));
}
.brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: 0.02em; }
.brand p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; }
.brand-h1 { margin: 0; display: flex; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-tagline { margin: 0; color: var(--muted); font-size: 0.85rem; }
.ed-footer-logo { height: 26px; width: auto; display: block; }
[data-theme="dark"] .brand-logo,
[data-theme="dark"] .ed-footer-logo { filter: brightness(0) invert(1); }

.model-badge {
  font-size: 0.75rem;
  color: var(--accent-2);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}

.visit-bar { width: 100%; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.visit-bar-inner { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.4rem clamp(1rem, 4vw, 3rem); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.01em; }
.visit-live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(47, 125, 107, 0.5); animation: visitPulse 2s infinite; }
@keyframes visitPulse { 0% { box-shadow: 0 0 0 0 rgba(47, 125, 107, 0.45); } 70% { box-shadow: 0 0 0 6px rgba(47, 125, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 125, 107, 0); } }

main {
  width: min(1180px, 92vw);
  margin: 2rem auto 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.4vw, 1.8rem);
  box-shadow: var(--shadow);
}

.upload-card { text-align: center; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.6rem 1rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  outline: none;
}
.dropzone:hover, .dropzone:focus, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(109, 91, 208, 0.06);
  transform: translateY(-2px);
}
.dropzone-icon { font-size: 2.2rem; color: var(--accent); }
.dropzone-title { margin: 0.6rem 0 0.2rem; font-size: 1.05rem; font-weight: 600; }
.dropzone-sub { margin: 0; color: var(--muted); font-size: 0.88rem; }
.link { color: var(--accent-2); text-decoration: underline; }

.file-row {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.file-name { color: var(--text); font-size: 0.9rem; word-break: break-all; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s, background 0.15s;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.hint { color: var(--muted); font-size: 0.8rem; margin: 0.9rem 0 0; min-height: 1rem; }

.progress-card { display: flex; align-items: center; gap: 1.2rem; }
.spinner {
  width: 34px; height: 34px; flex: none;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-body { flex: 1; }
.progress-body p { margin: 0 0 0.5rem; font-size: 0.92rem; }
.progress-track { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.4s ease; }
.progress-body small { color: var(--muted); display: block; margin-top: 0.4rem; }

.error-banner {
  background: rgba(192, 80, 106, 0.1);
  border: 1px solid rgba(192, 80, 106, 0.35);
  color: #9c3f5e;
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
}

.hero { display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.hero-main { flex: 1; min-width: 260px; }
.eyebrow { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 0.5rem; }
.hero h2 { margin: 0 0 0.5rem; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.logline { color: var(--text); font-size: 1rem; margin: 0 0 0.6rem; line-height: 1.5; }
.conflict { color: var(--accent); font-size: 0.88rem; margin: 0; }

.stats { display: flex; gap: 1rem; }
.stat {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1.2rem;
  text-align: center;
  min-width: 92px;
}
.stat strong { display: block; font-size: 1.5rem; color: var(--accent); }
.stat span { color: var(--muted); font-size: 0.75rem; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.section-head h3 { margin: 0; font-size: 1.05rem; }

.timeline-tools { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.legend { display: inline-flex; align-items: center; gap: 0.4rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.key { background: var(--accent); box-shadow: 0 0 10px rgba(109, 91, 208, 0.7); }
.dot.normal { background: var(--accent-2); }
select {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-family: inherit;
  font-size: 0.82rem;
}

.timeline-scroll { overflow-x: auto; padding: 0.5rem 0 1rem; }
.timeline {
  position: relative;
  height: 320px;
  min-width: 100%;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border) 6%, var(--border) 94%, transparent);
}
.tl-node {
  position: absolute;
  top: 50%;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid var(--bg);
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  z-index: 3;
}
.tl-node.key { background: var(--accent); width: 19px; height: 19px; box-shadow: 0 0 14px rgba(109, 91, 208, 0.6); }
.tl-node:hover { transform: translate(-50%, -50%) scale(1.35); z-index: 6; }
.tl-node.dim { opacity: 0.18; }
.tl-node.active { box-shadow: 0 0 0 5px rgba(79, 143, 208, 0.25); }

.tl-card {
  position: absolute;
  width: 190px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, opacity 0.2s;
  z-index: 2;
}
.tl-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tl-card.key { border-color: rgba(109, 91, 208, 0.55); }
.tl-card.dim { opacity: 0.22; }
.tl-card h4 { margin: 0 0 0.25rem; font-size: 0.82rem; line-height: 1.25; }
.tl-card p { margin: 0; font-size: 0.72rem; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tl-card .tl-connector {
  position: absolute;
  left: 50%;
  width: 1px;
  background: var(--border);
}
.tl-card.up { bottom: calc(50% + 14px); }
.tl-card.up .tl-connector { top: 100%; height: 14px; }
.tl-card.down { top: calc(50% + 14px); }
.tl-card.down .tl-connector { bottom: 100%; height: 14px; }

.characters { display: flex; flex-direction: column; gap: 0.8rem; }
.character {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.character:hover { border-color: var(--accent-2); transform: translateX(2px); }
.character.selected { border-color: var(--accent); background: rgba(109, 91, 208, 0.07); }
.character-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.character-head strong { font-size: 0.95rem; }
.character p { margin: 0.45rem 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.character .aliases { margin-top: 0.35rem; font-size: 0.74rem; color: var(--accent-2); }
.character .count { font-size: 0.72rem; color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge.protagonist {
  color: #5540b8;
  border-color: rgba(109, 91, 208, 0.5);
  background: rgba(109, 91, 208, 0.13);
}
.badge.antagonist {
  color: #a83f58;
  border-color: rgba(192, 80, 106, 0.5);
  background: rgba(192, 80, 106, 0.13);
}
.badge.supporting {
  color: #2f7aa6;
  border-color: rgba(79, 143, 208, 0.5);
  background: rgba(79, 143, 208, 0.13);
}
.badge.minor {
  color: #6b7284;
  border-color: rgba(140, 148, 168, 0.5);
  background: rgba(140, 148, 168, 0.16);
}

.key-events { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; }
.key-events li { font-size: 0.85rem; line-height: 1.4; }
.key-events li span { color: var(--muted); display: block; font-size: 0.76rem; margin-top: 0.15rem; }

.arc { display: flex; flex-direction: column; gap: 0.9rem; }
.arc-item { border-left: 2px solid var(--accent); padding-left: 0.9rem; }
.arc-item strong { font-size: 0.88rem; }
.arc-item p { margin: 0.2rem 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }

.themes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.theme-chip {
  background: rgba(79, 143, 208, 0.12);
  border: 1px solid rgba(79, 143, 208, 0.35);
  color: var(--accent-2);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}
.synopsis { font-size: 0.85rem; color: var(--muted); line-height: 1.6; margin: 0; }

.all-events { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.all-events li { font-size: 0.86rem; line-height: 1.45; }
.all-events li .meta { color: var(--muted); font-size: 0.76rem; margin-top: 0.2rem; display: flex; gap: 0.8rem; flex-wrap: wrap; }
.all-events li em { color: var(--text); font-style: normal; font-weight: 600; }

.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
@media (max-width: 860px) { .grid-two { grid-template-columns: 1fr; } .stats { width: 100%; } }

.modal {
  position: fixed; inset: 0;
  background: rgba(51, 48, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 200;
}
.modal-box {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  width: min(520px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-box h3 { margin: 0.7rem 0 0.5rem; }
.modal-box > p { color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.modal-close {
  position: absolute; top: 0.8rem; right: 0.9rem;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-meta { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.9rem; font-size: 0.82rem; margin: 1rem 0 0; }
.modal-meta dt { color: var(--muted); }
.modal-meta dd { margin: 0; }
.modal-box .chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }
.modal-box .chips span {
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.25rem 0.7rem; font-size: 0.78rem;
}

.footer { text-align: center; color: var(--muted); font-size: 0.78rem; padding: 2rem 1rem; }

.view-toggle {
  display: inline-flex;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.view-toggle button {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.view-toggle button.active { background: var(--accent); color: #ffffff; font-weight: 600; }
.view-toggle button:not(.active):hover { color: var(--text); }
.timeline-subhead { margin-bottom: 0.8rem; }

.timeline.graph { min-width: 0; }
.timeline.graph::before { display: none; }
.timeline-scroll.graph { overflow: visible; padding: 0; }

.radial-edge { stroke: var(--border); stroke-width: 1; }
.radial-chord { fill: none; stroke-width: 1.7; opacity: 0.32; transition: opacity 0.2s; }
.radial-node {
  fill: var(--accent-2);
  stroke: var(--bg);
  stroke-width: 2;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, filter 0.15s;
  transform-box: fill-box;
  transform-origin: center;
}
.radial-node.key { fill: var(--accent); filter: drop-shadow(0 0 6px rgba(109, 91, 208, 0.7)); }
.radial-node-group:hover .radial-node { transform: scale(1.3); }
.radial-number { fill: #ffffff; font-size: 8px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.radial-label { fill: var(--muted); font-size: 10.5px; pointer-events: none; }

.network-edge { stroke: var(--accent-2); transition: opacity 0.2s; }
.network-node { fill: var(--card-2); stroke-width: 2.5; cursor: pointer; transition: transform 0.15s, opacity 0.2s; transform-box: fill-box; transform-origin: center; }
.network-node-group:hover .network-node { transform: scale(1.08); }
.network-count { fill: var(--text); font-size: 9px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.network-label { fill: var(--text); font-size: 11px; pointer-events: none; }

.timeline .dim { opacity: 0.12; }

.modal-wide { width: min(780px, 100%); }
.character-detail-head { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.character-detail-head h3 { margin: 0; }
.cd-aliases { color: var(--accent-2); font-size: 0.82rem; margin: 0.35rem 0 1.1rem; }
.cd-loading { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); padding: 1rem 0; font-size: 0.88rem; }
.cd-error {
  color: #9c3f5e;
  background: rgba(192, 80, 106, 0.1);
  border: 1px solid rgba(192, 80, 106, 0.35);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font-size: 0.84rem;
}
.cd-section { margin-bottom: 1.1rem; }
.cd-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}
.cd-section p { margin: 0; font-size: 0.86rem; line-height: 1.55; color: var(--text); }
.cd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .cd-grid { grid-template-columns: 1fr; } }
.cd-relations { display: flex; flex-direction: column; gap: 0.5rem; }
.cd-relation {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-size: 0.82rem;
}
.cd-relation span { color: var(--muted); display: block; margin-top: 0.15rem; line-height: 1.4; }
.cd-moments { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.cd-moment {
  cursor: pointer;
  background: rgba(109, 91, 208, 0.12);
  border: 1px solid rgba(109, 91, 208, 0.4);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  font-size: 0.78rem;
  transition: background 0.15s;
}
.cd-moment:hover { background: rgba(109, 91, 208, 0.24); }

.mini-timeline { position: relative; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.8rem; }
.mini-timeline::before {
  content: "";
  position: absolute;
  left: 4px; top: 5px; bottom: 5px;
  width: 2px;
  background: var(--border);
}
.mini-item { position: relative; cursor: pointer; }
.mini-dot {
  position: absolute;
  left: -1.2rem; top: 0.3rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid var(--bg);
}
.mini-item.key .mini-dot { background: var(--accent); box-shadow: 0 0 8px rgba(109, 91, 208, 0.6); }
.mini-item strong { font-size: 0.85rem; }
.mini-item p { margin: 0.18rem 0; font-size: 0.79rem; color: var(--muted); line-height: 1.45; }
.mini-item small { color: var(--muted); font-size: 0.72rem; }
.mini-item:hover strong { color: var(--accent); }

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}
.legend-note { flex-basis: 100%; color: var(--muted); font-size: 0.79rem; line-height: 1.45; margin-bottom: 0.15rem; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.79rem;
  color: var(--text);
  cursor: default;
  font-family: inherit;
}
.legend-item.clickable { cursor: pointer; border-color: var(--border); }
.legend-item.clickable:hover { border-color: var(--accent); background: var(--accent-soft); }
.legend-item i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }

.radial-label, .network-label, .radial-number, .network-count {
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.radial-center-title { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.radial-center-sub { fill: var(--accent); opacity: 0.4; font-size: 26px; font-weight: 700; text-anchor: middle; }

.radial-guide { fill: none; stroke: var(--border); stroke-dasharray: 3 7; opacity: 0.8; }
.radial-chord:hover { opacity: 0.75; }
.network-edge:hover { stroke-opacity: 0.9; }
.radial-node-group, .network-node-group { cursor: pointer; }

.timeline-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.tl-node.flagged,
.radial-node.flagged {
  background: var(--danger);
  fill: var(--danger);
  box-shadow: 0 0 0 4px rgba(192, 80, 106, 0.18);
}
.tl-card.flagged { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(192, 80, 106, 0.18); }
.network-node.flagged { stroke: var(--danger) !important; filter: drop-shadow(0 0 6px rgba(192, 80, 106, 0.6)); }

.issues-panel {
  margin-top: 1rem;
  padding: 1.1rem 1.2rem;
  background: rgba(192, 80, 106, 0.06);
  border: 1px solid rgba(192, 80, 106, 0.3);
  border-radius: var(--radius);
}
.issues-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.issues-head strong { font-size: 0.95rem; color: #9c3f5e; }
.issues-summary { margin: 0 0 0.9rem; font-size: 0.85rem; color: var(--text); line-height: 1.5; }
.issues-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.issue-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.issue-item:hover { background: var(--card-2); }
.issue-item.active { border-color: var(--danger); background: rgba(192, 80, 106, 0.08); }
.issue-item.sev-alta { border-left-color: var(--danger); }
.issue-item.sev-media { border-left-color: var(--accent); }
.issue-item.sev-bassa { border-left-color: var(--accent-2); }
.issue-top { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.issue-top strong { font-size: 0.88rem; }
.issue-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.issue-tag.sev-alta { color: #9c3f5e; border-color: rgba(192, 80, 106, 0.45); background: rgba(192, 80, 106, 0.1); }
.issue-tag.sev-media { color: var(--accent); border-color: rgba(109, 91, 208, 0.45); background: rgba(109, 91, 208, 0.1); }
.issue-tag.sev-bassa { color: var(--accent-2); border-color: rgba(79, 143, 208, 0.45); background: rgba(79, 143, 208, 0.1); }
.issue-item p { margin: 0; font-size: 0.83rem; color: var(--muted); line-height: 1.5; }
.issue-events { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.issue-events span {
  font-size: 0.74rem;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  color: var(--text);
}
.issue-events span:hover { border-color: var(--accent); }

.radial-node-group.flagged .radial-node { fill: var(--danger); filter: drop-shadow(0 0 6px rgba(192, 80, 106, 0.6)); }
.network-node-group.flagged .network-node { stroke: var(--danger); filter: drop-shadow(0 0 6px rgba(192, 80, 106, 0.6)); }

.composer-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}
.composer-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.composer-tab:hover { color: var(--text); }
.composer-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.editor-toolbar {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.title-input {
  flex: 1;
  min-width: 200px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
}
.title-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 91, 208, 0.12); }
.editor-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.save-state { font-size: 0.75rem; color: var(--ok); min-width: 3rem; }

.text-editor {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--text);
}
.text-editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 91, 208, 0.12); }
.editor-status {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.projects-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
}
.project-item {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.project-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.project-item.active { border-color: var(--accent); background: var(--accent-soft); }
.project-new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem; min-height: 96px; background: transparent; border: 1px dashed var(--border); color: var(--muted); }
.project-new:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.project-new-plus { font-size: 1.6rem; line-height: 1; }
.project-new-label { font-size: 0.85rem; font-weight: 600; }
.project-item strong { display: block; font-size: 0.9rem; margin-bottom: 0.25rem; }
.project-item small { color: var(--muted); font-size: 0.74rem; }
.project-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 0.55rem; gap: 0.5rem; }
.project-delete {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}
.project-delete:hover { color: var(--danger); background: rgba(192, 80, 106, 0.1); }
.project-actions { display: flex; align-items: center; gap: 0.1rem; }
.project-duplicate:hover { color: var(--accent); background: rgba(109, 91, 208, 0.12); }

html { scroll-behavior: smooth; }

.topnav { display: flex; gap: 1.4rem; }
.topnav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; transition: color 0.15s; }
.topnav a:hover { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 0.8rem; }
.topbar-cta { padding: 0.5rem 1rem; }
@media (max-width: 900px) { .topnav { display: none; } }
@media (max-width: 640px) { .brand p { display: none; } .topbar-cta { display: none; } }

.landing-hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 3rem;
  align-items: center;
  padding: 3rem 0 1.5rem;
}
@media (max-width: 900px) { .landing-hero { grid-template-columns: 1fr; padding-top: 2rem; } }
.hero-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(109, 91, 208, 0.25);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.hero-title {
  font-size: clamp(2rem, 4.6vw, 3.3rem);
  line-height: 1.08;
  margin: 1.1rem 0;
  letter-spacing: -0.02em;
}
.grad { background: linear-gradient(100deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-lead { color: var(--muted); font-size: 1.05rem; line-height: 1.7; max-width: 38rem; }
.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin: 1.7rem 0 1.3rem; }
.btn-lg { padding: 0.8rem 1.5rem; font-size: 1rem; border-radius: 12px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.hero-points { list-style: none; display: flex; gap: 1.4rem; flex-wrap: wrap; padding: 0; margin: 0; color: var(--muted); font-size: 0.85rem; }

.mock-window { background: var(--card); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 1rem 1.1rem 1.2rem; }
.mock-bar { display: flex; gap: 0.35rem; margin-bottom: 1rem; }
.mock-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.mock-timeline { position: relative; height: 190px; }
.mock-line { position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: var(--border); }
.mock-node { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--accent-2); transform: translate(-50%, -50%); }
.mock-node.key { background: var(--accent); width: 18px; height: 18px; box-shadow: 0 0 0 5px rgba(109, 91, 208, 0.15); }
.mock-card {
  position: absolute;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
  color: var(--text);
  white-space: nowrap;
}
.mock-card.up { bottom: calc(50% + 15px); transform: translateX(-50%); }
.mock-card.down { top: calc(50% + 15px); transform: translateX(-50%); }
.mock-card.key { border-color: var(--accent); color: var(--accent); }
.mock-timeline > :nth-child(2), .mock-timeline > :nth-child(6) { left: 15%; }
.mock-timeline > :nth-child(3), .mock-timeline > :nth-child(7) { left: 39%; }
.mock-timeline > :nth-child(4), .mock-timeline > :nth-child(8) { left: 63%; }
.mock-timeline > :nth-child(5), .mock-timeline > :nth-child(9) { left: 87%; }
.mock-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.8rem; }
.mock-chip { font-size: 0.7rem; border-radius: 999px; padding: 0.22rem 0.6rem; border: 1px solid var(--border); }
.mock-chip.protagonist { color: var(--accent); border-color: rgba(109, 91, 208, 0.4); background: rgba(109, 91, 208, 0.1); }
.mock-chip.antagonist { color: #a83f58; border-color: rgba(192, 80, 106, 0.4); background: rgba(192, 80, 106, 0.1); }
.mock-chip.supporting { color: #2f7aa6; border-color: rgba(79, 143, 208, 0.4); background: rgba(79, 143, 208, 0.1); }

.features, .steps, .faq { padding: 3rem 0 1rem; }
.section-intro { text-align: center; max-width: 46rem; margin: 0 auto 2.4rem; }
.eyebrow { color: var(--accent); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; }
.section-intro h3 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0.6rem 0 0.5rem; }
.section-intro p { color: var(--muted); line-height: 1.6; margin: 0; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
@media (max-width: 900px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .feature-grid { grid-template-columns: 1fr; } }
.feature {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  transition: transform 0.18s, border-color 0.18s;
}
.feature:hover { transform: translateY(-4px); border-color: var(--accent); }
.feature-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.9rem;
}
.feature h4 { margin: 0 0 0.4rem; font-size: 1.02rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }

.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
@media (max-width: 800px) { .steps-grid { grid-template-columns: 1fr; } }
.step { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700;
  margin-bottom: 0.8rem;
}
.step h4 { margin: 0 0 0.35rem; }
.step p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }

.faq { max-width: 52rem; margin: 0 auto; }
.faq-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1.1rem; margin-bottom: 0.7rem; }
.faq-item summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; line-height: 1; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.88rem; line-height: 1.6; }

.cta-band {
  text-align: center;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: var(--radius);
  padding: 2.6rem 1.5rem;
  margin: 2rem 0 0;
  box-shadow: var(--shadow);
}
.cta-band h3 { margin: 0 0 0.5rem; font-size: clamp(1.3rem, 3vw, 1.9rem); }
.cta-band p { margin: 0 0 1.3rem; opacity: 0.92; }
.cta-band .btn-primary { background: #fff; color: var(--accent); }

.tool-anchor { scroll-margin-top: 90px; }
#funzioni, #come-funziona, #faq, #app { scroll-margin-top: 90px; }

.footer { border-top: 1px solid var(--border); background: var(--bg-soft); padding: 2.4rem clamp(1rem, 4vw, 3rem) 1.4rem; text-align: left; }
.footer-inner { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 2rem; }
@media (max-width: 700px) { .footer-inner { grid-template-columns: 1fr; } }
.footer-brand { display: flex; gap: 0.8rem; align-items: flex-start; }
.footer-brand strong { font-size: 1rem; }
.footer-brand p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.85rem; }
.footer-col { display: flex; flex-direction: column; gap: 0.45rem; }
.footer-col strong { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.2rem; }
.footer-col a, .footer-col span { color: var(--text); text-decoration: none; font-size: 0.88rem; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { max-width: 1180px; margin: 2rem auto 0; padding-top: 1.2rem; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: 0.78rem; }

/* ===== Landing: hero full-bleed, sfondo e parallax ===== */
body {
  background:
    radial-gradient(1000px 520px at 85% -5%, rgba(79, 143, 208, 0.10), transparent),
    radial-gradient(820px 460px at 0% 8%, rgba(109, 91, 208, 0.10), transparent),
    var(--bg);
  background-attachment: fixed;
}

.landing-hero {
  position: relative;
  overflow: hidden;
  display: block;
  grid-template-columns: none;
  gap: 0;
  padding: clamp(3.5rem, 7vw, 6rem) 0 clamp(4rem, 8vw, 6.5rem);
  color: #fff;
  background:
    radial-gradient(1200px 620px at 12% -15%, rgba(124, 92, 246, 0.62), transparent 62%),
    radial-gradient(1000px 560px at 106% 0%, rgba(52, 130, 200, 0.5), transparent 58%),
    radial-gradient(900px 620px at 50% 135%, rgba(11, 9, 30, 0.85), transparent 72%),
    linear-gradient(160deg, #160f31 0%, #241a4f 46%, #13102c 100%);
}
.landing-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.75) 1px, transparent 1.5px);
  background-size: 48px 48px;
  opacity: 0.16;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 88%);
  mask-image: linear-gradient(to bottom, #000, transparent 88%);
  pointer-events: none;
}
.hero-orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.45; pointer-events: none; will-change: transform; }
.hero-orb.a { width: 360px; height: 360px; background: #7c5cf6; top: -90px; left: -70px; }
.hero-orb.b { width: 320px; height: 320px; background: #3f86c0; bottom: -110px; right: 4%; }
.hero-orb.c { width: 260px; height: 260px; background: #b06fd0; top: 28%; right: 24%; opacity: 0.26; }

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 3rem);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 3rem;
  align-items: center;
}
@media (max-width: 900px) { .hero-inner { grid-template-columns: 1fr; gap: 2.2rem; } }

.hero-badge {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(6px);
}
.hero-title { color: #fff; }
.hero-lead { color: rgba(255, 255, 255, 0.8); }
.hero-points { color: rgba(255, 255, 255, 0.72); }
.hero-actions .btn-primary { background: #fff; color: #4a3aa8; }
.hero-actions .btn-primary:hover { filter: none; transform: translateY(-1px); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3); }
.hero-actions .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.hero-actions .btn-ghost:hover { color: #fff; border-color: #fff; background: rgba(255, 255, 255, 0.08); }

.hero-visual { will-change: transform; }
.landing-hero .mock-window {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 30px 70px rgba(5, 3, 20, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transform: perspective(900px) rotateY(-8deg) rotateX(3deg);
  animation: float 7s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: perspective(900px) rotateY(-8deg) rotateX(3deg) translateY(0); }
  50% { transform: perspective(900px) rotateY(-8deg) rotateX(3deg) translateY(-14px); }
}

.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .landing-hero .mock-window { animation: none; transform: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .hero-orb { display: none; }
}

.landing-hero .grad { background: linear-gradient(100deg, #b9a4ff, #7fc0ff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-title { text-shadow: 0 2px 30px rgba(10, 6, 30, 0.35); }

.brand.clickable { cursor: pointer; }
.brand.clickable:hover h1 { color: var(--accent); }
.app-main { margin-top: 1.6rem; }
.app-main .error-banner { margin-bottom: 0.2rem; }
.landing-cta-wrap { margin: 1rem 0 0; }

.app-home-head { text-align: center; max-width: 42rem; margin: 0 auto 2rem; }
.app-home-head h2 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 0 0 0.5rem; }
.app-home-head p { color: var(--muted); margin: 0; }
.app-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-bottom: 2rem; }
@media (max-width: 720px) { .app-choice-grid { grid-template-columns: 1fr; } }
.app-choice {
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  box-shadow: var(--shadow);
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.app-choice:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 16px 40px rgba(60, 60, 110, 0.14); }
.app-choice-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}
.app-choice h3 { margin: 0.2rem 0 0.3rem; font-size: 1.15rem; }
.app-choice p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.app-choice-cta { color: var(--accent); font-weight: 600; font-size: 0.85rem; margin-top: 0.6rem; }

.app-pane { max-width: 840px; margin: 0 auto; }
.pane-head { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1rem; }
.pane-head h3 { margin: 0; font-size: 1.15rem; }
.pane-context { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0.9rem; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--card-2); font-size: 0.85rem; }
.pane-context-label { color: var(--muted); text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.06em; }
.pane-context strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-context-warning { border-color: var(--danger); background: rgba(192, 80, 106, 0.08); justify-content: space-between; }
.pane-back {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 10px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}
.pane-back:hover { color: var(--text); border-color: var(--accent); }

html { scroll-padding-top: 84px; }

.feature-highlight {
  position: relative;
  border-color: rgba(109, 91, 208, 0.5);
  background: linear-gradient(180deg, rgba(109, 91, 208, 0.07), var(--card));
  box-shadow: 0 12px 32px rgba(109, 91, 208, 0.14);
}
.feature-highlight:hover { border-color: var(--accent); }
.feature-badge {
  position: absolute;
  top: -10px;
  right: 14px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
}

.highlight-band {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 2.4rem;
  align-items: center;
  margin: 2.5rem 0 1rem;
  padding: clamp(1.6rem, 3vw, 2.4rem);
  border: 1px solid rgba(109, 91, 208, 0.35);
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(109, 91, 208, 0.1), rgba(79, 143, 208, 0.08));
}
@media (max-width: 860px) { .highlight-band { grid-template-columns: 1fr; gap: 1.6rem; } }
.highlight-copy h3 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 0.5rem 0 0.7rem; }
.highlight-copy p { color: var(--text); line-height: 1.65; margin: 0 0 1rem; }
.highlight-list { list-style: none; padding: 0; margin: 0 0 1.4rem; display: flex; flex-direction: column; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.highlight-list li { padding-left: 1.4rem; position: relative; }
.highlight-list li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.highlight-demo { display: flex; flex-direction: column; gap: 0.7rem; }
.demo-issue {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  box-shadow: var(--shadow);
}
.demo-issue strong { font-size: 0.85rem; }
.demo-issue p { margin: 0.2rem 0 0; font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.demo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-top: 0.35rem; flex: none; }
.demo-issue.sev-alta { border-left-color: var(--danger); }
.demo-issue.sev-alta .demo-dot { background: var(--danger); }
.demo-issue.sev-media { border-left-color: var(--accent); }
.demo-issue.sev-media .demo-dot { background: var(--accent); }
.demo-issue.sev-bassa { border-left-color: var(--accent-2); }
.demo-issue.sev-bassa .demo-dot { background: var(--accent-2); }

.check-wrap { display: inline-flex; align-items: center; gap: 0.5rem; }
.check-badge {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}
.btn-highlight {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  box-shadow: 0 8px 20px rgba(109, 91, 208, 0.28);
}
.btn-highlight:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-highlight:disabled { filter: none; }

.auth-area { display: flex; align-items: center; gap: 0.5rem; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.3rem 0.25rem 0.35rem;
}
.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  flex: none;
}
.user-name { font-size: 0.82rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-family: inherit;
}
.user-logout:hover { color: var(--danger); }
@media (max-width: 640px) { .user-name { display: none; } }

.auth-box { width: min(420px, 100%); }
.auth-tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; }
.auth-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
  margin-bottom: -1px;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.auth-field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.auth-field span { font-size: 0.78rem; color: var(--muted); }
.auth-field input {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
}
.auth-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 91, 208, 0.12); }
.auth-error {
  color: #9c3f5e;
  background: rgba(192, 80, 106, 0.1);
  border: 1px solid rgba(192, 80, 106, 0.35);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  margin-bottom: 0.9rem;
}
.auth-notice {
  color: #2f5d8a;
  background: rgba(64, 128, 192, 0.1);
  border: 1px solid rgba(64, 128, 192, 0.35);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  margin-bottom: 0.9rem;
}
.auth-submit { width: 100%; }
.auth-note { color: var(--muted); font-size: 0.78rem; line-height: 1.5; margin: 1rem 0 0; }

/* ===== Writer / focus mode ===== */
body.writer-mode .topbar,
body.writer-mode .footer { display: none; }
body.writer-mode { background: #fbfaf7; }
body.writer-mode .app-main { width: 100%; max-width: none; margin: 0; }
body.writer-mode .app-main .error-banner { max-width: 900px; margin: 0.8rem auto 0; }

.app-pane.writer {
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.writer-bar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem clamp(1rem, 3vw, 2.2rem);
  background: rgba(251, 250, 247, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.writer-title {
  flex: 1;
  min-width: 160px;
  border: none;
  border-bottom: 1px dashed transparent;
  background: transparent;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.3rem 0;
}
.writer-title:focus { outline: none; border-bottom-color: var(--accent); }
.writer-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.writer-toolbar {
  position: sticky;
  top: 54px;
  z-index: 11;
  display: flex;
  gap: 0.15rem;
  align-items: center;
  padding: 0.5rem clamp(1rem, 3vw, 2.2rem);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.writer-toolbar button {
  min-width: 34px;
  height: 32px;
  padding: 0 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}
.writer-toolbar button:hover { background: var(--card-2); border-color: var(--border); }
.file-tabs { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; padding: 0.4rem clamp(1rem, 3vw, 2.2rem); background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.file-tabs[hidden] { display: none; }
.file-tab { display: inline-flex; align-items: center; gap: 0.35rem; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 999px; padding: 0.28rem 0.6rem; font: 600 0.76rem inherit; cursor: pointer; }
.file-tab:hover { border-color: var(--accent); }
.file-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.file-tab-close { color: var(--muted); font-size: 0.9rem; line-height: 1; padding: 0 0.1rem; border-radius: 999px; }
.file-tab-close:hover { color: var(--danger); }
.file-tab-stale { color: var(--danger); font-style: normal; }
.file-tab-add { border: 1px dashed var(--border); background: transparent; color: var(--muted); border-radius: 999px; padding: 0.28rem 0.6rem; font: 600 0.8rem inherit; cursor: pointer; }
.file-tab-add:hover { border-color: var(--accent); color: var(--accent); }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 0.35rem; }
@media (max-width: 720px) { .writer-toolbar { position: static; } }

.writer-stage { flex: 1; display: flex; justify-content: center; padding: clamp(1.4rem, 4vh, 3rem) clamp(1rem, 4vw, 2rem) 1.5rem; }
.writer-canvas {
  width: min(820px, 100%);
  min-height: calc(100vh - 250px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(60, 60, 110, 0.08);
  padding: clamp(1.6rem, 5vw, 3.2rem);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 1.12rem;
  line-height: var(--editor-line-height, 1.9);
  text-align: var(--editor-text-align, left);
  color: var(--text);
  outline: none;
}
.writer-canvas:focus-visible { box-shadow: 0 20px 50px rgba(60, 60, 110, 0.13); }
.writer-canvas:empty::before { content: attr(data-placeholder); color: var(--muted); }
.writer-canvas p { margin: 0 0 1.05rem; text-align: var(--editor-text-align, left); }
.writer-canvas h1 { font-size: 1.9rem; margin: 1.4rem 0 0.8rem; }
.writer-canvas h2 { font-size: 1.45rem; margin: 1.2rem 0 0.6rem; }
.writer-canvas blockquote {
  border-left: 3px solid var(--accent);
  margin: 1rem 0;
  padding: 0.2rem 1.1rem;
  color: var(--muted);
  font-style: italic;
}
.writer-canvas ul, .writer-canvas ol { padding-left: 1.5rem; margin: 0 0 1rem; }
.writer-canvas hr { border: none; border-top: 1px solid var(--border); margin: 1.6rem 0; }

.writer .editor-status {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 0.5rem clamp(1rem, 3vw, 2.2rem) 1.2rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

body.writer-mode .progress-card,
body.writer-mode #results { width: min(1000px, 94vw); margin: 1.2rem auto; }
body.writer-mode #results { display: block; }

.confirm-box { width: min(440px, 100%); }
.confirm-box h3 { margin: 0 0 0.6rem; font-size: 1.15rem; }
.confirm-box p { margin: 0 0 1.4rem; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.choice-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.choice-actions .btn { width: 100%; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }

#results, #progressCard { scroll-margin-top: 110px; }
body.writer-mode #results, body.writer-mode #progressCard { scroll-margin-top: 130px; }

/* ===== Gallery / generi ===== */
.gallery { padding: 3rem 0 1.5rem; }
.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
@media (max-width: 860px) { .gallery-grid { grid-template-columns: 1fr; } }
.gallery-item {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s, border-color 0.18s;
}
.gallery-item:hover { transform: translateY(-5px); border-color: var(--accent); }
.gallery-item img { display: block; width: 100%; height: 210px; object-fit: cover; background: #1b1738; }
.gallery-item figcaption { padding: 0.95rem 1.05rem 1.15rem; }
.gallery-item figcaption strong { display: block; font-size: 0.98rem; margin-bottom: 0.15rem; }
.gallery-item figcaption span { color: var(--muted); font-size: 0.84rem; }

/* ===== Workspace: editor + analisi affiancata ===== */
.workspace { display: block; }

.analysis-side {
  display: none;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
  min-width: 0;
}
body.split .analysis-side { display: flex; }
.analysis-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(0.8rem, 2vw, 1.4rem);
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 5;
}
.analysis-side-head strong { font-size: 0.9rem; letter-spacing: 0.02em; }
.analysis-side-body { flex: 1; overflow-y: auto; padding: 1rem clamp(0.8rem, 2vw, 1.4rem) 2rem; }

body.split .workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  height: 100vh;
}
body.split #editorPane { min-height: 0; height: 100vh; overflow-y: auto; }
body.split .analysis-side { height: 100vh; overflow: hidden; }

body.split .analysis-side-body .card { padding: 1rem; border-radius: 12px; box-shadow: none; }
body.split .analysis-side-body .hero { flex-direction: column; gap: 1rem; }
body.split .analysis-side-body .stats { flex-wrap: wrap; }
body.split .analysis-side-body .grid-two { grid-template-columns: 1fr; }
body.split .analysis-side-body .section-head { margin-bottom: 0.8rem; }
body.split .analysis-side-body .timeline { min-width: 0; }
body.split .analysis-side-body #timelineViewport { overflow-x: auto; }

@media (max-width: 900px) {
  body.split .workspace { grid-template-columns: 1fr; height: auto; }
  body.split #editorPane { height: auto; }
  body.split .analysis-side { height: auto; max-height: none; }
  body.split .analysis-side-body { overflow: visible; }
}

/* ===== Contenimento pannello analisi (split) ===== */
.analysis-side { overflow: hidden; min-width: 0; }
.analysis-side-body { overflow-y: auto; overflow-x: hidden; min-width: 0; }
.analysis-side-body #results,
.analysis-side-body .card,
.analysis-side-body .feature,
.analysis-side-body section { max-width: 100%; min-width: 0; box-sizing: border-box; }

body.split .analysis-side-body .section-head,
body.split .analysis-side-body .timeline-subhead,
body.split .analysis-side-body .timeline-tools,
body.split .analysis-side-body .timeline-actions,
body.split .analysis-side-body .character-head { flex-wrap: wrap; }
body.split .analysis-side-body .timeline-actions,
body.split .analysis-side-body .timeline-tools { gap: 0.5rem; }
body.split .analysis-side-body .tl-card { width: 150px; }
body.split .analysis-side-body .timeline { height: 300px; }
body.split .analysis-side-body .key-events { padding-left: 1rem; }
body.split .analysis-side-body .modal-meta { grid-template-columns: 1fr; }

.analysis-side-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Analisi a tutto schermo (nasconde l'editor) */
body.analysis-full .workspace { display: block; height: 100vh; }
body.analysis-full #editorPane { display: none; }
body.analysis-full .analysis-side {
  height: 100vh;
  border-left: none;
}
body.analysis-full .analysis-side-body { padding: 1.2rem clamp(1rem, 4vw, 3rem) 3rem; }
body.analysis-full .analysis-side-body .card { box-shadow: var(--shadow); }
body.analysis-full .analysis-side-body #results { width: min(1200px, 100%); margin: 0 auto; }

/* ===== Pannello utente ===== */
.user-chip { cursor: pointer; font-family: inherit; }
.profile-box { width: min(720px, 100%); }
.profile-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem; font-weight: 700; flex: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}
.profile-head-info { flex: 1; min-width: 0; }
.profile-head-info h3 { margin: 0; font-size: 1.15rem; }
.profile-head-info p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; word-break: break-all; }
.profile-head-info small { color: var(--muted); font-size: 0.75rem; }
.profile-tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; flex-wrap: wrap; }
.profile-tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 0.5rem 0.85rem; cursor: pointer;
  font-family: inherit; font-size: 0.9rem; margin-bottom: -1px;
}
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.avatar-colors { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.avatar-color { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.avatar-color.selected { border-color: var(--text); box-shadow: 0 0 0 3px rgba(109, 91, 208, 0.2); }
.profile-files-stats { color: var(--muted); font-size: 0.84rem; margin: 0 0 1rem; }
.danger-zone { border: 1px solid rgba(192, 80, 106, 0.4); background: rgba(192, 80, 106, 0.06); border-radius: 12px; padding: 1rem 1.1rem; }
.danger-zone strong { color: #a83f58; display: block; margin-bottom: 0.4rem; }
.danger-zone p { color: var(--text); font-size: 0.86rem; line-height: 1.55; margin: 0 0 1rem; }
.auth-ok { color: #2f7a5a; background: rgba(79, 154, 135, 0.1); border: 1px solid rgba(79, 154, 135, 0.35); border-radius: 10px; padding: 0.55rem 0.75rem; font-size: 0.82rem; margin-bottom: 0.9rem; }

/* ===== Zoom editor ===== */
.writer-stage { zoom: var(--editor-zoom, 1); justify-content: safe center; }
body.writer-mode #editorPane { height: 100vh; overflow: auto; }
body.split #editorPane { min-height: 0; height: 100vh; overflow: auto; }
.writer-canvas h1 { font-size: 1.7em; margin: 1.1em 0 0.6em; }
.writer-canvas h2 { font-size: 1.3em; margin: 1em 0 0.5em; }
.writer-canvas blockquote { font-size: 1em; }

.zoom-controls { display: inline-flex; align-items: center; gap: 0.25rem; margin-left: auto; }
.zoom-controls .zoom-level { font-size: 0.78rem; color: var(--muted); min-width: 42px; text-align: center; }
.zoom-controls button { min-width: 32px; }

/* ===== Zoom pagina + dimensione testo (separati) ===== */
.writer-canvas { font-size: calc(1.12rem * var(--editor-font-scale, 1)); }
.editor-view-controls { display: inline-flex; align-items: center; gap: 0.25rem; margin-left: auto; flex-wrap: wrap; }
.vc-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0.15rem; }

.section-hint { margin: -0.4rem 0 1rem; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }

.cd-connections { counter-reset: conn; list-style: none; margin: 0; padding: 0 0 0 0.2rem; display: flex; flex-direction: column; gap: 0.55rem; }
.cd-connections li {
  position: relative;
  padding-left: 1.9rem;
  padding-bottom: 0.5rem;
  border-left: 1px solid var(--border);
  margin-left: 0.45rem;
  min-height: 1.4rem;
}
.cd-connections li:last-child { border-left-color: transparent; padding-bottom: 0; }
.cd-connections li::before {
  counter-increment: conn;
  content: counter(conn);
  position: absolute;
  left: -0.72rem;
  top: 0.05rem;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cd-connections strong { font-size: 0.84rem; color: var(--accent); }
.cd-connections p { margin: 0.1rem 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.cd-connection-event { display: none; }

/* ===== Correzione (refusi / grammatica) ===== */
.correction-box { width: min(760px, 100%); }
.correction-note { color: var(--muted); font-size: 0.82rem; margin: 0 0 0.8rem; line-height: 1.5; }
.correction-body {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  max-height: 50vh;
  overflow: auto;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text);
  margin: 0 0 1rem;
}
.correction-body p { margin: 0 0 0.8rem; }
.correction-body h1 { font-size: 1.35rem; margin: 0.6rem 0 0.5rem; }
.correction-body h2 { font-size: 1.15rem; margin: 0.6rem 0 0.4rem; }
.correction-body ul, .correction-body ol { padding-left: 1.4rem; margin: 0 0 0.8rem; }

.corr-hi {
  background: rgba(192, 80, 106, 0.16);
  color: #a83f58;
  border-radius: 3px;
  padding: 0 0.08rem;
  box-shadow: inset 0 -1px 0 rgba(192, 80, 106, 0.45);
}

/* ===== Analisi editoriale ===== */
.editorial-btn { margin-top: 1rem; }
.editorial-box { width: min(880px, 100%); }
.editorial-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.editorial-head h3 { margin: .35rem 0 0; }
.editorial-badge { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); border: 1px solid rgba(109, 91, 208, .35); background: var(--accent-soft); border-radius: 999px; padding: .22rem .65rem; white-space: nowrap; }

.er-section { margin-bottom: 1.1rem; }
.er-section > h4 { margin: 0 0 .5rem; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.er-summary { font-size: .92rem; line-height: 1.6; margin: 0; }
.er-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 700px) { .er-grid { grid-template-columns: 1fr; } }
.er-card { background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: .95rem 1.05rem; }
.er-card h4 { margin: 0 0 .5rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.er-card p { margin: .25rem 0 0; font-size: .82rem; color: var(--muted); line-height: 1.5; }

.er-row { display: flex; align-items: center; gap: .7rem; margin: .45rem 0; }
.er-label { min-width: 128px; font-size: .84rem; }
.er-bar { flex: 1; height: 8px; background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.er-fill { height: 100%; background: var(--accent); }
.er-fill.warn { background: var(--danger); }
.er-value { width: 2.4rem; text-align: right; font-weight: 700; font-size: .85rem; }

.er-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.er-chips span { font-size: .75rem; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: .2rem .6rem; }
.er-caution { border-color: rgba(192, 80, 106, 0.4); background: rgba(192, 80, 106, 0.06); }
.er-caution h4 { color: #a83f58; }
.er-hours strong { font-size: 1.9rem; color: var(--accent); line-height: 1; }
.er-hours span { color: var(--muted); font-size: .82rem; }
.er-lists { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 700px) { .er-lists { grid-template-columns: 1fr; } }
.er-lists ul { margin: 0; padding-left: 1.1rem; }
.er-lists li { font-size: .84rem; line-height: 1.5; margin-bottom: .3rem; }
.er-lists .er-strengths h4 { color: var(--ok); }
.er-lists .er-risks h4 { color: var(--danger); }

/* ===== Ricerca autore ===== */
.author-box { width: min(820px, 100%); }
.author-search { display: flex; gap: 0.5rem; margin: 0.6rem 0 0.3rem; flex-wrap: wrap; }
.author-search input { flex: 1; min-width: 200px; background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.8rem; font-family: inherit; font-size: 0.92rem; color: var(--text); }
.author-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 91, 208, 0.12); }
.author-profile { margin-top: 0.9rem; }
.author-cat { margin-bottom: 0.8rem; }
.author-cat h4 { margin: 0 0 0.35rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.author-cat a { display: block; font-size: 0.85rem; color: var(--accent-2); text-decoration: none; padding: 0.18rem 0; word-break: break-word; }
.author-cat a:hover { text-decoration: underline; }
.author-sources { margin-top: 0.8rem; border-top: 1px solid var(--border); padding-top: 0.7rem; }
.author-sources h4 { margin: 0 0 0.4rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.author-sources a { display: block; font-size: 0.78rem; color: var(--muted); text-decoration: none; padding: 0.12rem 0; word-break: break-word; }
.author-sources a:hover { color: var(--text); }

/* ===== Editoriale esteso ===== */
.er-verdict {
  display: inline-block;
  font-family: var(--lp-mono, ui-monospace);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(109, 91, 208, 0.3);
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  margin-bottom: 0.6rem;
}
.er-pitch {
  margin: 0.5rem 0 0;
  font-style: italic;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.55;
}
.er-recommendations ol { margin: 0; padding-left: 1.2rem; }
.er-recommendations li { font-size: 0.85rem; line-height: 1.55; margin-bottom: 0.35rem; }
.er-detail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.er-detail-list li { font-size: 0.85rem; line-height: 1.5; }
.er-detail-list strong { display: block; font-size: 0.86rem; }
.er-detail-list span { color: var(--muted); }
.er-section.er-strengths h4 { color: var(--ok); }
.er-section.er-risks h4 { color: var(--danger); }
.er-mini-list { margin: 0.6rem 0 0; }
.er-mini-list h4 { margin: 0 0 0.3rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.er-mini-list ul, .er-mini-list ol { margin: 0; padding-left: 1.1rem; }
.er-mini-list li { font-size: 0.82rem; line-height: 1.5; margin-bottom: 0.25rem; }

/* ===== Ricerca autore: tab + ISBN ===== */
.author-tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin: 0.6rem 0 0.8rem; }
.author-tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 0.45rem 0.9rem; cursor: pointer; font-family: inherit; font-size: 0.88rem; margin-bottom: -1px; }
.author-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.author-isbn { color: var(--muted); font-size: 0.76rem; }
.isbn-result { display: flex; gap: 1rem; margin-top: 0.6rem; }
.isbn-cover { width: 96px; height: auto; border-radius: 8px; border: 1px solid var(--border); flex: none; }
.isbn-info { flex: 1; min-width: 0; }
.isbn-info h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.isbn-info p { margin: 0.15rem 0; color: var(--muted); font-size: 0.85rem; }
.isbn-meta { color: var(--text) !important; }
.isbn-author { font-size: 0.75rem; background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.22rem 0.6rem; cursor: pointer; color: var(--accent); font-family: inherit; }
.isbn-author:hover { border-color: var(--accent); }
.isbn-links { display: flex; gap: 0.8rem; margin-top: 0.6rem; }
.isbn-links a { font-size: 0.82rem; color: var(--accent-2); text-decoration: none; }
.isbn-links a:hover { text-decoration: underline; }

/* ===== Coerenza layout analisi editoriale ===== */
#editorialContent { display: flex; flex-direction: column; gap: 0.9rem; }
#editorialContent > * { margin: 0; }
#editorialContent .er-section { margin-bottom: 0; }
#editorialContent .er-grid { gap: 0.9rem; }
#editorialContent .er-card { display: flex; flex-direction: column; }
#editorialContent .er-card > h4:first-child { margin-top: 0; }
.er-summary-card { display: flex; flex-direction: column; gap: 0.4rem; }
.er-strengths h4 { color: var(--ok); }
.er-risks h4 { color: var(--danger); }

/* ===== Elenco titoli per nome ===== */
.isbn-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }
.isbn-row { display: flex; gap: 0.85rem; align-items: flex-start; background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.8rem; }
.isbn-thumb { width: 44px; height: auto; border-radius: 4px; flex: none; border: 1px solid var(--border); }
.isbn-row-info { flex: 1; min-width: 0; }
.isbn-row-info a, .isbn-row-info strong { font-size: 0.9rem; color: var(--text); text-decoration: none; display: block; }
.isbn-row-info a:hover { color: var(--accent); text-decoration: underline; }
.isbn-row-info p { margin: 0.15rem 0; font-size: 0.8rem; color: var(--muted); }
.isbn-code { font-size: 0.74rem; color: var(--accent); }

/* ===== Landing: strumenti editor ===== */
#landingView .lp-lead a { color: var(--accent); }
#landingView .lp-editor-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
#landingView .lp-editor-list li { position: relative; padding-left: 1.3rem; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
#landingView .lp-editor-list li::before { content: ""; position: absolute; left: 0; top: 0.55rem; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
#landingView .lp-editor-list strong { color: var(--text); }
#landingView .lp-editor-report { align-self: start; }
#landingView .lp-editor-report .er-hours { margin-top: 0.7rem; }

/* ===== Policy / privacy ===== */
.policy-box { width: min(760px, 100%); }
.policy-body { font-size: 0.88rem; line-height: 1.6; color: var(--text); }
.policy-body h4 { margin: 1rem 0 0.35rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); }
.policy-body p { margin: 0 0 0.6rem; color: var(--muted); }
.policy-body strong { color: var(--text); }
.policy-list { margin: 0.3rem 0 0.6rem; padding-left: 1.1rem; }
.policy-list li { color: var(--muted); font-size: 0.86rem; line-height: 1.5; margin-bottom: 0.3rem; }
.policy-list strong { color: var(--text); }
.policy-body code { background: var(--card-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 0.3rem; font-size: 0.8rem; }

/* ===== Risultati a schermo intero (analisi file) ===== */
.results-fs-exit {
  display: none;
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 90;
  box-shadow: 0 8px 24px rgba(60, 60, 110, 0.25);
}
body.results-fullscreen #results {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: auto;
  background: var(--bg);
  margin: 0;
  width: auto;
  padding: 1.6rem clamp(1rem, 4vw, 3rem) 3.5rem;
}
body.results-fullscreen #results > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
body.results-fullscreen .results-fs-exit { display: inline-flex; }

/* ===== Toolbar risultati più visibile ===== */
.results-tools { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 1.1rem; }
.btn-soft {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}
.btn-soft:hover { border-color: var(--accent); color: var(--accent); }

.er-sublabel { display: block; margin: 0.6rem 0 0.2rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }

/* ===== Language switch ===== */
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.lang-switch button { background: transparent; border: none; color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; padding: 0.3rem 0.6rem; cursor: pointer; font-family: inherit; }
.lang-switch button.active { background: var(--accent); color: #fff; }
body:not(.in-app) .lang-switch { border-color: var(--lp-border, #e4e8f2); }

/* ===== Piani e consumi ===== */
.plans-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; margin-top: 0.9rem; }
@media (max-width: 760px) { .plans-grid { grid-template-columns: 1fr; } }
.plan-card { background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; display: flex; flex-direction: column; }
.plan-card h4 { margin: 0 0 0.2rem; font-size: 0.95rem; }
.plan-price { color: var(--accent); font-weight: 700; margin: 0 0 0.6rem; }
.plan-card ul { margin: 0 0 0.9rem; padding-left: 1.1rem; flex: 1; }
.plan-card li { font-size: 0.8rem; color: var(--muted); line-height: 1.45; margin-bottom: 0.25rem; }
.plan-card .btn { margin-top: auto; }
.usage-row .er-label { min-width: 150px; }
.plan-current { font-size: 0.95rem; font-weight: 600; margin: 0.2rem 0 0.9rem; }
.paywall-box { width: min(820px, 100%); }
.paywall-box .plans-grid { grid-template-columns: repeat(2, 1fr); }

/* ===== Gate di registrazione sui risultati ===== */
#results { position: relative; }
.results-gate {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(2rem, 8vh, 6rem);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(7px);
  border-radius: var(--radius);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.results-gate-box {
  width: min(460px, 90%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.6rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(60, 60, 110, 0.18);
}
.results-gate-icon { font-size: 1.8rem; }
.results-gate-box h3 { margin: 0.5rem 0 0.6rem; font-size: 1.2rem; }
.results-gate-box p { margin: 0 0 1.2rem; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.results-gate-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
#results.gated > *:not(.results-gate) {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

.results-gate-box { width: min(720px, 94%); }
.results-gate .plans-grid { grid-template-columns: repeat(2, 1fr); margin-top: 0.4rem; margin-bottom: 1rem; }
@media (max-width: 620px) { .results-gate .plans-grid { grid-template-columns: 1fr; } }

.results-gate .plans-grid { grid-template-columns: 1fr; max-width: 380px; margin-left: auto; margin-right: auto; }

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(14px);
  background: #2f7d5b;
  color: #fff;
  padding: 0.7rem 1.15rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: min(560px, 92vw);
  text-align: center;
  box-shadow: 0 14px 34px rgba(20, 20, 40, 0.28);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100000;
}
.app-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast.error { background: #9c3f5e; }

.paypal-checkout { margin-top: auto; width: 100%; }
.paypal-checkout .btn { width: 100%; }

.user-credits {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(109, 91, 208, 0.14);
  color: #6d5bd0;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  white-space: nowrap;
}
.credits-stats {
  margin-top: 1rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(80, 80, 120, 0.12);
}

.credit-costs {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 1rem;
}
.credit-cost-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.86rem;
}
.credit-cost-label { color: var(--muted, #6b6b80); }
.credit-cost-value { font-weight: 600; text-align: right; }

.file-card.has-file {
  padding: 0.75rem 1rem;
}
.file-card.has-file .dropzone { display: none; }
.file-card.has-file .hint { display: none; }
.file-pick {
  align-self: flex-start;
  margin-top: 0.5rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, #6d5bd0);
  font-size: 0.82rem;
  cursor: pointer;
}
.file-pick:hover { text-decoration: underline; }

/* ===== Apple touch ===== */
h1, h2, h3, h4 { letter-spacing: -0.02em; }
.card { background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); }
.btn {
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform .18s cubic-bezier(.2,.7,.3,1), background .18s, box-shadow .18s, border-color .18s, filter .18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, .08); }
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--accent); box-shadow: 0 6px 16px rgba(109, 91, 208, .25); }
.btn-primary:hover { filter: none; background: #6150c4; }
.btn-highlight { border-radius: 12px; box-shadow: 0 6px 16px rgba(79, 143, 208, .25); }
.btn-ghost { background: rgba(0, 0, 0, .03); border-color: transparent; color: var(--text); }
.btn-ghost:hover { background: rgba(0, 0, 0, .06); border-color: transparent; color: var(--text); }
input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select, textarea {
  border-radius: 12px !important;
  border: 1px solid var(--border);
  background: var(--card);
  transition: border-color .18s, box-shadow .18s;
}
input:not([type="range"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.user-chip, .model-badge, .badge, .chip, .tag, .pill, .lang-switch { border-radius: 980px; }
.modal { background: rgba(0, 0, 0, .30); -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px); }
.modal-box { border-radius: 20px; box-shadow: 0 28px 80px rgba(0, 0, 0, .24); }
.dropzone { background: rgba(0, 0, 0, .015); }
* { scrollbar-width: thin; scrollbar-color: rgba(0, 0, 0, .22) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .18); border-radius: 980px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Pronta stampa */
.prepress-box { width: min(920px, 96%); }
.prepress-frame {
  width: 100%;
  height: 62vh;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .02);
}

.prepress-loading { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; padding: 1.6rem 0 1.2rem; }
.prepress-spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: prepressSpin 0.9s linear infinite; }
@keyframes prepressSpin { to { transform: rotate(360deg); } }
.prepress-loading-msg { margin: 0; font-weight: 600; text-align: center; }
.prepress-loading .progress-track { width: 100%; max-width: 440px; }
@media (prefers-reduced-motion: reduce) { .prepress-spinner { animation-duration: 2s; } }

/* Controlli vista editor + opzioni pronta stampa */
.vc-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  font-family: inherit;
}
.prepress-options { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0 0 0.9rem; }
.prepress-options label { display: flex; align-items: center; gap: 0.45rem; font-size: 0.84rem; color: var(--muted); }
.prepress-options select { border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-size: 0.84rem; padding: 0.35rem 0.5rem; font-family: inherit; }

/* Spaziatura tra i blocchi dei risultati */
#results > * + * { margin-top: 1.5rem; }
.analysis-side-body #results > * + * { margin-top: 1.1rem; }

.autosave-timer { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Versioni del manoscritto */
.versions-box { width: min(980px, 96%); }
.versions-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 780px) { .versions-layout { grid-template-columns: 1fr; } }
.versions-list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 60vh; overflow: auto; }
.version-item { border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.8rem; background: var(--card); }
.version-item.current { border-color: var(--accent); background: var(--accent-soft); }
.version-item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }
.version-meta { display: block; color: var(--muted); font-size: 0.76rem; margin-top: 0.25rem; }
.version-actions { display: flex; gap: 0.4rem; margin-top: 0.55rem; }
.version-detail { border: 1px solid var(--border); border-radius: 12px; padding: 0.8rem; max-height: 60vh; overflow: auto; background: var(--card); }
.version-diff { font-size: 0.8rem; line-height: 1.5; font-family: inherit; }
.version-diff .diff-add { background: rgba(79, 154, 135, 0.14); }
.version-diff .diff-remove { background: rgba(192, 80, 106, 0.14); }
.stale-banner { background: rgba(185, 138, 63, 0.14); border: 1px solid rgba(185, 138, 63, 0.4); color: #8a6a1f; border-radius: 12px; padding: 0.7rem 0.9rem; font-size: 0.86rem; }
.project-stale { color: #8a6a1f; }

/* Scrivania editoriale e Issue */
.desk-box, .issues-box { width: min(1080px, 96%); }
.desk-counts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.9rem; }
.desk-chip { font-size: 0.72rem; background: var(--accent-soft); color: var(--accent); border-radius: 980px; padding: 0.2rem 0.6rem; }
.desk-table { overflow: auto; max-height: 62vh; }
.desk-grid { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.desk-grid th { text-align: left; color: var(--muted); font-weight: 600; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.desk-grid td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.desk-grid td .vc-select { width: 100%; }
.issues-toolbar { margin: 0 0 0.8rem; }
.issues-list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 60vh; overflow: auto; }
.issue-row { border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 10px; padding: 0.6rem 0.8rem; }
.issue-row.issue-high, .issue-row.issue-critical { border-left-color: var(--danger); }
.issue-row.issue-medium { border-left-color: #b98a3f; }
.issue-row.issue-low { border-left-color: var(--ok); }
.issue-row-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }
.issue-row-head small { color: var(--muted); font-size: 0.72rem; }
.issue-row-controls { display: flex; gap: 0.45rem; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; }

/* Dossier con evidenze */
.dossier-toolbar { display: flex; align-items: center; gap: 0.8rem; margin: 0.6rem 0 0.8rem; flex-wrap: wrap; }
.dossier-findings { display: flex; flex-direction: column; gap: 0.6rem; max-height: 40vh; overflow: auto; margin-bottom: 0.8rem; }
.finding { border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 10px; padding: 0.6rem 0.8rem; }
.finding-high, .finding-critical { border-left-color: var(--danger); }
.finding-medium { border-left-color: #b98a3f; }
.finding-low { border-left-color: var(--ok); }
.finding-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }
.finding-head small { color: var(--muted); font-size: 0.72rem; }
.finding-evidence blockquote { margin: 0.4rem 0 0; font-size: 0.82rem; font-style: italic; color: var(--muted); border-left: 2px solid var(--border); padding-left: 0.6rem; }
.finding-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; }

.desk-toolbar { margin: 0 0 0.7rem; }
.desk-toolbar input { width: 100%; }
.issue-evidence { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.evidence-chip { border: 1px solid var(--border); background: rgba(0,0,0,.02); border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.72rem; color: var(--text); cursor: pointer; font-family: inherit; }
.evidence-chip:hover { border-color: var(--accent); color: var(--accent); }

.issue-history { margin-top: 0.5rem; font-size: 0.75rem; color: var(--muted); }
.issue-history summary { cursor: pointer; }
.issue-history-line { padding: 0.15rem 0; }
.decision-box { width: min(620px, 96%); }
.decision-box textarea, .decision-box input, .decision-box select { width: 100%; }

.selection-toolbar { position: absolute; z-index: 100001; display: flex; gap: 0.3rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 0.25rem; box-shadow: 0 10px 26px rgba(0,0,0,.16); }
.selection-toolbar button { border: none; background: transparent; color: var(--text); font-size: 0.78rem; padding: 0.3rem 0.6rem; border-radius: 8px; cursor: pointer; font-family: inherit; }
.selection-toolbar button:hover { background: var(--accent-soft); color: var(--accent); }
.versions-controls { display: flex; gap: 1rem; align-items: center; margin: 0 0 0.8rem; font-size: 0.82rem; color: var(--muted); }
.checkbox-inline { display: inline-flex; align-items: center; gap: 0.4rem; }

.metrics-box { width: min(760px, 96%); }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.metric-card { background: var(--card-2); border-radius: 12px; padding: 0.7rem; text-align: center; }
.metric-card strong { display: block; font-size: 1.4rem; }
.metric-card span { font-size: 0.72rem; color: var(--muted); }
.metric-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.metric-chip { font-size: 0.74rem; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0.15rem 0.55rem; }
.metric-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 30vh; overflow: auto; }
.metric-long { text-align: left; border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 0.45rem 0.6rem; font-size: 0.8rem; cursor: pointer; font-family: inherit; color: var(--text); }
.metric-long:hover { border-color: var(--accent); }

.goal-progress { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.goal-progress.done { color: var(--ok); font-weight: 600; }

.metric-long { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }

.outline-box { width: min(680px, 96%); }
.outline-content { display: flex; flex-direction: column; gap: 0.4rem; max-height: 60vh; overflow: auto; }
.outline-item { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 0.5rem 0.7rem; cursor: pointer; font-family: inherit; color: var(--text); text-align: left; }
.outline-item:hover { border-color: var(--accent); }
.outline-item span { color: var(--muted); font-size: 0.75rem; }
.outline-level-2 { margin-left: 1rem; }
.outline-level-3 { margin-left: 2rem; }

.theme-toggle { border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 999px; width: 32px; height: 28px; cursor: pointer; font-size: 0.85rem; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] {
  --bg: #15171c;
  --bg-soft: #1a1d23;
  --card: #1e222a;
  --card-2: #262b34;
  --border: rgba(255, 255, 255, 0.12);
  --text: #e8eaef;
  --muted: #9aa1ad;
  --accent-soft: #2a2740;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] body:not(.in-app) {
  --ed-paper: #15171c; --ed-ink: #e8eaef; --ed-muted: #9aa1ad; --ed-line: rgba(255,255,255,.12);
}
[data-theme="dark"] .writer-canvas { background: #1e222a; color: var(--text); }

.glossary-box, .tasks-box, .stats-box, .today-box, .summary-box { width: min(760px, 96%); }
.glossary-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0.9rem; }
.glossary-toolbar .vc-select { flex: 1; min-width: 140px; }
.glossary-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 60vh; overflow: auto; }
.glossary-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem 0.7rem; }
.glossary-row small { display: block; color: var(--muted); font-size: 0.74rem; }
.today-content { display: flex; flex-direction: column; gap: 1rem; max-height: 62vh; overflow: auto; }
.today-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.version-label-input { margin-top: 0.4rem; width: 100%; }

.summary-head { margin-bottom: 1rem; }
.summary-head h3 { margin: 0.15rem 0 0.25rem; font-size: 1.45rem; }
.summary-body { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-height: 56vh; overflow: auto; }
.summary-section { border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem; background: var(--card); }
.summary-section h4 { margin: 0 0 0.7rem; font-size: 0.92rem; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.summary-stat { display: flex; flex-direction: column; gap: 0.1rem; }
.summary-stat strong { font-size: 1.05rem; }
.summary-stat span { color: var(--muted); font-size: 0.7rem; }
.summary-action { margin-top: 0.8rem; }.summary-entries { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.5rem; }
.summary-entry { display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 12px; background: var(--card); padding: 0.7rem 0.85rem; cursor: pointer; color: var(--text); }
.summary-entry:hover { border-color: var(--accent); background: var(--accent-soft); }
.summary-entry.active { border-color: var(--accent); background: var(--accent-soft); }
.summary-file-row { padding: 0; gap: 0; }
.summary-entry-main { flex: 1; display: flex; align-items: center; gap: 0.7rem; text-align: left; border: 0; background: transparent; padding: 0.7rem 0.85rem; cursor: pointer; color: var(--text); border-radius: 12px; }
.summary-file-delete { border: 0; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 0 0.7rem; align-self: stretch; }
.summary-file-delete:hover { color: var(--danger); }
.summary-entry-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 1rem; flex: none; }
.summary-entry-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1; }
.summary-entry-body strong { font-size: 0.92rem; }
.summary-entry-body small { color: var(--muted); font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-entry-go { color: var(--muted); }
.summary-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }

.plot-picker-box { width: min(520px, 96%); }
.plot-picker-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0.4rem; }
.plot-picker-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.6rem; max-height: 44vh; overflow: auto; }
.plot-picker-subhead { margin: 0.6rem 0 0.2rem; }
.plot-picker-item { display: flex; flex-direction: column; gap: 0.15rem; text-align: left; border: 1px solid var(--border); border-radius: 10px; background: var(--card); padding: 0.6rem 0.75rem; cursor: pointer; color: var(--text); }
.plot-picker-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.plot-picker-item small { color: var(--muted); font-size: 0.72rem; }
@media (max-width: 640px) { .summary-body { grid-template-columns: 1fr; } .summary-grid { grid-template-columns: repeat(2, 1fr); } }

.project-summary:hover { color: var(--accent); background: rgba(109, 91, 208, 0.12); }

/* Dark theme: superfici e contrasto */
[data-theme="dark"] .topbar { background: rgba(21, 23, 28, 0.82); border-color: var(--border); }
[data-theme="dark"] .writer-bar,
[data-theme="dark"] .writer-toolbar { background: var(--card); border-color: var(--border); }
[data-theme="dark"] .writer-canvas { background: var(--card); color: var(--text); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45); }
[data-theme="dark"] .prepress-frame { background: var(--card); }
[data-theme="dark"] .dropzone { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .modal { background: rgba(0, 0, 0, 0.55); }
[data-theme="dark"] .btn-ghost { background: rgba(255, 255, 255, 0.05); color: var(--text); }
[data-theme="dark"] .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }
[data-theme="dark"] input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--card-2); color: var(--text); }
[data-theme="dark"] .auth-error { color: #ffb3c4; background: rgba(192, 80, 106, 0.18); }
[data-theme="dark"] .auth-notice { color: #b7d4f0; background: rgba(64, 128, 192, 0.18); }
[data-theme="dark"] * { scrollbar-color: rgba(255, 255, 255, 0.25) transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); }
[data-theme="dark"] body.writer-mode { background: var(--bg); }
[data-theme="dark"] .writer-toolbar button { color: var(--text); }
[data-theme="dark"] .writer-toolbar button.active { background: var(--accent); color: #fff; }

/* --- Dialoghi input generici, guida scorciatoie --- */
.modal-narrow { width: min(420px, 100%); }
.modal-narrow textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}
.shortcuts-box h3 { margin-top: 0; }
.shortcuts-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem 1rem;
  align-items: center;
  margin: 1rem 0 1.4rem;
}
.shortcuts-list dt { margin: 0; }
.shortcuts-list dd { margin: 0; color: var(--muted); font-size: 0.9rem; }
.shortcuts-list kbd {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 7px;
  background: var(--card-2);
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
}
.editor-status { align-items: center; }
.shortcuts-trigger { margin-left: auto; white-space: nowrap; }

/* --- Palette dei comandi --- */
.command-modal { align-items: flex-start; }
.command-box { margin-top: 12vh; padding: 0.9rem; width: min(560px, 100%); }
.command-input {
  width: 100%;
  font: inherit;
  font-size: 1.02rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}
.command-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.command-list { list-style: none; margin: 0.6rem 0 0; padding: 0; max-height: 52vh; overflow-y: auto; }
.command-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
}
.command-item.active { background: var(--accent-soft); }
.command-group {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  min-width: 74px;
}
.command-label { font-size: 0.94rem; }
.command-hint { margin-left: auto; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.72rem; }
.command-empty { padding: 0.8rem; color: var(--muted); font-size: 0.9rem; }
.goal-button { background: transparent; border: 1px dashed transparent; border-radius: 8px; cursor: pointer; padding: 0.15rem 0.35rem; font-family: inherit; }
.goal-button:hover { border-color: var(--border); color: var(--accent); }

/* --- Riepilogo controlli di stile --- */
.style-summary { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 0.8rem; }
.style-chip {
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--muted);
}
.style-chip.has-value { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* --- Barra trova e sostituisci --- */
.find-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.7rem;
  margin: 0.5rem 0 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.find-bar .vc-select { min-width: 150px; padding: 0.35rem 0.55rem; font-size: 0.85rem; }
.find-count { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 70px; }
