/* Leaflet 1.9.x core layout — vendored locally to prevent broken tile layout */
.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}.leaflet-container{overflow:hidden;-webkit-tap-highlight-color:transparent}.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile::selection{background:transparent}.leaflet-safari .leaflet-tile{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container{width:1600px;height:1600px;-webkit-transform-origin:0 0}.leaflet-marker-icon,.leaflet-marker-shadow{display:block}.leaflet-container .leaflet-overlay-pane svg{max-width:none!important;max-height:none!important}.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-tile{max-width:none!important;max-height:none!important;width:auto;padding:0}.leaflet-container.leaflet-touch-zoom{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{-ms-touch-action:none;touch-action:none}.leaflet-container{-webkit-touch-callout:none}.leaflet-tile{filter:inherit;visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-box{width:0;height:0;-moz-box-sizing:border-box;box-sizing:border-box;z-index:800}.leaflet-overlay-pane svg{-moz-user-select:none}.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}.leaflet-vml-shape{width:1px;height:1px}.lvml{behavior:url(#default#VML);display:inline-block;position:absolute}.leaflet-control{position:relative;z-index:800;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}.leaflet-fade-anim .leaflet-popup{opacity:0;transition:opacity .2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}.leaflet-zoom-animated{transform-origin:0 0}.leaflet-zoom-anim .leaflet-zoom-animated{transition:transform .25s cubic-bezier(0,0,.25,1)}.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{transition:none}.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:grab}.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}.leaflet-popup-pane,.leaflet-control{cursor:auto}.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive{cursor:grabbing}.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive,svg.leaflet-image-layer.leaflet-interactive path{pointer-events:auto}.leaflet-container{background:#ddd;outline-offset:1px}.leaflet-container a{color:#0078a8}.leaflet-zoom-box{border:2px dotted #38f;background:rgba(255,255,255,.5)}.leaflet-bar{box-shadow:0 1px 5px rgba(0,0,0,.65);border-radius:4px}.leaflet-bar a{background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:#000}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom:none}.leaflet-bar a.leaflet-disabled{cursor:default;background-color:#f4f4f4;color:#bbb}.leaflet-control-zoom-in,.leaflet-control-zoom-out{font:700 18px Lucida Console,Monaco,monospace;text-indent:1px}.leaflet-control-attribution{background:#fff;background:rgba(255,255,255,.8);margin:0;color:#333;padding:0 5px}.leaflet-control-attribution,.leaflet-control-scale-line{font-size:11px}.leaflet-control-attribution a{text-decoration:none}.leaflet-control-attribution a:hover{text-decoration:underline}.leaflet-popup{position:absolute;text-align:center;margin-bottom:20px}.leaflet-popup-content-wrapper{padding:1px;text-align:left;border-radius:12px}.leaflet-popup-content{margin:13px 24px 13px 20px;line-height:1.3;font-size:13px;min-height:1px}.leaflet-popup-tip-container{width:40px;height:20px;position:absolute;left:50%;margin-top:-1px;margin-left:-20px;overflow:hidden;pointer-events:none}.leaflet-popup-tip{width:17px;height:17px;padding:1px;margin:-10px auto 0;pointer-events:auto;transform:rotate(45deg)}.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:#fff;color:#333;box-shadow:0 3px 14px rgba(0,0,0,.4)}.leaflet-container a.leaflet-popup-close-button{position:absolute;top:0;right:0;border:none;text-align:center;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;color:#757575;text-decoration:none;background:transparent}.leaflet-tooltip{position:absolute;padding:6px;background-color:#fff;border:1px solid #fff;border-radius:3px;color:#222;white-space:nowrap;box-shadow:0 1px 3px rgba(0,0,0,.4);pointer-events:none}.leaflet-tooltip.leaflet-interactive{cursor:pointer;pointer-events:auto}

:root {
  color-scheme: light;

  --page: #f6f6f4;
  --surface: #ffffff;
  --surface-soft: #f1f1ef;
  --surface-hover: #e9e9e6;
  --sidebar: #efefec;
  --sidebar-deep: #e7e7e3;
  --text: #20201f;
  --muted: #757572;
  --faint: #a2a29e;
  --border: #deded9;
  --border-strong: #cacac4;
  --accent: #1f6f5f;
  --accent-hover: #195c4f;
  --accent-soft: rgba(31, 111, 95, 0.10);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.08);
  --success: #16794f;
  --overlay: rgba(16, 16, 15, 0.52);
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.06);
  --shadow-md: 0 12px 35px rgba(15, 15, 15, 0.15);
  --shadow-lg: 0 25px 80px rgba(15, 15, 15, 0.22);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --composer-shadow:
    0 0 0 1px rgba(20, 20, 19, 0.06),
    0 8px 30px rgba(20, 20, 19, 0.10);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --page: #20201f;
  --surface: #292928;
  --surface-soft: #30302f;
  --surface-hover: #383836;
  --sidebar: #151515;
  --sidebar-deep: #111111;
  --text: #eeeeeb;
  --muted: #aaa9a4;
  --faint: #777772;
  --border: #3a3a38;
  --border-strong: #4b4b48;
  --accent: #62b49f;
  --accent-hover: #79c2af;
  --accent-soft: rgba(98, 180, 159, 0.12);
  --danger: #ff8174;
  --danger-soft: rgba(255, 129, 116, 0.10);
  --success: #7bd6aa;
  --overlay: rgba(0, 0, 0, 0.70);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 12px 35px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 25px 80px rgba(0, 0, 0, 0.46);
  --composer-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 12px 38px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;

    --page: #20201f;
    --surface: #292928;
    --surface-soft: #30302f;
    --surface-hover: #383836;
    --sidebar: #151515;
    --sidebar-deep: #111111;
    --text: #eeeeeb;
    --muted: #aaa9a4;
    --faint: #777772;
    --border: #3a3a38;
    --border-strong: #4b4b48;
    --accent: #62b49f;
    --accent-hover: #79c2af;
    --accent-soft: rgba(98, 180, 159, 0.12);
    --danger: #ff8174;
    --danger-soft: rgba(255, 129, 116, 0.10);
    --success: #7bd6aa;
    --overlay: rgba(0, 0, 0, 0.70);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.16);
    --shadow-md: 0 12px 35px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 25px 80px rgba(0, 0, 0, 0.46);
    --composer-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.04),
      0 12px 38px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--page);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  padding: 10px 14px;
  font-weight: 650;
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    opacity 0.16s ease,
    transform 0.16s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

label,
.field-label {
  display: block;
  margin: 0 0 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.hidden {
  display: none !important;
}

.muted,
.field-help {
  color: var(--muted);
}

.field-help {
  margin: 7px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.error-message {
  min-height: 20px;
  color: var(--danger);
}

/* Login */

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(
      circle at 50% 0%,
      var(--accent-soft),
      transparent 36%
    ),
    var(--page);
}

.login-card {
  width: min(100%, 390px);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 13px;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 25px;
  letter-spacing: -0.03em;
}

.login-card p {
  margin-top: 0;
}

.login-card label {
  margin-top: 24px;
}

.login-card button {
  width: 100%;
  margin-top: 16px;
}

/* Layout */

.app {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  overflow: hidden;
  background: var(--page);
}

.sidebar {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}

.sidebar-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 13px 0 15px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  background: var(--text);
  color: var(--sidebar);
  font-size: 10px;
  font-weight: 800;
}

.brand-name {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-close-button {
  display: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
}

.sidebar-close-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-controls {
  padding: 4px 10px 10px;
}

.new-chat-button {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.new-chat-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.new-chat-icon {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 20px;
  font-weight: 400;
}

.search-shell {
  position: relative;
  margin-top: 8px;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  z-index: 1;
  color: var(--faint);
  font-size: 18px;
  transform: translateY(-52%);
  pointer-events: none;
}

.chat-search {
  height: 38px;
  padding: 8px 10px 8px 34px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
}

.chat-search:hover,
.chat-search:focus {
  border-color: var(--border);
  background: var(--surface);
}

.folder-filter {
  height: 34px;
  margin-top: 4px;
  padding: 6px 31px 6px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.folder-filter:hover,
.folder-filter:focus {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.chat-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 3px 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.chat-section-title {
  padding: 15px 9px 6px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chat-list-empty {
  padding: 22px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.chat-list-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  margin-bottom: 2px;
  border-radius: 9px;
}

.chat-list-row:hover,
.chat-list-row.active {
  background: var(--surface-hover);
}

.chat-list-row.active {
  box-shadow: inset 2px 0 0 var(--accent);
}

.chat-list-item {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 9px 4px 9px 11px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.chat-list-item:hover {
  background: transparent;
}

.chat-list-title {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 520;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-list-row.active .chat-list-title {
  font-weight: 650;
}

.chat-list-row.pinned .chat-list-title::before {
  content: "•";
  margin-right: 7px;
  color: var(--accent);
}

.chat-folder-name {
  overflow: hidden;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-menu-button {
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--faint);
  opacity: 0;
}

.chat-list-row:hover .chat-menu-button,
.chat-list-row.active .chat-menu-button,
.chat-menu-button:focus-visible {
  opacity: 1;
}

.chat-menu-button:hover {
  background: var(--surface);
  color: var(--text);
}

.search-result {
  width: 100%;
  margin-bottom: 4px;
  padding: 10px 11px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-result:hover {
  background: var(--surface-hover);
}

.search-result-title {
  display: block;
  margin-bottom: 3px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.search-result-snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.search-result-meta {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-size: 10px;
}

.sidebar-footer {
  padding: 9px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-deep);
}

.profile-button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.profile-button:hover {
  background: var(--surface-hover);
}

.profile-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.profile-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.profile-copy strong,
.profile-copy small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.profile-copy strong {
  font-size: 12px;
  font-weight: 650;
}

.profile-copy small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.profile-chevron {
  color: var(--faint);
  font-size: 18px;
}

.sidebar-logout {
  width: 100%;
  margin-top: 2px;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
}

.sidebar-logout:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Main chat */

.chat-area {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--page);
}

.chat-header {
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--page) 92%, transparent);
  backdrop-filter: blur(12px);
}

.menu-button {
  display: none;
}

.chat-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-heading strong,
.chat-heading span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-heading strong {
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.chat-heading span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.header-icon-button,
.header-text-button {
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.header-icon-button {
  width: 34px;
  padding: 0;
  font-size: 17px;
}

.header-icon-button:hover,
.header-text-button:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 32px max(24px, calc((100% - 880px) / 2));
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.empty-state {
  max-width: 430px;
  margin: auto;
  padding: 36px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  font-weight: 800;
}

.empty-state h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

.empty-state p {
  margin: 8px 0 0;
  font-size: 13px;
}

.message {
  width: min(100%, 820px);
  align-self: center;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 11px;
  padding: 17px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.message + .message {
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.message.user-message {
  width: auto;
  max-width: min(74%, 680px);
  align-self: flex-end;
  display: block;
  margin: 8px 0 14px;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 18px 18px 5px 18px;
  background: var(--surface-soft);
  box-shadow: var(--shadow-sm);
}

.message.user-message + .message {
  border-top: 0;
}

.message.user-message .avatar {
  display: none;
}

.message.user-message .message-meta {
  justify-content: flex-end;
  margin-bottom: 5px;
}

.message.user-message .message-meta strong {
  display: none;
}

.message.user-message .message-meta span {
  font-size: 10px;
}

.avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-top: 1px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 9px;
  font-weight: 800;
}

.message-main {
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--faint);
  font-size: 10px;
}

.message-meta strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 680;
}

.message-content {
  overflow-x: auto;
  color: var(--text);
  font-size: 15px;
}

.message-content p {
  margin: 0 0 12px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  margin: 24px 0 10px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.message-content h1 {
  font-size: 24px;
}

.message-content h2 {
  font-size: 20px;
}

.message-content h3 {
  font-size: 17px;
}

.message-content pre {
  position: relative;
  overflow-x: auto;
  margin: 15px 0;
  padding: 42px 15px 15px;
  border: 1px solid #303331;
  border-radius: 12px;
  background: #151716;
  color: #f4f5f3;
  box-shadow: var(--shadow-sm);
}

.message-content code {
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.91em;
}

.inline-code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-soft);
}

.copy-code-button {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 5px 8px;
  border: 1px solid #3d403e;
  background: #222523;
  color: #d8dad7;
  font-size: 10px;
}

.copy-code-button:hover {
  background: #2d302e;
}

.message-content ul,
.message-content ol {
  padding-left: 24px;
}

.message-content li {
  margin: 5px 0;
}

.message-content blockquote {
  margin: 14px 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.message-content table {
  width: 100%;
  margin: 15px 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.message-content th,
.message-content td {
  padding: 9px 11px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.message-content tr:last-child td {
  border-bottom: 0;
}

.message-content th:last-child,
.message-content td:last-child {
  border-right: 0;
}

.message-content th {
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 680;
}

.message-actions {
  min-height: 27px;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.message:hover .message-actions,
.message:focus-within .message-actions,
.message.user-message .message-actions {
  opacity: 1;
}

.message-action-button {
  min-width: 29px;
  height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 540;
}

.message-action-button:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.message-action-icon {
  font-size: 14px;
  line-height: 1;
}

.message-action-label {
  display: none;
}

.message.search-highlight {
  animation: search-highlight 2.2s ease;
}

@keyframes search-highlight {
  0%,
  45% {
    background: var(--accent-soft);
  }

  100% {
    background: transparent;
  }
}

/* Attachments */

.attachments {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.attachment-card {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  max-width: 620px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.attachment-card.generated-file {
  border-color:
    color-mix(in srgb, var(--success) 55%, var(--border));
  background:
    color-mix(in srgb, var(--success) 8%, var(--surface-soft));
}

.attachment-icon {
  font-size: 18px;
}

.attachment-info {
  min-width: 0;
}

.attachment-name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.attachment-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.attachment-open-button {
  padding: 6px 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 10px;
}

.attachment-open-button:hover {
  background: var(--surface-hover);
}

.attachment-image {
  max-width: min(100%, 590px);
  max-height: 440px;
  display: block;
  margin-top: 9px;
  border: 1px solid var(--border);
  border-radius: 11px;
  object-fit: contain;
  background: var(--surface-soft);
}

/* Composer */

.message-form {
  flex: 0 0 auto;
  padding:
    10px
    max(18px, calc((100% - 900px) / 2))
    max(14px, env(safe-area-inset-bottom));
  background:
    linear-gradient(
      to top,
      var(--page) 72%,
      color-mix(in srgb, var(--page) 86%, transparent)
    );
}

.composer-region {
  width: 100%;
}

.typing-status {
  min-height: 20px;
  padding: 0 8px 5px;
  color: var(--muted);
  font-size: 11px;
}

.inline-notice {
  margin: 0 0 7px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.inline-notice.error {
  border-color:
    color-mix(in srgb, var(--danger) 40%, var(--border));
  color: var(--danger);
}

.inline-notice.success {
  color: var(--success);
}

.message-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 5px;
}

.composer-box {
  min-height: 58px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--composer-shadow);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.composer-box:focus-within {
  border-color:
    color-mix(in srgb, var(--accent) 65%, var(--border));
  box-shadow:
    0 0 0 3px var(--accent-soft),
    var(--composer-shadow);
}

.composer-box textarea {
  min-height: 44px;
  max-height: 220px;
  padding: 11px 7px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
  line-height: 1.45;
}

.composer-box textarea:focus {
  box-shadow: none;
}

.composer-icon-button,
.composer-send-button,
.composer-stop-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 12px;
}

.composer-icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 23px;
  font-weight: 300;
}

.composer-icon-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.composer-send-button {
  background: var(--text);
  color: var(--surface);
  font-size: 21px;
  font-weight: 500;
}

.composer-send-button:hover {
  background: var(--accent);
  color: #ffffff;
}

.composer-stop-button {
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.composer-stop-button:hover {
  background: var(--danger);
  color: #ffffff;
}

.composer-hint {
  margin: 7px 7px 0;
  color: var(--faint);
  font-size: 10px;
  text-align: center;
}

.selected-files {
  margin: 0 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-file {
  max-width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
}

.selected-file-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.selected-file-size {
  color: var(--faint);
  font-size: 9px;
}

.remove-file-button {
  padding: 0 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
}

.upload-progress {
  margin: 0 7px 7px;
  color: var(--muted);
  font-size: 10px;
}

/* Streaming */

.message.streaming {
  background: transparent;
}

.message-content.streaming-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-content.streaming-content::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 0.17em;
  vertical-align: -0.12em;
  border-radius: 2px;
  background: currentColor;
  animation: streaming-cursor 0.85s steps(1) infinite;
}

@keyframes streaming-cursor {
  0%,
  48% {
    opacity: 1;
  }

  49%,
  100% {
    opacity: 0;
  }
}

.typing-dots span {
  display: inline-block;
  animation: typing-bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }

  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* Modals */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--overlay);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(100%, 560px);
  max-height: 92vh;
  overflow-y: auto;
  padding: 23px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.compact-modal {
  width: min(100%, 390px);
}

.settings-modal {
  width: min(100%, 760px);
  padding: 0;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.settings-modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 24px 26px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.modal-header h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.close-button {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  font-weight: 300;
}

.close-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.modal-button-list {
  display: grid;
  gap: 4px;
}

.modal-list-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 11px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.modal-list-button:hover {
  background: var(--surface-hover);
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover {
  background: var(--surface-hover);
}

.danger-text-button {
  border: 1px solid
    color-mix(in srgb, var(--danger) 35%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.danger-text-button:hover {
  background: var(--danger);
  color: #ffffff;
}

.full-width {
  width: 100%;
}

.top-gap {
  margin-top: 10px;
}

.compact-label {
  margin-top: 20px;
}

.settings-section {
  margin: 0 26px;
  padding: 25px 0;
  border-bottom: 1px solid var(--border);
}

.compact-settings-section {
  border-bottom: 0;
}

.settings-section-heading {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 19px;
}

.settings-section-index {
  color: var(--faint);
  font-family:
    "SFMono-Regular",
    Consolas,
    monospace;
  font-size: 10px;
}

.settings-section-heading h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.settings-section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.field-group + .field-group {
  margin-top: 16px;
}

.settings-grid .field-group + .field-group {
  margin-top: 0;
}

.settings-textarea {
  min-height: 115px;
  resize: vertical;
}

.model-description,
.usage-information {
  margin: 8px 0 0;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.model-description strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 12px;
}

.usage-group {
  display: flex;
  flex-direction: column;
}

.usage-information {
  flex: 1;
  margin-top: 0;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.settings-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.settings-list-empty {
  padding: 13px;
  border: 1px dashed var(--border);
  border-radius: 9px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.settings-list-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
}

.settings-list-item.disabled {
  opacity: 0.56;
}

.settings-list-text {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
}

.settings-list-actions {
  display: flex;
  gap: 4px;
}

.mini-button {
  padding: 5px 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 9px;
}

.memory-toggle {
  width: 17px;
  height: 17px;
  margin: 0;
}

.settings-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 17px 26px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.settings-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

/* Feedback */

.toast {
  position: fixed;
  z-index: 60;
  right: 18px;
  bottom: 18px;
  max-width: min(390px, calc(100vw - 36px));
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: 12px;
}

.toast.error {
  color: var(--danger);
}

.toast.success {
  color: var(--success);
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.60);
  pointer-events: none;
}

.drop-overlay-card {
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.drop-overlay-icon {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 34px;
  font-weight: 300;
}

.drop-overlay-card strong {
  font-size: 16px;
}

.drop-overlay-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.mobile-overlay {
  display: none;
}

/* Responsive */

@media (max-width: 900px) {
  .app {
    display: block;
    height: 100vh;
    height: 100dvh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(88vw, 300px);
    height: 100vh;
    height: 100dvh;
    transform: translateX(-103%);
    transition: transform 0.20s ease;
    box-shadow: 10px 0 36px rgba(0, 0, 0, 0.28);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-button {
    display: grid;
    place-items: center;
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: block;
    background: var(--overlay);
  }

  .chat-area {
    width: 100%;
    height: 100vh;
    height: 100dvh;
  }

  .menu-button {
    display: grid;
    place-items: center;
  }

  .messages {
    padding:
      22px
      max(13px, calc((100% - 820px) / 2));
  }

  .message-form {
    padding:
      8px
      12px
      max(10px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 620px) {
  .chat-header {
    min-height: 56px;
    padding: 7px 10px;
  }

  .header-text-button {
    display: none;
  }

  .messages {
    gap: 3px;
    padding: 18px 10px;
  }

  .message {
    grid-template-columns: 25px minmax(0, 1fr);
    gap: 8px;
    padding: 14px 5px;
  }

  .avatar {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    font-size: 8px;
  }

  .message.user-message {
    max-width: 88%;
    margin-right: 2px;
  }

  .message-content {
    font-size: 14px;
  }

  .message-actions {
    opacity: 1;
  }

  .composer-box {
    min-height: 54px;
    border-radius: 16px;
  }

  .composer-icon-button,
  .composer-send-button,
  .composer-stop-button {
    width: 37px;
    height: 37px;
  }

  .composer-hint {
    display: none;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid .field-group + .field-group {
    margin-top: 0;
  }

  .settings-modal-header,
  .settings-section,
  .settings-footer {
    margin-left: 0;
    margin-right: 0;
  }

  .settings-modal-header {
    padding: 20px;
  }

  .settings-section {
    margin: 0 20px;
  }

  .settings-footer {
    padding: 14px 20px;
  }

  .inline-control {
    grid-template-columns: 1fr;
  }

  .inline-control button {
    width: 100%;
  }
}

@media print {
  body {
    overflow: visible;
    background: #ffffff;
    color: #000000;
  }

  #sidebar,
  .chat-header,
  .message-form,
  .modal-backdrop,
  .toast,
  .mobile-overlay {
    display: none !important;
  }

  .app,
  .chat-area {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .messages {
    display: block;
    overflow: visible;
    padding: 0;
  }

  .message {
    width: 100%;
    break-inside: avoid;
    margin: 0 0 13px;
    border: 0;
    color: #000000;
    background: #ffffff !important;
  }

  .message.user-message {
    max-width: 75%;
    margin-left: auto;
    border: 1px solid #bbbbbb;
  }

  .message-action-button,
  .copy-code-button {
    display: none !important;
  }
}



/* V7.2 — cartelle nella sidebar, menu contestuali e modello rapido */

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-collapse-button {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  font-weight: 300;
}

.sidebar-collapse-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.folder-area {
  padding: 2px 8px 8px;
  border-bottom: 1px solid
    color-mix(in srgb, var(--border) 70%, transparent);
}

.sidebar-section-header {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.sidebar-section-action {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  font-weight: 300;
}

.sidebar-section-action:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.folder-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 29px 29px;
  gap: 4px;
  padding: 3px 3px 7px;
}

.folder-create-row input {
  height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.folder-create-confirm,
.folder-create-cancel {
  width: 29px;
  height: 29px;
  align-self: center;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.folder-create-confirm:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.folder-create-cancel:hover {
  color: var(--danger);
}

.folder-list {
  display: grid;
  gap: 2px;
  max-height: 42vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.folder-list-empty,
.folder-chat-empty {
  padding: 7px 9px;
  color: var(--faint);
  font-size: 10px;
}

.folder-group {
  min-width: 0;
}

.folder-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto 27px;
  align-items: center;
  border-radius: 8px;
}

.folder-row:hover {
  background: var(--surface-hover);
}

.folder-toggle,
.folder-name-button,
.folder-menu-button {
  border: 0;
  background: transparent;
  color: var(--text);
}

.folder-toggle {
  width: 22px;
  height: 28px;
  padding: 0;
  color: var(--muted);
  font-size: 16px;
}

.folder-name-button {
  min-width: 0;
  padding: 6px 2px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.folder-count {
  padding: 0 5px;
  color: var(--faint);
  font-size: 9px;
}

.folder-menu-button {
  width: 27px;
  height: 27px;
  padding: 0;
  color: var(--faint);
  opacity: 0;
}

.folder-row:hover .folder-menu-button,
.folder-menu-button:focus-visible {
  opacity: 1;
}

.folder-menu-button:hover {
  background: var(--surface);
  color: var(--text);
}

.folder-chat-list {
  display: grid;
  gap: 1px;
  margin-left: 13px;
  padding-left: 7px;
  border-left: 1px solid var(--border);
}

.nested-chat-row {
  margin-bottom: 0;
}

.nested-chat-row .chat-list-item {
  padding-top: 7px;
  padding-bottom: 7px;
}

.inline-rename-editor {
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 27px 27px;
  gap: 4px;
  padding: 3px;
}

.folder-inline-editor {
  grid-column: 1 / -1;
}

.inline-rename-editor input {
  min-width: 0;
  height: 31px;
  padding: 5px 7px;
  font-size: 12px;
}

.inline-rename-save,
.inline-rename-cancel {
  width: 27px;
  height: 27px;
  align-self: center;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.inline-rename-save:hover {
  color: var(--accent);
}

.inline-rename-cancel:hover {
  color: var(--danger);
}

.context-menu {
  position: fixed;
  z-index: 70;
  width: 220px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.context-submenu {
  z-index: 72;
  max-height: min(360px, 70vh);
  overflow-y: auto;
}

.context-menu-item {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 540;
  text-align: left;
}

.context-menu-item:hover {
  background: var(--surface-hover);
}

.context-shortcut {
  color: var(--faint);
  font-size: 12px;
}

.context-menu-separator {
  height: 1px;
  margin: 4px 5px;
  background: var(--border);
}

.context-menu-danger {
  color: var(--danger);
}

.context-menu-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.header-model-control {
  display: grid;
  grid-template-columns: auto minmax(120px, 210px);
  align-items: center;
  gap: 6px;
  margin: 0;
}

.header-model-label {
  color: var(--faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-model-select {
  height: 34px;
  max-width: 230px;
  padding: 6px 28px 6px 9px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.header-model-select:hover,
.header-model-select:focus {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.app.sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.app.sidebar-collapsed .brand-name,
.app.sidebar-collapsed .new-chat-label,
.app.sidebar-collapsed .search-shell,
.app.sidebar-collapsed .folder-area,
.app.sidebar-collapsed .chat-list,
.app.sidebar-collapsed .profile-copy,
.app.sidebar-collapsed .profile-chevron,
.app.sidebar-collapsed .sidebar-logout {
  display: none;
}

.app.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}

.app.sidebar-collapsed .brand {
  display: none;
}

.app.sidebar-collapsed .sidebar-header-actions {
  display: block;
}

.app.sidebar-collapsed .sidebar-controls {
  padding: 5px 10px;
}

.app.sidebar-collapsed .new-chat-button {
  width: 44px;
  height: 44px;
  justify-content: center;
  padding: 0;
}

.app.sidebar-collapsed .new-chat-icon {
  font-size: 23px;
}

.app.sidebar-collapsed .sidebar-footer {
  display: grid;
  place-items: center;
  padding: 9px;
}

.app.sidebar-collapsed .profile-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
}

.app.sidebar-collapsed .profile-avatar {
  width: 32px;
  height: 32px;
}

@media (max-width: 900px) {
  .sidebar-collapse-button {
    display: none;
  }

  .folder-menu-button,
  .chat-menu-button {
    opacity: 1;
  }

  .context-menu,
  .context-submenu {
    inset: auto 10px 10px 10px !important;
    width: auto;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 15px;
    box-shadow: var(--shadow-lg);
  }

  .app.sidebar-collapsed {
    display: block;
  }
}

@media (max-width: 680px) {
  .header-model-control {
    grid-template-columns: minmax(0, 150px);
  }

  .header-model-label {
    display: none;
  }

  .header-model-select {
    max-width: 150px;
  }

  .header-actions .header-text-button {
    display: none;
  }
}

@media (max-width: 470px) {
  .header-model-control {
    grid-template-columns: minmax(0, 116px);
  }

  .header-model-select {
    max-width: 116px;
    font-size: 10px;
  }
}

/* V8 — Smart Workspace */

html[data-accent="rose"] {
  --accent: #d16078;
  --accent-hover: #b94e66;
  --accent-soft: rgba(209, 96, 120, 0.14);
}

html[data-accent="blue"] {
  --accent: #4c79d8;
  --accent-hover: #3d68bd;
  --accent-soft: rgba(76, 121, 216, 0.14);
}

html[data-accent="violet"] {
  --accent: #8565d6;
  --accent-hover: #714fc4;
  --accent-soft: rgba(133, 101, 214, 0.14);
}

html[data-accent="amber"] {
  --accent: #b97a17;
  --accent-hover: #9e6510;
  --accent-soft: rgba(185, 122, 23, 0.14);
}

.library-nav {
  display: grid;
  gap: 2px;
  padding: 3px 8px 8px;
}

.library-nav-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
}

.library-nav-button:hover,
.library-nav-button.active {
  background: var(--surface-hover);
  color: var(--text);
}

.library-nav-button.active {
  box-shadow: inset 2px 0 0 var(--accent);
}

.library-count {
  min-width: 21px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--faint);
  font-size: 9px;
  text-align: center;
}

.folder-row.drop-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft);
}

.chat-list-row.dragging {
  opacity: 0.42;
}

.profile-menu {
  width: 245px;
}

.profile-menu-title {
  padding: 7px 9px 8px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-menu-item.active {
  background: var(--accent-soft);
}

.profile-menu-identity {
  display: flex;
  align-items: center;
  gap: 9px;
}

.profile-menu-avatar,
.avatar.accent-teal,
.avatar.accent-rose,
.avatar.accent-blue,
.avatar.accent-violet,
.avatar.accent-amber {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.accent-teal { background: #1f6f5f !important; }
.accent-rose { background: #d16078 !important; }
.accent-blue { background: #4c79d8 !important; }
.accent-violet { background: #8565d6 !important; }
.accent-amber { background: #b97a17 !important; }

.workspace-welcome,
.smart-home {
  width: min(100%, 860px);
  margin: auto;
}

.workspace-welcome {
  display: grid;
  place-items: center;
  padding: 50px 20px;
  text-align: center;
}

.workspace-welcome h2,
.smart-home h2 {
  margin: 0;
  color: var(--text);
  letter-spacing: -0.04em;
}

.workspace-welcome p,
.smart-home p {
  color: var(--muted);
}

.workspace-orb,
.smart-home-hero::before {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background:
    linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #0d0d0d));
  color: #fff;
  box-shadow: 0 18px 45px color-mix(in srgb, var(--accent) 24%, transparent);
  font-size: 13px;
  font-weight: 850;
}

.workspace-orb {
  margin-bottom: 18px;
}

.smart-home {
  padding: 40px 4px 30px;
}

.smart-home-hero {
  position: relative;
  padding: 8px 0 26px 76px;
}

.smart-home-hero::before {
  content: "AI";
  position: absolute;
  top: 4px;
  left: 0;
}

.smart-home-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.smart-home h2 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.04;
}

.smart-home-hero p {
  max-width: 600px;
  margin: 13px 0 0;
  font-size: 13px;
}

.smart-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.smart-action-card {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background:
    linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--surface-soft) 80%, transparent));
  color: var(--text);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.smart-action-card:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: var(--accent-soft);
  transform: translateY(-2px);
}

.smart-action-card strong {
  font-size: 14px;
}

.smart-action-card span {
  color: var(--muted);
  font-size: 11px;
}

.smart-recent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 19px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
}

.smart-recent > span {
  width: 100%;
  color: var(--faint);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.smart-recent button,
.suggested-actions button {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.smart-recent button:hover,
.suggested-actions button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.suggested-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 13px;
}

.memory-usage {
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
}

.memory-usage summary {
  width: fit-content;
  cursor: pointer;
  color: var(--faint);
}

.memory-usage[open] summary {
  color: var(--accent);
}

.memory-usage ul {
  margin: 8px 0 0;
  padding: 10px 12px 10px 27px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.version-navigator {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 11px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
}

.version-navigator button {
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
}

.version-navigator button:disabled {
  opacity: 0.3;
}

.artifact-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  width: min(42vw, 540px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: -20px 0 55px rgba(0, 0, 0, 0.22);
  animation: artifact-in 0.2s ease;
}

@keyframes artifact-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.artifact-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.artifact-panel-header strong {
  display: block;
  max-width: 420px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.artifact-preview {
  min-height: 0;
  overflow: auto;
  padding: 13px;
  background: var(--page);
}

.artifact-preview iframe,
.artifact-preview img {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
}

.artifact-generic-preview {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 30px;
  text-align: center;
}

.artifact-generic-preview > span {
  font-size: 50px;
}

.artifact-generic-preview small {
  color: var(--muted);
}

.artifact-panel-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 13px;
  border-top: 1px solid var(--border);
}

.command-backdrop {
  place-items: start center;
  padding-top: min(15vh, 130px);
}

.command-palette {
  width: min(92vw, 680px);
  max-height: min(72vh, 650px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.command-search-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.command-search-row input {
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 16px;
}

.command-search-row kbd {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--faint);
  font-size: 9px;
}

.command-filters {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.command-filter {
  padding: 5px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.command-filter.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.command-results {
  max-height: 480px;
  overflow-y: auto;
  padding: 6px;
}

.command-result {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.command-result:hover {
  background: var(--surface-hover);
}

.command-result-icon {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.command-result-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.command-result-copy strong,
.command-result-copy small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.command-result-copy strong {
  font-size: 12px;
}

.command-result-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.command-loading,
.command-empty {
  padding: 30px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.command-footer {
  padding: 8px 13px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 9px;
  text-align: right;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast-action {
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
}

@media (min-width: 1100px) {
  .app.artifact-open .chat-area {
    margin-right: min(42vw, 540px);
  }
}

@media (max-width: 900px) {
  .artifact-panel {
    width: 100%;
  }

  .smart-action-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .smart-home {
    padding-top: 22px;
  }

  .smart-home-hero {
    padding-left: 0;
    padding-top: 72px;
  }

  .smart-home-hero::before {
    top: 4px;
  }

  .artifact-panel-actions {
    grid-template-columns: 1fr;
  }
}

.memory-scope-label {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}



/* =========================================================
   FATA ATOMICA LAB V8.1
   ========================================================= */
:root {
  --app-height: 100dvh;
  --viewport-offset-top: 0px;
  --fata-pink: #d64f73;
  --fata-cream: #fff7eb;
}
html, body {
  height: var(--app-height);
  min-height: var(--app-height);
  overscroll-behavior: none;
}
body {
  position: fixed;
  inset: var(--viewport-offset-top) 0 auto 0;
  width: 100%;
  height: var(--app-height);
}
.app, .chat-area, .sidebar {
  height: var(--app-height);
  max-height: var(--app-height);
}
.sidebar {
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
}
html[data-accent="rose"] {
  --accent: #d64f73;
  --accent-hover: #bd3f63;
  --accent-soft: rgba(214, 79, 115, 0.14);
}
.login-logo {
  width: 68px;
  height: 68px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border-radius: 20px;
}
.login-logo img { width: 100%; height: 100%; display: block; }
.login-payoff { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.login-payoff span { color: var(--accent); font-weight: 700; }
.brand-mark {
  width: 31px;
  height: 31px;
  display: block;
  padding: 0;
  object-fit: cover;
  border-radius: 10px;
  background: transparent;
}
.brand-copy { min-width: 0; display: flex; flex-direction: column; }
.brand-copy small { margin-top: 1px; overflow: hidden; color: var(--faint); font-size: 8px; white-space: nowrap; text-overflow: ellipsis; }
.header-icon-button svg,
.composer-icon-button svg,
.composer-send-button svg,
.composer-stop-button svg { width: 21px; height: 21px; display: block; }
.ui-svg-icon { width: 17px; height: 17px; display: block; }
.header-model-button {
  max-width: 178px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.header-model-button:hover { border-color: var(--border); background: var(--surface); color: var(--text); }
.header-model-button svg { width: 16px; height: 16px; flex: 0 0 auto; }
.header-model-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
#currentModelLabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.model-picker-backdrop { z-index: 90; }
.model-picker-sheet { width: min(92vw, 520px); padding: 20px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-lg); }
.model-picker-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.model-picker-header h2 { margin: 0; font-size: 21px; letter-spacing: -0.03em; }
.model-picker-list { display: grid; gap: 7px; }
.model-picker-list.busy { pointer-events: none; opacity: 0.55; }
.model-choice { width: 100%; display: grid; grid-template-columns: 27px minmax(0, 1fr); align-items: start; gap: 10px; padding: 13px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); color: var(--text); text-align: left; }
.model-choice:hover, .model-choice.active { border-color: color-mix(in srgb, var(--accent) 65%, var(--border)); background: var(--accent-soft); }
.model-choice-indicator { width: 21px; height: 21px; display: grid; place-items: center; border: 1.5px solid var(--border-strong); border-radius: 50%; background: var(--surface); }
.model-choice.active .model-choice-indicator { border-color: var(--accent); }
.model-choice-check { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.model-choice-copy { min-width: 0; display: flex; flex-direction: column; }
.model-choice-copy strong { font-size: 14px; }
.model-choice-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.model-choice-copy code { margin-top: 7px; color: var(--faint); font-size: 9px; }
.model-picker-note { margin: 13px 3px 0; color: var(--faint); font-size: 10px; }
.fata-home { position: relative; isolation: isolate; padding: 28px 4px 24px; }
.fata-home::before { content: ""; position: absolute; z-index: -1; top: -80px; right: -140px; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, var(--accent-soft), transparent 67%); pointer-events: none; }
.fata-hero { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 21px; margin-bottom: 17px; }
.fata-logo-stage { position: relative; width: 86px; height: 86px; }
.fata-hero-logo { width: 86px; height: 86px; display: block; border-radius: 25px; box-shadow: 0 20px 45px color-mix(in srgb, var(--accent) 25%, transparent); }
.fata-spark { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--fata-cream); box-shadow: 0 0 18px var(--fata-cream); }
.fata-spark-one { top: -5px; right: 3px; }
.fata-spark-two { right: -9px; bottom: 14px; width: 5px; height: 5px; }
.fata-hero-copy { min-width: 0; }
.fata-hero-copy h2 { margin: 0; font-size: clamp(30px, 5vw, 48px); line-height: 1.02; letter-spacing: -0.052em; }
.fata-hero-copy p { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.fata-hero-copy p strong { color: var(--accent); }
.life-symbols { width: fit-content; display: flex; align-items: center; gap: 6px; margin: 0 0 16px 113px; padding: 5px; border: 1px solid var(--border); border-radius: 999px; background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: var(--shadow-sm); }
.life-symbols > span { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.life-symbols > span:nth-child(1) { background: rgba(133, 101, 214, 0.12); color: #8565d6; }
.life-symbols > span:nth-child(2) { background: rgba(214, 79, 115, 0.12); color: #d64f73; }
.life-symbols > span:nth-child(3) { background: rgba(76, 121, 216, 0.12); color: #4c79d8; }
.life-symbols > span:nth-child(4) { background: rgba(185, 122, 23, 0.12); color: #b97a17; }
.life-symbol-icon { width: 17px; height: 17px; }
.fata-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.fata-action-card { position: relative; min-height: 132px; justify-content: flex-start; gap: 12px; overflow: hidden; padding: 15px; }
.fata-action-card.wide { grid-column: 1 / -1; min-height: 105px; }
.fata-action-card::after { content: ""; position: absolute; right: -28px; bottom: -40px; width: 100px; height: 100px; border-radius: 50%; background: var(--accent-soft); transition: transform 0.18s ease; }
.fata-action-card:hover::after { transform: scale(1.2); }
.smart-action-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }
.smart-card-icon { width: 20px; height: 20px; }
.fata-action-card strong { position: relative; z-index: 1; max-width: 220px; font-size: 13px; line-height: 1.25; }
.smart-action-cta { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 4px; margin-top: auto; color: var(--muted); font-size: 10px; font-weight: 700; }
.smart-action-arrow { width: 14px; height: 14px; }
.message-action-icon { display: grid; place-items: center; }
.message-action-icon .ui-svg-icon { width: 15px; height: 15px; }
.attachment-icon .ui-svg-icon, .selected-file .ui-svg-icon { width: 20px; height: 20px; }
.artifact-placeholder-icon { width: 54px; height: 54px; color: var(--accent); }
@media (max-width: 900px) {
  body { position: fixed; }
  .sidebar { grid-template-rows: auto auto auto auto minmax(0, 1fr) auto; }
  .model-picker-backdrop { place-items: end center; padding: 0; }
  .model-picker-sheet { width: 100%; max-height: min(78vh, 680px); overflow-y: auto; padding: 20px 18px max(20px, env(safe-area-inset-bottom)); border-right: 0; border-bottom: 0; border-left: 0; border-radius: 24px 24px 0 0; }
  .message-form { padding-bottom: max(9px, env(safe-area-inset-bottom)); }
  .keyboard-open .composer-hint { display: none; }
}
@media (max-width: 620px) {
  .chat-header { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .chat-heading strong { font-size: 14px; }
  .header-actions { gap: 2px; }
  .header-model-button { max-width: 126px; height: 34px; padding: 0 8px; font-size: 10px; }
  .header-actions #refreshButton { width: 32px; }
  .messages { padding: 18px 13px 12px; }
  .fata-home { padding-top: 16px; }
  .fata-hero { grid-template-columns: 66px minmax(0, 1fr); gap: 14px; }
  .fata-logo-stage, .fata-hero-logo { width: 64px; height: 64px; }
  .fata-hero-logo { border-radius: 19px; }
  .fata-hero-copy h2 { font-size: clamp(27px, 8vw, 35px); }
  .fata-hero-copy p { margin-top: 8px; font-size: 12px; }
  .life-symbols { margin-left: 80px; }
  .fata-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fata-action-card { min-height: 124px; padding: 13px; }
  .fata-action-card.wide { min-height: 94px; }
  .smart-action-icon { width: 32px; height: 32px; }
  .smart-card-icon { width: 18px; height: 18px; }
  .message-form { padding-top: 6px; }
  .composer-box { min-height: 52px; padding: 5px; }
  .composer-box textarea { min-height: 40px; padding-top: 9px; font-size: 16px; }
  .composer-icon-button, .composer-send-button, .composer-stop-button { width: 38px; height: 38px; }
  .typing-status { min-height: 0; padding: 0 8px 4px; font-size: 10px; }
  .typing-status:empty { display: none; }
  .library-nav { gap: 0; }
  .library-nav-button { min-height: 36px; padding: 8px 10px; }
}
@media (max-width: 390px) {
  .header-model-button { max-width: 105px; }
  .fata-action-card { min-height: 118px; }
  .fata-action-card strong { font-size: 12px; }
  .life-symbols { margin-left: 0; }
}



/* =========================================================
   V9 — ACCOUNT PERSONALI, SPAZI PRIVATI E REASONING
   ========================================================= */

.account-login-card {
  width: min(100%, 470px);
}

.login-brand-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin-bottom: 27px;
}

.login-brand-row .login-logo {
  margin: 0;
}

.login-brand-row h1 {
  margin: 0;
}

.login-eyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.account-list {
  display: grid;
  gap: 9px;
}

.account-choice {
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.account-choice:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.account-choice-avatar,
.selected-account-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
}

.account-choice-copy,
.selected-account-summary > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.account-choice-copy small,
.selected-account-summary small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.account-choice-arrow {
  color: var(--faint);
  font-size: 22px;
}

.account-password-form {
  display: grid;
  gap: 10px;
}

.login-back-button {
  width: fit-content;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.selected-account-summary {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  margin: 3px 0 10px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

#normalLoginFields,
#setupAccountFields {
  display: grid;
  gap: 9px;
}

.setup-explanation {
  margin: 0 0 5px;
  padding: 10px 11px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.login-loading,
.login-error-box {
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.space-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin: 0 9px 7px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--sidebar-deep);
}

.space-switch-button {
  min-width: 0;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.space-switch-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.space-switch-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chat-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.space-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.space-badge.private {
  background: var(--accent-soft);
  color: var(--accent);
}

.space-badge.shared {
  background: rgba(76, 121, 216, 0.13);
  color: #4c79d8;
}

.share-confirm-modal {
  text-align: center;
}

.share-confirm-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 13px;
  border-radius: 17px;
  background: var(--accent-soft);
  color: var(--accent);
}

.share-confirm-icon svg {
  width: 27px;
  height: 27px;
}

.share-confirm-modal h2 {
  margin: 0;
}

.share-confirm-modal p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.reasoning-panel {
  margin: 0 0 12px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
  overflow: hidden;
}

.reasoning-panel summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.reasoning-panel summary::-webkit-details-marker {
  display: none;
}

.reasoning-orb {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.streaming-reasoning .reasoning-orb {
  animation: reasoning-pulse 1.2s ease-in-out infinite;
}

@keyframes reasoning-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.65; }
  50% { transform: scale(1.12); opacity: 1; }
}

.reasoning-summary-text {
  padding: 0 11px 11px 28px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 620px) {
  .login-screen {
    align-items: start;
    overflow-y: auto;
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .login-card {
    padding: 22px;
  }

  .space-switch {
    margin-bottom: 4px;
  }

  .space-switch-button {
    height: 42px;
    font-size: 11px;
  }

  .space-badge {
    display: none;
  }
}



/* V9.1 — home immediata e diagnostica */

.fata-home {
  width: min(100%, 900px);
  margin: auto;
  padding-top: 34px;
  padding-bottom: 34px;
}

.fata-hero {
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 28px;
}

.fata-logo-stage,
.fata-hero-logo {
  width: 122px;
  height: 122px;
}

.fata-hero-logo {
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  background: #111;
}

.fata-hero-copy h2 {
  max-width: 680px;
}

.fata-action-grid {
  margin-top: 22px;
}

.fata-action-card {
  min-height: 124px;
}

.inline-notice.error {
  border-color:
    color-mix(in srgb, var(--danger) 55%, var(--border));
  background:
    color-mix(in srgb, var(--danger) 7%, var(--surface));
}

.composer-box:has(textarea:disabled) {
  opacity: 0.68;
}

@media (max-width: 620px) {
  .fata-home {
    padding-top: 14px;
  }

  .fata-hero {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 14px;
  }

  .fata-logo-stage,
  .fata-hero-logo {
    width: 68px;
    height: 68px;
  }

  .fata-action-grid {
    margin-top: 15px;
  }
}



/* =========================================================
   V9.2 — DIAGNOSTICA AI + QUALITY PASS
   ========================================================= */

.chat-header {
  min-height: 66px;
  padding-inline: 20px;
  background:
    color-mix(in srgb, var(--page) 89%, transparent);
  box-shadow:
    0 1px 0 var(--border),
    0 8px 28px rgba(0, 0, 0, 0.025);
}

.header-actions {
  gap: 4px;
}

.header-diagnostics-button {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
}

.header-diagnostics-button:hover {
  border-color:
    color-mix(
      in srgb,
      var(--success) 55%,
      var(--border)
    );
  background:
    color-mix(
      in srgb,
      var(--success) 8%,
      var(--surface)
    );
  color: var(--text);
}

.header-diagnostics-button svg {
  width: 17px;
  height: 17px;
}

.diagnostics-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow:
    0 0 0 4px
    color-mix(
      in srgb,
      var(--success) 13%,
      transparent
    );
}

.messages {
  gap: 2px;
  padding-top: 38px;
}

.message {
  width: min(100%, 850px);
  padding: 20px 12px;
}

.message + .message {
  border-top-color:
    color-mix(
      in srgb,
      var(--border) 42%,
      transparent
    );
}

.message-content {
  font-size: 15.5px;
  line-height: 1.66;
}

.message-meta {
  min-height: 25px;
  align-items: center;
  margin-bottom: 9px;
}

.message-meta strong {
  font-size: 12.5px;
}

.message-verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 3px 7px;
  border: 1px solid
    color-mix(
      in srgb,
      var(--success) 32%,
      var(--border)
    );
  border-radius: 999px;
  background:
    color-mix(
      in srgb,
      var(--success) 7%,
      var(--surface)
    );
  color: var(--success);
  font-size: 8.5px;
  font-weight: 750;
}

.message-verified-icon {
  width: 12px;
  height: 12px;
}

.ai-response-details {
  width: min(100%, 650px);
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background:
    color-mix(
      in srgb,
      var(--surface-soft) 78%,
      transparent
    );
  overflow: hidden;
}

.ai-response-details summary {
  display: grid;
  grid-template-columns:
    auto
    auto
    minmax(0, 1fr)
    auto;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  font-size: 10px;
}

.ai-response-details summary::-webkit-details-marker {
  display: none;
}

.ai-response-details summary strong {
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ai-response-details summary small {
  color: var(--faint);
  font-size: 9px;
}

.ai-details-summary-icon {
  width: 15px;
  height: 15px;
  color: var(--success);
}

.ai-response-details[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.ai-response-details-body {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}

.ai-detail-row {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px;
  background: var(--surface-soft);
}

.ai-detail-row span {
  color: var(--faint);
  font-size: 8px;
  font-weight: 730;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.ai-detail-row strong,
.ai-detail-row code {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  font-weight: 630;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ai-detail-row code {
  font-family:
    "SFMono-Regular",
    Consolas,
    monospace;
}

.ai-detail-identifiers {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--faint);
  font-size: 8.5px;
}

.ai-detail-identifiers code {
  color: var(--muted);
  word-break: break-all;
}

.reasoning-panel {
  width: min(100%, 650px);
  margin: 0 0 12px;
}

.composer-context {
  width: fit-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 7px 7px;
  color: var(--muted);
  font-size: 9px;
}

.composer-context-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.composer-context-icon svg {
  width: 12px;
  height: 12px;
}

.composer-context.private
.composer-context-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.composer-context.shared
.composer-context-icon {
  background:
    color-mix(
      in srgb,
      var(--success) 12%,
      transparent
    );
  color: var(--success);
}

.composer-context span {
  color: var(--text);
  font-weight: 720;
}

.composer-context small {
  color: var(--faint);
  font-size: 9px;
}

.composer-box {
  border-radius: 20px;
}

.sidebar {
  border-right-color:
    color-mix(
      in srgb,
      var(--border) 82%,
      transparent
    );
}

.new-chat-button {
  border-radius: 11px;
}

.space-switch {
  border-radius: 12px;
}

.chat-list-row {
  min-height: 38px;
}

.chat-list-row.active {
  background:
    linear-gradient(
      90deg,
      var(--accent-soft),
      var(--surface-hover)
    );
}

/* Centro diagnostico */

.diagnostics-modal {
  width: min(94vw, 820px);
  max-height: 90vh;
  padding: 0;
}

.diagnostics-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 23px 25px 19px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.diagnostics-header h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.diagnostics-header p {
  max-width: 600px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.48;
}

.diagnostics-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 25px 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
}

.diagnostics-status.success {
  border-color:
    color-mix(
      in srgb,
      var(--success) 42%,
      var(--border)
    );
  background:
    color-mix(
      in srgb,
      var(--success) 7%,
      var(--surface-soft)
    );
  color: var(--success);
}

.diagnostics-status.warning {
  color: #b7791f;
}

.diagnostics-status.error {
  color: var(--danger);
}

.diagnostics-status-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 17px 25px;
}

.diagnostic-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(
      145deg,
      var(--surface),
      color-mix(
        in srgb,
        var(--surface-soft) 76%,
        transparent
      )
    );
  box-shadow: var(--shadow-sm);
}

.diagnostic-card-wide {
  grid-column: 1 / -1;
}

.diagnostic-card-kicker {
  color: var(--accent);
  font-size: 8.5px;
  font-weight: 780;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.diagnostic-card h3,
.diagnostic-test-panel h3 {
  margin: 5px 0 13px;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.diagnostic-value-row {
  display: grid;
  grid-template-columns:
    minmax(0, 0.8fr)
    minmax(0, 1.2fr);
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid
    color-mix(
      in srgb,
      var(--border) 70%,
      transparent
    );
}

.diagnostic-value-row:last-child {
  border-bottom: 0;
}

.diagnostic-value-row span {
  color: var(--muted);
  font-size: 10px;
}

.diagnostic-value-row strong,
.diagnostic-value-row code {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  font-weight: 670;
  text-align: right;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.diagnostic-value-row code {
  font-family:
    "SFMono-Regular",
    Consolas,
    monospace;
}

.diagnostic-empty {
  padding: 24px 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.privacy-check {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.privacy-check:last-child {
  border-bottom: 0;
}

.privacy-check-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 820;
}

.privacy-check.passed
.privacy-check-icon {
  background:
    color-mix(
      in srgb,
      var(--success) 13%,
      transparent
    );
  color: var(--success);
}

.privacy-check.failed
.privacy-check-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.privacy-check-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.privacy-check-copy strong {
  font-size: 11px;
}

.privacy-check-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}

.diagnostic-test-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 25px 17px;
  padding: 16px;
  border: 1px solid
    color-mix(
      in srgb,
      var(--accent) 38%,
      var(--border)
    );
  border-radius: 14px;
  background: var(--accent-soft);
}

.diagnostic-test-panel h3 {
  margin-bottom: 5px;
}

.diagnostic-test-panel p {
  max-width: 570px;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.diagnostic-test-panel button {
  flex: 0 0 auto;
}

.diagnostic-test-result {
  margin: 0 25px 17px;
  padding: 15px;
  border: 1px solid
    color-mix(
      in srgb,
      var(--success) 40%,
      var(--border)
    );
  border-radius: 14px;
  background:
    color-mix(
      in srgb,
      var(--success) 6%,
      var(--surface)
    );
}

.diagnostic-test-result.error {
  border-color:
    color-mix(
      in srgb,
      var(--danger) 40%,
      var(--border)
    );
  color: var(--danger);
}

.diagnostic-test-success {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr);
  gap: 11px;
  margin-bottom: 10px;
}

.diagnostic-test-success strong {
  font-size: 12px;
}

.diagnostic-test-success p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.diagnostic-test-icon {
  width: 31px;
  height: 31px;
  padding: 6px;
  border-radius: 50%;
  background:
    color-mix(
      in srgb,
      var(--success) 12%,
      transparent
    );
  color: var(--success);
}

.diagnostics-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 25px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.diagnostics-footer span {
  color: var(--faint);
  font-size: 9px;
}

@media (max-width: 820px) {
  .header-diagnostics-label {
    display: none;
  }

  .header-diagnostics-button {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .diagnostics-live-dot {
    display: none;
  }
}

@media (max-width: 620px) {
  .chat-header {
    padding-inline: 10px;
  }

  .messages {
    padding-top: 20px;
  }

  .message {
    padding-block: 16px;
  }

  .message-content {
    font-size: 14.5px;
  }

  .message-verified-badge {
    display: none;
  }

  .composer-context {
    margin-left: 5px;
  }

  .composer-context small {
    display: none;
  }

  .ai-response-details-body {
    grid-template-columns: 1fr;
  }

  .ai-detail-identifiers {
    grid-column: auto;
    flex-direction: column;
  }

  .diagnostics-modal {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }

  .diagnostics-header {
    padding:
      max(18px, env(safe-area-inset-top))
      18px
      16px;
  }

  .diagnostics-grid {
    grid-template-columns: 1fr;
    padding: 14px 15px;
  }

  .diagnostic-card-wide {
    grid-column: auto;
  }

  .diagnostics-status {
    margin-inline: 15px;
  }

  .diagnostic-test-panel {
    align-items: stretch;
    flex-direction: column;
    margin-inline: 15px;
  }

  .diagnostic-test-panel button {
    width: 100%;
  }

  .diagnostic-test-result {
    margin-inline: 15px;
  }

  .diagnostics-footer {
    padding:
      12px
      15px
      max(12px, env(safe-area-inset-bottom));
  }
}



/* =========================================================
   V10 — INTERNET E VITA REALE
   ========================================================= */

.header-web-button {
  max-width: 148px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 710;
  white-space: nowrap;
}

.header-web-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.header-web-button:hover,
.header-web-button.active {
  border-color:
    color-mix(in srgb, #4c79d8 38%, var(--border));
  background:
    color-mix(in srgb, #4c79d8 8%, var(--surface));
  color: var(--text);
}

.header-web-button.active svg {
  color: #4c79d8;
}

#currentWebLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-topbar {
  min-height: 27px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 5px;
}

.composer-context {
  margin: 0;
}

.web-once-button {
  height: 25px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--faint);
  font-size: 8.5px;
  font-weight: 730;
}

.web-once-button svg {
  width: 13px;
  height: 13px;
}

.web-once-button:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.web-once-button.active {
  border-color:
    color-mix(in srgb, #4c79d8 50%, var(--border));
  background:
    color-mix(in srgb, #4c79d8 11%, var(--surface));
  color: #4c79d8;
  box-shadow:
    0 0 0 3px
    color-mix(in srgb, #4c79d8 8%, transparent);
}

.live-web-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #4c79d8;
  font-weight: 650;
}

.live-web-status-icon {
  width: 15px;
  height: 15px;
  animation: web-pulse 1.25s ease-in-out infinite;
}

@keyframes web-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}

.web-search-activity {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 11px;
  padding: 6px 9px;
  border: 1px solid
    color-mix(in srgb, #4c79d8 35%, var(--border));
  border-radius: 999px;
  background:
    color-mix(in srgb, #4c79d8 7%, var(--surface));
  color: #4c79d8;
  font-size: 9px;
  font-weight: 700;
}

.web-search-activity-icon {
  width: 14px;
  height: 14px;
  animation: web-pulse 1.25s ease-in-out infinite;
}

.web-search-activity.completed
.web-search-activity-icon {
  animation: none;
}

.inline-citation {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  margin: 0 2px;
  padding: 0 5px;
  border: 1px solid
    color-mix(in srgb, #4c79d8 38%, var(--border));
  border-radius: 999px;
  background:
    color-mix(in srgb, #4c79d8 8%, var(--surface));
  color: #4c79d8;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  vertical-align: 0.12em;
}

.inline-citation:hover {
  background: #4c79d8;
  color: #fff;
}

.web-sources {
  width: min(100%, 680px);
  margin-top: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background:
    color-mix(in srgb, var(--surface-soft) 80%, transparent);
  overflow: hidden;
}

.web-sources summary {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  font-size: 10px;
}

.web-sources summary::-webkit-details-marker {
  display: none;
}

.web-sources summary strong {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background:
    color-mix(in srgb, #4c79d8 11%, var(--surface));
  color: #4c79d8;
  font-size: 9px;
  text-align: center;
}

.web-sources summary small {
  justify-self: end;
  color: var(--faint);
  font-size: 8.5px;
}

.web-sources-summary-icon {
  width: 15px;
  height: 15px;
  color: #4c79d8;
}

.web-sources[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.web-source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 9px;
}

.web-source-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.web-source-card:hover {
  border-color:
    color-mix(in srgb, #4c79d8 45%, var(--border));
  background:
    color-mix(in srgb, #4c79d8 5%, var(--surface));
  transform: translateY(-1px);
}

.web-source-number {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    color-mix(in srgb, #4c79d8 11%, var(--surface-soft));
  color: #4c79d8;
  font-size: 9px;
  font-weight: 820;
}

.web-source-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.web-source-copy strong,
.web-source-copy small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.web-source-copy strong {
  font-size: 10px;
  font-weight: 680;
}

.web-source-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8.5px;
}

.smart-live-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  padding: 3px 6px;
  border-radius: 999px;
  background:
    color-mix(in srgb, #4c79d8 12%, var(--surface));
  color: #4c79d8;
  font-size: 7.5px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

/* Web settings sheet */

.web-picker-backdrop {
  z-index: 92;
}

.web-picker-sheet {
  width: min(94vw, 670px);
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.web-picker-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 21px 22px 17px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.web-picker-header h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.035em;
}

.web-picker-header p {
  max-width: 520px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.web-mode-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 17px 20px 0;
}

.web-mode-choice {
  min-height: 112px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  gap: 8px 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.web-mode-choice:hover,
.web-mode-choice.active {
  border-color:
    color-mix(in srgb, #4c79d8 52%, var(--border));
  background:
    color-mix(in srgb, #4c79d8 8%, var(--surface));
}

.web-mode-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background:
    color-mix(in srgb, #4c79d8 11%, var(--surface));
  color: #4c79d8;
  font-size: 8px;
  font-weight: 850;
}

.web-mode-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.web-mode-copy strong {
  font-size: 12px;
}

.web-mode-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.web-mode-check {
  grid-column: 1 / -1;
  color: #4c79d8;
  font-size: 8px;
  font-weight: 850;
  text-align: right;
}

.web-location-section {
  margin: 14px 20px 19px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background:
    linear-gradient(
      145deg,
      var(--surface),
      color-mix(in srgb, var(--surface-soft) 75%, transparent)
    );
}

.web-location-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.web-location-heading h3 {
  margin: 3px 0 0;
  font-size: 15px;
}

.compact-button {
  padding: 7px 10px;
  font-size: 9px;
}

.web-location-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.web-location-grid label {
  margin: 0;
}

.web-location-grid label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
}

.web-location-grid input {
  height: 37px;
  font-size: 11px;
}

.web-location-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.web-picker-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

@media (max-width: 980px) {
  #currentWebLabel {
    display: none;
  }

  .header-web-button {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 620px) {
  .composer-topbar {
    padding-inline: 3px;
  }

  .web-source-list {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }

  .web-source-card {
    min-width: 240px;
    scroll-snap-align: start;
  }

  .web-picker-backdrop {
    place-items: end center;
    padding: 0;
  }

  .web-picker-sheet {
    width: 100%;
    max-height: 92dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
  }

  .web-picker-header {
    padding:
      19px
      18px
      15px;
  }

  .web-mode-list {
    grid-template-columns: 1fr;
    padding-inline: 15px;
  }

  .web-mode-choice {
    min-height: 78px;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
    align-items: center;
  }

  .web-mode-check {
    grid-column: auto;
  }

  .web-location-section {
    margin-inline: 15px;
  }

  .web-location-grid {
    grid-template-columns: 1fr;
  }

  .web-picker-footer {
    padding:
      12px
      15px
      max(12px, env(safe-area-inset-bottom));
  }

  .web-picker-footer button {
    width: 100%;
  }
}



/* =========================================================
   V10.1 — POSTI & ATTIVITÀ ATOMICHE
   ========================================================= */

body.modal-open {
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-header,
.app-mode-switch,
.sidebar-controls,
.space-switch,
.library-nav,
.folder-area,
.sidebar-footer {
  flex: 0 0 auto;
}

.chat-list {
  flex: 1 1 auto;
  min-height: 0;
}

.app-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 10px 10px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.app-mode-button {
  min-width: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 730;
}

.app-mode-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.app-mode-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.app-mode-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.atomic-only {
  display: none !important;
}

.app.atomic-mode .chat-only {
  display: none !important;
}

.app.atomic-mode .atomic-only {
  display: flex !important;
}

.app.atomic-mode #atomicWorkspace {
  display: block !important;
}

.app.atomic-mode #atomicSidebar {
  display: flex !important;
}

.app.atomic-mode #atomicHeaderActions {
  display: flex !important;
}

.atomic-sidebar {
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 0 10px 16px;
  scrollbar-width: thin;
}

.atomic-sidebar-add {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 11px;
  background:
    linear-gradient(
      135deg,
      var(--accent),
      color-mix(in srgb, var(--accent) 66%, #6e3d9e)
    );
  box-shadow:
    0 10px 24px
    color-mix(in srgb, var(--accent) 20%, transparent);
}

.atomic-sidebar-add span {
  font-size: 19px;
  font-weight: 400;
}

.atomic-sidebar-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.atomic-sidebar-search svg {
  width: 15px;
  height: 15px;
  color: var(--faint);
}

.atomic-sidebar-search input {
  min-width: 0;
  height: 37px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 10px;
}

.atomic-space-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.atomic-space-switch button {
  min-width: 0;
  height: 31px;
  padding: 0 5px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
}

.atomic-space-switch button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.atomic-sidebar-filters,
.atomic-sidebar-categories {
  display: grid;
  gap: 2px;
}

.atomic-sidebar-filters button,
.atomic-sidebar-categories button {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 9.5px;
  text-align: left;
}

.atomic-sidebar-categories button {
  justify-content: flex-start;
}

.atomic-sidebar-filters button:hover,
.atomic-sidebar-categories button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.atomic-sidebar-filters button.active,
.atomic-sidebar-categories button.active {
  border-color:
    color-mix(in srgb, var(--accent) 28%, var(--border));
  background: var(--accent-soft);
  color: var(--text);
}

.atomic-sidebar-filters strong {
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--faint);
  font-size: 8px;
  text-align: center;
}

.atomic-sidebar-label {
  margin: 6px 8px 1px;
  color: var(--faint);
  font-size: 7.5px;
  font-weight: 780;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.header-primary-button {
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  box-shadow:
    0 8px 20px
    color-mix(in srgb, var(--accent) 18%, transparent);
  font-size: 10px;
}

.atomic-decide-header {
  border-color:
    color-mix(in srgb, var(--accent) 30%, var(--border));
  background: var(--accent-soft);
  color: var(--text);
}

/* Atomic workspace */

.atomic-workspace {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  background:
    radial-gradient(
      circle at 20% 0%,
      color-mix(in srgb, var(--accent) 8%, transparent),
      transparent 33%
    ),
    radial-gradient(
      circle at 88% 15%,
      rgba(116, 87, 185, 0.08),
      transparent 28%
    ),
    var(--page);
  scrollbar-width: thin;
}

.atomic-page {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding:
    30px
    clamp(18px, 3.2vw, 42px)
    72px;
}

.atomic-hero-panel {
  position: relative;
  isolation: isolate;
  min-height: 320px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(310px, 0.9fr);
  align-items: center;
  gap: 36px;
  overflow: hidden;
  padding: clamp(28px, 4.5vw, 54px);
  border: 1px solid
    color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: 28px;
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--surface) 94%, var(--accent) 6%),
      var(--surface-soft)
    );
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.13);
}

.atomic-hero-panel::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: auto -8% -56% 36%;
  height: 340px;
  border-radius: 50%;
  background:
    radial-gradient(
      circle,
      color-mix(in srgb, var(--accent) 24%, transparent),
      transparent 68%
    );
  filter: blur(4px);
}

.atomic-eyebrow {
  display: block;
  color: var(--accent);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.atomic-hero-copy h1 {
  max-width: 680px;
  margin: 11px 0 16px;
  font-size: clamp(42px, 6vw, 74px);
  line-height: 0.95;
  letter-spacing: -0.068em;
}

.atomic-hero-copy h1 em {
  display: block;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.atomic-hero-copy p {
  max-width: 590px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.atomic-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 24px;
}

.atomic-hero-primary,
.atomic-hero-secondary {
  min-height: 45px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border-radius: 13px;
  font-size: 11px;
}

.atomic-hero-primary {
  box-shadow:
    0 12px 30px
    color-mix(in srgb, var(--accent) 24%, transparent);
}

.atomic-hero-primary span {
  font-size: 19px;
  font-weight: 400;
}

.atomic-hero-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.atomic-hero-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.atomic-action-icon {
  width: 18px;
  height: 18px;
}

.atomic-hero-visual {
  position: relative;
  min-height: 230px;
  display: grid;
  place-items: center;
}

.atomic-core {
  position: relative;
  z-index: 2;
  width: 138px;
  height: 138px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px solid
    color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 38% 28%,
      color-mix(in srgb, var(--accent) 33%, var(--surface)),
      var(--surface) 63%
    );
  box-shadow:
    0 0 0 18px
      color-mix(in srgb, var(--accent) 5%, transparent),
    0 24px 60px
      color-mix(in srgb, var(--accent) 19%, transparent);
}

.atomic-core strong {
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.06em;
}

.atomic-core span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 720;
}

.atomic-orbit {
  position: absolute;
  border: 1px dashed
    color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 50%;
  animation: atomic-spin 22s linear infinite;
}

.atomic-orbit::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 16px var(--accent);
}

.atomic-orbit-one {
  width: 205px;
  height: 205px;
}

.atomic-orbit-two {
  width: 282px;
  height: 150px;
  animation-direction: reverse;
  animation-duration: 28s;
}

@keyframes atomic-spin {
  to {
    transform: rotate(360deg);
  }
}

.atomic-float-card {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background:
    color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  font-size: 8.5px;
}

.atomic-float-card svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.atomic-float-one {
  top: 20px;
  right: 3px;
}

.atomic-float-two {
  bottom: 22px;
  left: 2px;
}

.atomic-float-three {
  right: 3px;
  bottom: 35px;
}

.atomic-stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.atomic-stat-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.atomic-stat-card:hover,
.atomic-stat-card.active {
  border-color:
    color-mix(in srgb, var(--accent) 45%, var(--border));
  background:
    color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.atomic-stat-icon {
  grid-row: 1 / 3;
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-stat-icon svg {
  width: 18px;
  height: 18px;
}

.atomic-stat-card strong {
  font-size: 18px;
  line-height: 1;
}

.atomic-stat-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.atomic-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 32px 0 13px;
}

.atomic-main-search {
  width: min(100%, 610px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.atomic-main-search svg {
  width: 18px;
  height: 18px;
  color: var(--faint);
}

.atomic-main-search input {
  height: 46px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
}

.atomic-view-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.atomic-view-copy strong {
  font-size: 10px;
}

.atomic-view-copy span {
  margin-top: 2px;
  color: var(--faint);
  font-size: 9px;
}

.atomic-category-rail {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 3px 1px 10px;
  scrollbar-width: none;
}

.atomic-category-rail::-webkit-scrollbar {
  display: none;
}

.atomic-category-chip {
  flex: 0 0 auto;
  min-height: 35px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
}

.atomic-category-chip:hover,
.atomic-category-chip.active {
  border-color:
    color-mix(in srgb, var(--accent) 44%, var(--border));
  background: var(--accent-soft);
  color: var(--text);
}

.atomic-category-chip svg {
  width: 14px;
  height: 14px;
}

.atomic-tonight-section {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid
    color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: 20px;
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--accent) 8%, var(--surface)),
      var(--surface)
    );
}

.atomic-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 15px;
}

.atomic-section-heading.compact {
  align-items: center;
}

.atomic-section-heading h2 {
  margin: 5px 0 0;
  font-size: 22px;
  letter-spacing: -0.035em;
}

.atomic-tonight-decide,
.atomic-quiet-button {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 9px;
}

.atomic-tonight-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.atomic-tonight-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
}

.atomic-card-open {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 11px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.atomic-card-open:hover {
  background: var(--surface-hover);
}

.atomic-tonight-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-tonight-icon svg {
  width: 20px;
  height: 20px;
}

.atomic-tonight-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.atomic-tonight-copy strong,
.atomic-tonight-copy small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.atomic-tonight-copy strong {
  font-size: 10px;
}

.atomic-tonight-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8.5px;
}

.atomic-mini-reactions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-top: 1px solid var(--border);
  background: var(--border);
}

.atomic-mini-reactions button {
  height: 28px;
  padding: 0;
  border-radius: 0;
  background: var(--surface-soft);
  color: var(--faint);
  font-size: 8px;
}

.atomic-mini-reactions button.active,
.atomic-mini-reactions button:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.atomic-library-section {
  margin-top: 34px;
}

.atomic-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.atomic-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow:
    0 13px 36px rgba(0, 0, 0, 0.065);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.atomic-card:hover {
  transform: translateY(-3px);
  border-color:
    color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow:
    0 18px 45px rgba(0, 0, 0, 0.11);
}

.atomic-card-visual {
  position: relative;
  width: 100%;
  height: 126px;
  display: block;
  overflow: hidden;
  padding: 0;
  border-radius: 0;
  background:
    radial-gradient(
      circle at 68% 28%,
      rgba(255, 255, 255, 0.16),
      transparent 24%
    ),
    linear-gradient(
      135deg,
      var(--atomic-tone-one, #7050a5),
      var(--atomic-tone-two, #2f2541)
    );
  color: rgba(255, 255, 255, 0.92);
}

.atomic-card-visual:hover {
  filter: brightness(1.05);
}

.atomic-card-orbit {
  position: absolute;
  top: -48px;
  right: -34px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(255, 255, 255, 0.19);
  border-radius: 50%;
}

.atomic-card-orbit::after {
  content: "";
  position: absolute;
  right: 17px;
  bottom: 18px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.4);
}

.atomic-card-category-icon {
  position: absolute;
  left: 17px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.19);
  border-radius: 15px;
  background: rgba(18, 15, 19, 0.2);
  backdrop-filter: blur(8px);
}

.atomic-card-main-icon {
  width: 27px;
  height: 27px;
}

.atomic-card-type,
.atomic-card-tonight {
  position: absolute;
  top: 13px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.19);
  border-radius: 999px;
  background: rgba(15, 13, 17, 0.22);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 7.5px;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.atomic-card-type {
  left: 13px;
}

.atomic-card-tonight {
  right: 13px;
}

.atomic-card-body {
  padding: 15px;
}

.atomic-card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.atomic-card-title-row > div {
  min-width: 0;
}

.atomic-card-title-row span {
  color: var(--accent);
  font-size: 7.5px;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.atomic-card-title-row h3 {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.atomic-card-favorite {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--faint);
}

.atomic-card-favorite svg {
  width: 15px;
  height: 15px;
}

.atomic-card-favorite.active {
  border-color:
    color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-card-description {
  min-height: 44px;
  margin: 11px 0 10px;
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.5;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.atomic-card-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 23px;
}

.atomic-card-facts > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 7.5px;
}

.atomic-card-facts svg {
  width: 11px;
  height: 11px;
}

.atomic-status.status-favorite {
  color: var(--accent);
}

.atomic-status.status-done {
  color: var(--success);
}

.atomic-status.status-discarded {
  color: var(--danger);
}

.atomic-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 9px;
}

.atomic-card-tags span,
.atomic-detail-tags span {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--faint);
  font-size: 7.5px;
}

.atomic-card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.atomic-card-people {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.atomic-card-people span,
.atomic-card-people small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.atomic-card-people span {
  color: var(--muted);
  font-size: 7.5px;
}

.atomic-card-people small {
  max-width: 155px;
  margin-top: 3px;
  color: var(--faint);
  font-size: 7px;
}

.atomic-card-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.atomic-card-actions a,
.atomic-card-actions button {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
}

.atomic-card-actions a:hover,
.atomic-card-actions button:hover,
.atomic-card-actions button.active {
  border-color:
    color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-card-actions svg {
  width: 14px;
  height: 14px;
}

.tone-coral {
  --atomic-tone-one: #bc5260;
  --atomic-tone-two: #5c2531;
}

.tone-violet {
  --atomic-tone-one: #7663a9;
  --atomic-tone-two: #302745;
}

.tone-blue {
  --atomic-tone-one: #466d9a;
  --atomic-tone-two: #21354e;
}

.tone-green {
  --atomic-tone-one: #577d64;
  --atomic-tone-two: #263b2d;
}

.tone-sand {
  --atomic-tone-one: #a67b51;
  --atomic-tone-two: #4a3527;
}

.tone-cyan {
  --atomic-tone-one: #3d8490;
  --atomic-tone-two: #1f4148;
}

.tone-amber {
  --atomic-tone-one: #b37c28;
  --atomic-tone-two: #563b19;
}

.tone-stone {
  --atomic-tone-one: #756d66;
  --atomic-tone-two: #332f2c;
}

.tone-pink {
  --atomic-tone-one: #ad5e8f;
  --atomic-tone-two: #4d2941;
}

.tone-rose {
  --atomic-tone-one: #b44d6e;
  --atomic-tone-two: #562438;
}

.tone-lime {
  --atomic-tone-one: #788d4c;
  --atomic-tone-two: #374222;
}

.tone-purple {
  --atomic-tone-one: #80539d;
  --atomic-tone-two: #392447;
}

.tone-atomic {
  --atomic-tone-one: #c0625d;
  --atomic-tone-two: #65304b;
}

.tone-neutral {
  --atomic-tone-one: #697079;
  --atomic-tone-two: #30343a;
}

.atomic-empty-collection,
.atomic-empty-state {
  min-height: 270px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 36px;
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
}

.atomic-empty-orbit,
.atomic-empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 13px;
  padding: 13px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-empty-collection h3,
.atomic-empty-state h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.atomic-empty-collection p,
.atomic-empty-state p {
  max-width: 430px;
  margin: 8px 0 16px;
  font-size: 10px;
  line-height: 1.5;
}

.atomic-loading-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.atomic-loading-orbit {
  width: 42px;
  height: 42px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: atomic-spin 0.9s linear infinite;
}

.atomic-closing-note {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  max-width: 640px;
  margin: 42px auto 0;
  color: var(--muted);
}

.atomic-closing-note > div {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-closing-icon {
  width: 23px;
  height: 23px;
}

.atomic-closing-note p {
  margin: 0;
  font-size: 10px;
  line-height: 1.55;
}

/* Smart home Atomiche entry */

.smart-atomic-entry {
  width: 100%;
  display: grid;
  grid-template-columns: 39px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 11px;
  padding: 12px 14px;
  border: 1px solid
    color-mix(in srgb, var(--accent) 27%, var(--border));
  border-radius: 14px;
  background:
    linear-gradient(
      105deg,
      var(--accent-soft),
      var(--surface)
    );
  color: var(--text);
  text-align: left;
}

.smart-atomic-entry:hover {
  border-color: var(--accent);
  background:
    linear-gradient(
      105deg,
      color-mix(in srgb, var(--accent) 17%, transparent),
      var(--surface)
    );
}

.smart-atomic-entry-icon {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
}

.smart-atomic-icon {
  width: 21px;
  height: 21px;
}

.smart-atomic-entry-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.smart-atomic-entry-copy small {
  color: var(--accent);
  font-size: 8px;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.smart-atomic-entry-copy strong {
  margin-top: 3px;
  font-size: 10.5px;
}

.smart-atomic-arrow {
  width: 17px;
  height: 17px;
  color: var(--accent);
}

/* Atomic modals */

.atomic-modal-backdrop {
  z-index: 95;
}

.atomic-sheet {
  width: min(94vw, 780px);
  max-height: min(90vh, 900px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.atomic-add-sheet {
  grid-template-rows: auto minmax(0, 1fr);
}

.atomic-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 23px 17px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.atomic-sheet-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.035em;
}

.atomic-sheet-header p {
  max-width: 590px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.atomic-add-body,
.atomic-detail-body,
.atomic-decide-body {
  min-height: 0;
  overflow-y: auto;
}

.atomic-add-body {
  padding: 19px 23px 25px;
}

.atomic-capture {
  padding: 14px;
  border: 1px solid
    color-mix(in srgb, var(--accent) 27%, var(--border));
  border-radius: 16px;
  background:
    linear-gradient(
      140deg,
      var(--accent-soft),
      var(--surface-soft)
    );
}

.atomic-capture textarea {
  min-height: 92px;
  resize: vertical;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 14px;
  line-height: 1.5;
}

.atomic-capture-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 8px;
}

.atomic-magic-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.atomic-magic-button span {
  font-size: 17px;
}

.atomic-preview-status {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9.5px;
}

.atomic-preview-status.loading {
  color: var(--accent);
}

.atomic-preview-status.success {
  color: var(--success);
}

.atomic-preview-status.error {
  color: var(--danger);
}

.atomic-item-form {
  display: grid;
  gap: 15px;
  margin-top: 17px;
}

.atomic-form-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 15px;
}

.atomic-title-field {
  min-width: 0;
}

.atomic-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.atomic-visibility-toggle > span {
  display: block;
  margin-bottom: 7px;
  font-size: 10px;
  font-weight: 690;
}

.atomic-visibility-toggle > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.atomic-visibility-toggle button {
  min-width: 92px;
  height: 34px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
}

.atomic-visibility-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.atomic-shortlist-check {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
}

.atomic-shortlist-check input {
  width: 17px;
  height: 17px;
  padding: 0;
  accent-color: var(--accent);
}

.atomic-form-footer,
.atomic-detail-footer,
.atomic-decide-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 23px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.atomic-form-footer span {
  max-width: 60%;
  color: var(--faint);
  font-size: 8px;
}

.atomic-detail-cover {
  position: relative;
  height: 175px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(
      circle at 64% 28%,
      rgba(255, 255, 255, 0.18),
      transparent 23%
    ),
    linear-gradient(
      135deg,
      var(--atomic-tone-one, #7050a5),
      var(--atomic-tone-two, #2f2541)
    );
  color: #ffffff;
}

.atomic-detail-cover::before,
.atomic-detail-cover::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
}

.atomic-detail-cover::before {
  width: 250px;
  height: 250px;
}

.atomic-detail-cover::after {
  width: 350px;
  height: 160px;
  transform: rotate(-12deg);
}

.atomic-detail-cover-icon {
  position: relative;
  z-index: 2;
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 24px;
  background: rgba(12, 10, 14, 0.19);
  backdrop-filter: blur(10px);
}

.atomic-detail-main-icon {
  width: 47px;
  height: 47px;
}

.atomic-detail-statuses {
  position: absolute;
  z-index: 3;
  top: 13px;
  left: 13px;
  display: flex;
  gap: 5px;
}

.atomic-detail-statuses span {
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(15, 13, 17, 0.22);
  color: #ffffff;
  font-size: 7.5px;
  backdrop-filter: blur(8px);
}

.atomic-detail-content {
  display: grid;
  gap: 18px;
  padding: 21px 23px 28px;
}

.atomic-detail-content section {
  min-width: 0;
}

.atomic-detail-label {
  display: block;
  margin-bottom: 6px;
  color: var(--faint);
  font-size: 8px;
  font-weight: 770;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.atomic-detail-content p {
  margin: 0;
  color: var(--text);
  font-size: 11px;
  line-height: 1.55;
}

.atomic-personal-note {
  padding: 13px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--accent-soft);
}

.atomic-detail-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.atomic-detail-actions-grid a,
.atomic-detail-actions-grid button {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 9px;
  text-decoration: none;
}

.atomic-detail-actions-grid a:hover,
.atomic-detail-actions-grid button:hover,
.atomic-detail-actions-grid button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.atomic-detail-actions-grid svg {
  width: 16px;
  height: 16px;
}

.atomic-detail-reactions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.atomic-detail-reactions button {
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9px;
}

.atomic-detail-reactions button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.atomic-other-reaction {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 8.5px;
}

.atomic-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.atomic-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 8px;
}

.atomic-detail-meta a {
  color: var(--accent);
}

.atomic-detail-footer > div {
  display: flex;
  gap: 7px;
}

.atomic-decide-sheet {
  width: min(94vw, 650px);
}

.atomic-decide-body {
  display: grid;
  gap: 15px;
  padding: 20px 23px 25px;
}

.atomic-decide-footer span {
  max-width: 60%;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.4;
}

/* Settings modal: actual header/body/footer layout */

.settings-modal {
  height: min(88vh, 860px);
  max-height: min(88vh, 860px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.settings-modal-header {
  position: relative;
  top: auto;
}

.settings-scroll-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.settings-footer {
  position: relative;
  bottom: auto;
  z-index: 2;
  margin: 0;
}

.modal-backdrop {
  overscroll-behavior: contain;
}

/* Mobile contextual navigation */

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 1040px) {
  .atomic-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .atomic-tonight-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-mode-switch {
    margin-top: 2px;
  }

  .atomic-page {
    padding-bottom:
      calc(92px + env(safe-area-inset-bottom));
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 75;
    right: 14px;
    bottom:
      max(12px, env(safe-area-inset-bottom));
    left: 14px;
    height: 62px;
    display: grid;
    grid-template-columns: 1fr 62px 1fr;
    align-items: center;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background:
      color-mix(in srgb, var(--surface) 91%, transparent);
    box-shadow:
      0 18px 55px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav > button {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    border-radius: 15px;
    background: transparent;
    color: var(--faint);
    font-size: 7px;
  }

  .mobile-bottom-nav > button.active {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .mobile-bottom-nav svg {
    width: 19px;
    height: 19px;
  }

  .mobile-bottom-nav
  .mobile-primary-action {
    width: 50px;
    height: 50px;
    justify-self: center;
    transform: translateY(-13px);
    border: 5px solid var(--page);
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    box-shadow:
      0 12px 26px
      color-mix(in srgb, var(--accent) 30%, transparent);
    font-size: 24px;
  }

  .message-form {
    padding-bottom:
      calc(82px + env(safe-area-inset-bottom));
  }

  .atomic-hero-panel {
    grid-template-columns: 1fr;
  }

  .atomic-hero-visual {
    display: none;
  }

  .atomic-stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .atomic-page {
    padding:
      14px
      12px
      calc(92px + env(safe-area-inset-bottom));
  }

  .atomic-hero-panel {
    min-height: 0;
    padding: 24px 19px;
    border-radius: 21px;
  }

  .atomic-hero-copy h1 {
    font-size: clamp(38px, 13vw, 54px);
  }

  .atomic-hero-copy p {
    font-size: 11px;
  }

  .atomic-hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .atomic-hero-primary,
  .atomic-hero-secondary {
    width: 100%;
  }

  .atomic-toolbar {
    align-items: stretch;
    flex-direction: column;
    margin-top: 22px;
  }

  .atomic-view-copy {
    display: none;
  }

  .atomic-main-search {
    width: 100%;
  }

  .atomic-tonight-section {
    padding: 15px;
    border-radius: 16px;
  }

  .atomic-section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .atomic-section-heading h2 {
    font-size: 19px;
  }

  .atomic-tonight-decide,
  .atomic-quiet-button {
    width: 100%;
  }

  .atomic-tonight-rail,
  .atomic-card-grid {
    grid-template-columns: 1fr;
  }

  .atomic-card-visual {
    height: 112px;
  }

  .atomic-card {
    border-radius: 16px;
  }

  .atomic-form-grid,
  .atomic-form-topline {
    grid-template-columns: 1fr;
  }

  .atomic-visibility-toggle button {
    min-width: 0;
  }

  .atomic-capture-actions {
    flex-direction: column;
  }

  .atomic-capture-actions button {
    width: 100%;
  }

  .atomic-sheet {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .atomic-sheet-header {
    padding:
      max(18px, env(safe-area-inset-top))
      17px
      15px;
  }

  .atomic-add-body,
  .atomic-detail-content,
  .atomic-decide-body {
    padding-right: 17px;
    padding-left: 17px;
  }

  .atomic-form-footer,
  .atomic-detail-footer,
  .atomic-decide-footer {
    padding:
      12px
      17px
      max(12px, env(safe-area-inset-bottom));
  }

  .atomic-form-footer,
  .atomic-decide-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .atomic-form-footer span,
  .atomic-decide-footer span {
    max-width: 100%;
  }

  .atomic-form-footer button,
  .atomic-decide-footer button {
    width: 100%;
  }

  .atomic-detail-actions-grid {
    grid-template-columns: 1fr;
  }

  .settings-modal {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

/* Collapsed sidebar should stay understandable */

.app.sidebar-collapsed .app-mode-switch {
  grid-template-columns: 1fr;
  margin-inline: 7px;
}

.app.sidebar-collapsed .app-mode-button span,
.app.sidebar-collapsed .atomic-sidebar-search,
.app.sidebar-collapsed .atomic-space-switch,
.app.sidebar-collapsed .atomic-sidebar-filters span,
.app.sidebar-collapsed .atomic-sidebar-filters strong,
.app.sidebar-collapsed .atomic-sidebar-label,
.app.sidebar-collapsed .atomic-sidebar-categories,
.app.sidebar-collapsed .atomic-sidebar-add strong {
  display: none;
}

.app.sidebar-collapsed .atomic-sidebar {
  padding-inline: 7px;
}

.app.sidebar-collapsed .atomic-sidebar-add {
  min-width: 42px;
  width: 42px;
  align-self: center;
}



/* V10.1 — collapsed sidebar: keep Atomiche readable */
.app.sidebar-collapsed .atomic-sidebar-search,
.app.sidebar-collapsed .atomic-space-switch,
.app.sidebar-collapsed .atomic-sidebar-filters,
.app.sidebar-collapsed .atomic-sidebar-label,
.app.sidebar-collapsed .atomic-sidebar-categories {
  display: none;
}

.app.sidebar-collapsed .atomic-add-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
}

.app.sidebar-collapsed .atomic-add-button span:not(.atomic-add-icon) {
  display: none;
}



/* =========================================================
   V10.2 — SMART ATOMICHE
   ========================================================= */

.atomic-stat-strip {
  grid-template-columns:
    repeat(5, minmax(0, 1fr));
}

.atomic-card-shortlist-badges {
  position: absolute;
  top: 13px;
  right: 13px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.atomic-card-tonight,
.atomic-card-weekend,
.atomic-detail-weekend {
  position: static;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 3px 7px;
  border: 1px solid
    rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.atomic-card-tonight,
.atomic-detail-tonight {
  background:
    rgba(184, 108, 17, 0.82);
}

.atomic-card-weekend,
.atomic-detail-weekend {
  background:
    rgba(64, 93, 159, 0.84);
}

.atomic-weekend-section {
  border-color:
    color-mix(
      in srgb,
      #5374c6 40%,
      var(--border)
    );
}

.atomic-card-actions {
  flex-wrap: wrap;
}

.atomic-card-done.active {
  border-color:
    color-mix(
      in srgb,
      var(--success) 65%,
      var(--border)
    );
  background:
    color-mix(
      in srgb,
      var(--success) 14%,
      var(--surface)
    );
  color: var(--success);
}

.atomic-practical-form {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
}

.atomic-practical-form summary {
  padding: 12px 13px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  list-style: none;
}

.atomic-practical-form summary::-webkit-details-marker {
  display: none;
}

.atomic-practical-form[open] summary {
  border-bottom: 1px solid var(--border);
}

.atomic-practical-form .atomic-form-grid {
  padding: 13px;
}

.atomic-form-shortlists,
.atomic-decide-shortlists {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.atomic-form-shortlists .atomic-shortlist-check,
.atomic-decide-shortlists .atomic-shortlist-check {
  flex: 1 1 220px;
}

.atomic-practical-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px;
  border: 1px solid
    color-mix(
      in srgb,
      var(--accent) 28%,
      var(--border)
    );
  border-radius: 15px;
  background:
    linear-gradient(
      145deg,
      var(--surface-soft),
      color-mix(
        in srgb,
        var(--accent) 5%,
        var(--surface)
      )
    );
}

.atomic-practical-card-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.atomic-practical-card-copy strong {
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.4;
}

.atomic-practical-card-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.atomic-practical-card-copy p,
.atomic-practical-card-copy a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.atomic-practical-card-copy svg {
  width: 15px;
  height: 15px;
}

.atomic-practical-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.atomic-practical-card-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 37px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
}

.atomic-note-editor {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    auto;
  gap: 9px;
}

.atomic-note-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.atomic-note-heading small {
  color: var(--muted);
  font-size: 9px;
}

.atomic-note-editor textarea {
  min-height: 63px;
  resize: vertical;
}

.atomic-note-editor button {
  align-self: end;
  min-height: 39px;
}

.atomic-import-sheet {
  width: min(94vw, 880px);
  max-height: 92vh;
  overflow: hidden;
}

.atomic-import-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.atomic-import-status {
  margin: 15px 20px 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
}

.atomic-import-status.loading {
  color: var(--accent);
}

.atomic-import-status.success {
  border-color:
    color-mix(
      in srgb,
      var(--success) 40%,
      var(--border)
    );
  color: var(--success);
}

.atomic-import-status.error {
  border-color:
    color-mix(
      in srgb,
      var(--danger) 40%,
      var(--border)
    );
  color: var(--danger);
}

.atomic-import-list {
  min-height: 180px;
  max-height: min(62vh, 640px);
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding: 14px 20px 20px;
}

.atomic-import-card {
  position: relative;
  display: grid;
  grid-template-columns:
    28px
    43px
    minmax(0, 1fr);
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background:
    linear-gradient(
      145deg,
      var(--surface),
      var(--surface-soft)
    );
  opacity: 0.62;
  transition:
    opacity 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.atomic-import-card.selected {
  border-color:
    color-mix(
      in srgb,
      var(--accent) 60%,
      var(--border)
    );
  opacity: 1;
}

.atomic-import-card:hover {
  transform: translateY(-1px);
}

.atomic-import-select input {
  position: absolute;
  opacity: 0;
}

.atomic-import-select span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
}

.atomic-import-select input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
}

.atomic-import-select input:checked + span::after {
  content: "";
  width: 8px;
  height: 4px;
  border-bottom: 2px solid #fff;
  border-left: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.atomic-import-icon {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-import-icon svg {
  width: 22px;
  height: 22px;
}

.atomic-import-copy {
  min-width: 0;
}

.atomic-import-kicker {
  color: var(--accent);
  font-size: 8px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.atomic-import-copy h3 {
  margin: 4px 0 0;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.atomic-import-copy > p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.48;
}

.atomic-import-address {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--text) !important;
  font-weight: 680;
}

.atomic-import-address svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.atomic-import-practical {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.atomic-import-practical span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 8.5px;
}

.atomic-import-practical svg {
  width: 12px;
  height: 12px;
}

.atomic-import-note {
  display: block;
  margin-top: 10px;
}

.atomic-import-note span {
  display: block;
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 8px;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.atomic-import-note textarea {
  min-height: 54px;
  font-size: 10px;
}

.atomic-import-shortlists {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.atomic-import-shortlists label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
}

.atomic-import-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding:
    14px
    20px
    max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.atomic-import-footer span {
  color: var(--muted);
  font-size: 10px;
}

.message-action-button[aria-label="Porta nelle Atomiche"] {
  border-color:
    color-mix(
      in srgb,
      var(--accent) 38%,
      var(--border)
    );
  background:
    color-mix(
      in srgb,
      var(--accent) 7%,
      transparent
    );
}

@media (max-width: 920px) {
  .atomic-stat-strip {
    grid-template-columns:
      repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .atomic-stat-strip {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .atomic-practical-card {
    align-items: stretch;
    flex-direction: column;
  }

  .atomic-practical-card-actions {
    justify-content: stretch;
  }

  .atomic-practical-card-actions a {
    flex: 1 1 auto;
    justify-content: center;
  }

  .atomic-note-editor {
    grid-template-columns: 1fr;
  }

  .atomic-note-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .atomic-import-sheet {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .atomic-import-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding-inline: 15px;
  }

  .atomic-import-list {
    max-height: none;
    padding-inline: 15px;
  }

  .atomic-import-card {
    grid-template-columns:
      25px
      38px
      minmax(0, 1fr);
    padding: 12px;
  }

  .atomic-import-icon {
    width: 38px;
    height: 38px;
  }

  .atomic-import-footer {
    padding-inline: 15px;
  }
}



/* =========================================================
   V10.3 — ATOMICHE VIVE
   ========================================================= */

.atomic-priority-boards {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-top: 14px;
}

.atomic-priority-boards
.atomic-tonight-section {
  min-width: 0;
  margin: 0;
  padding: 17px;
  border-width: 1px;
  border-radius: 18px;
}

.atomic-board-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.atomic-board-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(16px, 1.45vw, 21px);
  letter-spacing: -0.035em;
}

.atomic-board-count {
  min-width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border: 1px solid
    color-mix(
      in srgb,
      var(--accent) 35%,
      var(--border)
    );
  border-radius: 50%;
  background:
    color-mix(
      in srgb,
      var(--accent) 9%,
      var(--surface)
    );
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.atomic-board-empty {
  width: 100%;
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px dashed
    color-mix(
      in srgb,
      var(--border-strong) 72%,
      transparent
    );
  border-radius: 14px;
  background:
    color-mix(
      in srgb,
      var(--surface-soft) 76%,
      transparent
    );
  color: var(--muted);
  text-align: left;
}

.atomic-board-empty:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.atomic-board-empty > svg {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  color: var(--accent);
}

.atomic-board-empty span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.atomic-board-empty strong {
  color: var(--text);
  font-size: 11px;
}

.atomic-board-empty small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.atomic-board-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
}

.atomic-board-actions button {
  min-height: 34px;
}

.atomic-priority-boards
.atomic-tonight-rail {
  min-height: 112px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns:
    minmax(230px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 3px;
  scroll-snap-type: x proximity;
}

.atomic-priority-boards
.atomic-tonight-card {
  min-width: 0;
  scroll-snap-align: start;
}

.atomic-tonight-copy {
  min-width: 0;
}

.atomic-tonight-copy
.atomic-rating-badge {
  margin-top: 5px;
}

.atomic-category-rail {
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.atomic-category-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

/* Rating */

.atomic-rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 25px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  white-space: nowrap;
}

.atomic-rating-badge svg {
  width: 13px;
  height: 13px;
  color: var(--accent);
}

.atomic-rating-badge strong {
  color: var(--text);
  font-size: 10px;
  font-weight: 820;
}

.atomic-rating-badge small {
  color: var(--faint);
  font-size: 8px;
  font-weight: 720;
  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.atomic-rating-badge.has-rating {
  border-color:
    color-mix(
      in srgb,
      var(--accent) 45%,
      var(--border)
    );
  background:
    color-mix(
      in srgb,
      var(--accent) 8%,
      var(--surface)
    );
}

.atomic-rating-badge.compact {
  width: fit-content;
  min-height: 21px;
  padding: 2px 6px;
  background:
    color-mix(
      in srgb,
      var(--surface) 80%,
      transparent
    );
}

.atomic-card-title-row {
  align-items: flex-start;
  gap: 8px;
}

.atomic-card-title-row
.atomic-rating-badge {
  margin-left: auto;
}

.atomic-card-title-row
.atomic-card-favorite {
  flex: 0 0 auto;
}

.atomic-rating-panel {
  padding: 15px;
  border: 1px solid
    color-mix(
      in srgb,
      var(--accent) 26%,
      var(--border)
    );
  border-radius: 15px;
  background:
    linear-gradient(
      145deg,
      var(--surface-soft),
      color-mix(
        in srgb,
        var(--accent) 4%,
        var(--surface)
      )
    );
}

.atomic-rating-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.atomic-rating-heading > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.atomic-rating-heading small,
.atomic-rating-mine {
  color: var(--muted);
  font-size: 9px;
}

.atomic-rating-mine {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.atomic-rating-buttons {
  display: grid;
  grid-template-columns:
    repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.atomic-rating-buttons button {
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--faint);
}

.atomic-rating-buttons button svg {
  width: 19px;
  height: 19px;
}

.atomic-rating-buttons button:hover,
.atomic-rating-buttons button.active {
  border-color:
    color-mix(
      in srgb,
      var(--accent) 60%,
      var(--border)
    );
  background: var(--accent-soft);
  color: var(--accent);
}

/* Importazione progressiva */

.atomic-import-progress-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.atomic-import-progress-head > div {
  min-width: 0;
}

.atomic-import-progress-head strong {
  display: block;
  color: var(--text);
  font-size: 11px;
}

.atomic-import-progress-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}

.atomic-import-spinner {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  border: 2px solid
    color-mix(
      in srgb,
      var(--accent) 20%,
      transparent
    );
  border-top-color: var(--accent);
  border-radius: 50%;
  animation:
    atomic-import-spin 0.8s linear infinite;
}

@keyframes atomic-import-spin {
  to {
    transform: rotate(360deg);
  }
}

.atomic-import-steps {
  display: grid;
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.atomic-import-steps > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--faint);
}

.atomic-import-steps > div span {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--surface-soft);
  font-size: 8px;
  font-weight: 820;
}

.atomic-import-steps > div small {
  min-width: 0;
  overflow: hidden;
  font-size: 8px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.atomic-import-steps > div.active {
  border-color:
    color-mix(
      in srgb,
      var(--accent) 50%,
      var(--border)
    );
  color: var(--accent);
}

.atomic-import-steps > div.done {
  border-color:
    color-mix(
      in srgb,
      var(--success) 38%,
      var(--border)
    );
  color: var(--success);
}

.atomic-import-slow-note {
  margin-top: 9px;
  padding: 7px 9px;
  border-radius: 8px;
  background:
    color-mix(
      in srgb,
      var(--accent) 8%,
      transparent
    );
  color: var(--muted);
  font-size: 8.5px;
}

.atomic-import-found-count {
  margin-top: 8px;
  color: var(--success);
  font-size: 9px;
  font-weight: 750;
}

.atomic-import-skeleton-grid {
  display: grid;
  gap: 10px;
}

.atomic-import-skeleton {
  display: grid;
  grid-template-columns:
    44px minmax(0, 1fr);
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
}

.atomic-import-skeleton > span {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background:
    linear-gradient(
      90deg,
      var(--surface),
      var(--surface-hover),
      var(--surface)
    );
  background-size: 220% 100%;
  animation:
    atomic-skeleton 1.25s ease infinite;
}

.atomic-import-skeleton > div {
  display: grid;
  gap: 7px;
}

.atomic-import-skeleton i {
  height: 9px;
  display: block;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      var(--surface),
      var(--surface-hover),
      var(--surface)
    );
  background-size: 220% 100%;
  animation:
    atomic-skeleton 1.25s ease infinite;
}

.atomic-import-skeleton i:nth-child(1) {
  width: 44%;
}

.atomic-import-skeleton i:nth-child(2) {
  width: 76%;
}

.atomic-import-skeleton i:nth-child(3) {
  width: 59%;
}

@keyframes atomic-skeleton {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

.atomic-import-error-state {
  min-height: 190px;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.atomic-import-error-state strong {
  color: var(--text);
  font-size: 14px;
}

.atomic-import-error-state p {
  max-width: 440px;
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
}

.atomic-import-footer-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.atomic-import-footer-copy small {
  color: var(--faint);
  font-size: 9px;
}

.atomic-import-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Menu secondario dei messaggi */

.message-more-actions {
  position: relative;
}

.message-more-actions summary {
  width: 29px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}

.message-more-actions summary::-webkit-details-marker {
  display: none;
}

.message-more-actions summary:hover,
.message-more-actions[open] summary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.message-more-actions summary svg {
  width: 15px;
  height: 15px;
}

.message-more-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 7px);
  z-index: 40;
  width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.message-more-menu button {
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 10px;
  text-align: left;
}

.message-more-menu button:hover {
  background: var(--surface-hover);
}

@media (max-width: 860px) {
  .atomic-priority-boards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .atomic-priority-boards {
    gap: 9px;
    margin-top: 10px;
  }

  .atomic-priority-boards
  .atomic-tonight-section {
    padding: 14px;
  }

  .atomic-priority-boards
  .atomic-tonight-rail {
    grid-auto-columns: 82%;
  }

  .atomic-board-heading h2 {
    font-size: 17px;
  }

  .atomic-card-title-row {
    flex-wrap: wrap;
  }

  .atomic-card-title-row
  .atomic-rating-badge {
    order: 3;
    margin-left: 0;
  }

  .atomic-import-steps {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .atomic-import-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .atomic-import-footer-actions {
    width: 100%;
  }

  .atomic-import-footer-actions button {
    flex: 1 1 0;
  }
}

/* =========================================================
   V10.4 — DECIDI E VAI
   ========================================================= */

.atomic-toolbar-sticky {
  position: sticky;
  top: 0;
  z-index: 32;
  display: grid;
  grid-template-columns:
    minmax(240px, 1.7fr)
    minmax(150px, 0.72fr)
    auto
    auto
    auto;
  align-items: center;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    color-mix(
      in srgb,
      var(--surface) 93%,
      transparent
    );
  box-shadow: 0 13px 34px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(18px);
}

.atomic-sort-control {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.atomic-sort-control span {
  color: var(--faint);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.atomic-sort-control select {
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  outline: none;
}

.atomic-view-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.atomic-view-switch button {
  min-width: 38px;
  min-height: 35px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 720;
}

.atomic-view-switch button svg {
  width: 15px;
  height: 15px;
}

.atomic-view-switch button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 4px 13px rgba(0, 0, 0, 0.1);
}

.atomic-selection-toggle {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
}

.atomic-selection-toggle svg {
  width: 15px;
  height: 15px;
}

.atomic-selection-toggle.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-bulk-bar {
  position: sticky;
  top: 73px;
  z-index: 31;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.atomic-bulk-bar > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 7px;
  white-space: nowrap;
}

.atomic-bulk-bar > div:first-child strong {
  color: var(--accent);
  font-size: 18px;
}

.atomic-bulk-bar > div:first-child span {
  color: var(--muted);
  font-size: 9px;
}

.atomic-bulk-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.atomic-bulk-actions button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 9px;
  font-weight: 720;
}

.atomic-bulk-actions button svg {
  width: 13px;
  height: 13px;
}

.atomic-bulk-actions button.danger {
  color: var(--danger);
}

.atomic-bulk-actions button:disabled {
  opacity: 0.38;
}

.atomic-card {
  position: relative;
}

.atomic-card.selected,
.atomic-list-row:has(.atomic-select-checkbox input:checked) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.atomic-card-select {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 8;
}

.atomic-select-checkbox {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.atomic-select-checkbox input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.atomic-select-checkbox span {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.15);
}

.atomic-select-checkbox input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
}

.atomic-select-checkbox input:checked + span::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}


/* Lista */

.atomic-list-view {
  display: grid;
  gap: 8px;
}

.atomic-list-row {
  display: grid;
  grid-template-columns:
    auto
    minmax(0, 1fr)
    auto
    auto;
  align-items: center;
  gap: 11px;
  min-height: 76px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(
      135deg,
      var(--surface),
      var(--surface-soft)
    );
}

.atomic-list-open {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.atomic-list-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.atomic-list-icon svg {
  width: 21px;
  height: 21px;
}

.atomic-list-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.atomic-list-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atomic-list-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atomic-list-metrics,
.atomic-list-flags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.atomic-list-metrics > span:not(.atomic-rating-badge) {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 8.5px;
}

.atomic-list-metrics svg {
  width: 13px;
  height: 13px;
}

.atomic-list-flags button {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
}

.atomic-list-flags button svg {
  width: 15px;
  height: 15px;
}

.atomic-list-flags button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Tabella */

.atomic-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
}

.atomic-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

.atomic-table th,
.atomic-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 9px;
  text-align: left;
  vertical-align: middle;
}

.atomic-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-soft);
  color: var(--faint);
  font-size: 8px;
  font-weight: 820;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.atomic-table tbody tr:hover {
  background: var(--surface-hover);
}

.atomic-table td button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.atomic-table td button strong {
  display: block;
  color: var(--text);
  font-size: 10px;
}

.atomic-table td button small,
.atomic-table td > small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 8px;
}

.atomic-table-category {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.atomic-table-category svg {
  width: 13px;
  height: 13px;
}

.atomic-table-flag {
  display: inline-flex;
  margin: 2px;
  padding: 4px 6px;
  border-radius: 999px;
  font-size: 7.5px;
  font-weight: 800;
  text-transform: uppercase;
}

.atomic-table-flag.tonight {
  background: rgba(184, 108, 17, 0.16);
  color: #db921b;
}

.atomic-table-flag.weekend {
  background: rgba(83, 116, 198, 0.16);
  color: #7698ec;
}

.atomic-table-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.atomic-table-actions button,
.atomic-table-actions a {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
}

.atomic-table-actions svg {
  width: 14px;
  height: 14px;
}

/* Mappe */

.atomic-mini-map-section,
.atomic-map-view {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
}

.atomic-mini-map-section > header,
.atomic-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.atomic-mini-map-section > header h2 {
  margin: 4px 0 0;
  font-size: 16px;
  letter-spacing: -0.025em;
}

.atomic-mini-map-section > header > div:last-child,
.atomic-map-header > div:last-child {
  display: flex;
  align-items: center;
  gap: 7px;
}

.atomic-mini-map-section > header button,
.atomic-map-header button {
  min-height: 35px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 9px;
  font-weight: 730;
}

.atomic-mini-map-section > header button svg,
.atomic-map-header button svg {
  width: 14px;
  height: 14px;
}

.atomic-map-header strong {
  display: block;
  color: var(--text);
  font-size: 11px;
}

.atomic-map-header span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8.5px;
}

.atomic-map-canvas {
  width: 100%;
  height: 280px;
  background: var(--surface-soft);
}

.atomic-map-canvas-large {
  height: min(58vh, 610px);
}

.atomic-map-list {
  display: grid;
  gap: 7px;
  padding: 13px;
}

.atomic-map-empty-copy {
  margin: 0;
  padding: 10px 17px 15px;
  color: var(--muted);
  font-size: 9px;
}

.atomic-leaflet-icon {
  border: 0 !important;
  background: transparent !important;
}

.atomic-map-marker {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50% 50% 50% 12px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
  transform: rotate(-45deg);
}

.atomic-map-marker svg {
  width: 18px;
  height: 18px;
  transform: rotate(45deg);
}

.atomic-map-popup {
  min-width: 175px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #222;
}

.atomic-map-popup strong {
  font-size: 12px;
}

.atomic-map-popup span,
.atomic-map-popup small {
  color: #666;
  font-size: 9px;
}

.atomic-map-popup button {
  min-height: 30px;
  margin-top: 3px;
  border: 0;
  border-radius: 8px;
  background: #cf8500;
  color: #fff;
  font-size: 9px;
  font-weight: 750;
}

html[data-theme="dark"] .atomic-map-canvas .leaflet-tile {
  filter: brightness(0.72) contrast(1.08) saturate(0.68);
}

html[data-theme="dark"] .leaflet-control-zoom a,
html[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(35, 35, 35, 0.9);
  color: #ddd;
}


/* Doppioni */

.atomic-import-card.duplicate {
  border-color: color-mix(in srgb, #e0a129 56%, var(--border));
}

.atomic-duplicate-notice {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 8px;
  margin-top: 9px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, #e0a129 45%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, #e0a129 8%, var(--surface));
}

.atomic-duplicate-notice > svg {
  width: 20px;
  height: 20px;
  color: #d9961d;
}

.atomic-duplicate-notice > span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.atomic-duplicate-notice strong {
  color: var(--text);
  font-size: 9px;
}

.atomic-duplicate-notice small {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atomic-duplicate-notice label {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 8.5px;
}

/* Piano Atomico */

.atomic-plan-sheet {
  width: min(94vw, 860px);
  max-height: 92vh;
  overflow: hidden;
}

.atomic-plan-body {
  min-height: 290px;
  max-height: 67vh;
  overflow-y: auto;
  padding: 18px 20px;
}

.atomic-plan-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.atomic-plan-loading {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  text-align: center;
}

.atomic-plan-loading strong {
  margin-top: 7px;
  color: var(--text);
  font-size: 15px;
}

.atomic-plan-loading p {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.atomic-plan-loading > div {
  width: min(100%, 440px);
  display: grid;
  gap: 7px;
  margin-top: 13px;
}

.atomic-plan-loading i {
  height: 10px;
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--surface-soft), var(--surface-hover), var(--surface-soft));
  background-size: 200% 100%;
  animation: atomic-skeleton 1.25s linear infinite;
}

.atomic-plan-loading i:nth-child(2) { width: 78%; }
.atomic-plan-loading i:nth-child(3) { width: 57%; }

.atomic-plan-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.atomic-plan-summary-grid > span {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.atomic-plan-summary-grid small {
  color: var(--faint);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.atomic-plan-summary-grid strong {
  color: var(--text);
  font-size: 11px;
}

.atomic-plan-timeline {
  display: grid;
  gap: 0;
  margin-top: 16px;
}

.atomic-plan-timeline article {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 13px;
}

.atomic-plan-time {
  position: relative;
  display: flex;
  justify-content: flex-end;
  padding-top: 13px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 820;
}

.atomic-plan-time i {
  position: absolute;
  top: 21px;
  right: -9px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.atomic-plan-timeline article:not(:last-child) .atomic-plan-time::after {
  content: "";
  position: absolute;
  top: 30px;
  right: -5px;
  bottom: 0;
  width: 1px;
  background: var(--border-strong);
}

.atomic-plan-step {
  margin-bottom: 10px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
}

.atomic-plan-step h3 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
}

.atomic-plan-step p {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin: 6px 0;
  color: var(--muted);
  font-size: 9px;
}

.atomic-plan-step p svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.atomic-plan-step > span {
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.45;
}

.atomic-plan-step > div {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.atomic-plan-step a {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 8.5px;
  font-weight: 720;
  text-decoration: none;
}

.atomic-plan-choice {
  margin-top: 15px;
  padding: 15px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.atomic-plan-choice p {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
}

.atomic-plan-sources {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.atomic-plan-sources summary {
  padding: 10px 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 9px;
}

.atomic-plan-sources > div {
  display: grid;
  gap: 5px;
  padding: 0 12px 12px;
}

.atomic-plan-sources a {
  color: var(--accent);
  font-size: 8.5px;
}

.atomic-page-compact .atomic-hero-panel {
  min-height: 0;
  padding-block: 18px;
}

.atomic-page-compact .atomic-hero-copy h1 {
  font-size: clamp(28px, 4vw, 50px);
}

.atomic-page-compact .atomic-hero-copy > p,
.atomic-page-compact .atomic-hero-visual,
.atomic-page-compact .atomic-hero-actions {
  display: none;
}

@media (max-width: 1180px) {
  .atomic-toolbar-sticky {
    grid-template-columns: minmax(230px, 1fr) minmax(150px, 0.55fr) auto auto;
  }

  .atomic-view-copy {
    display: none;
  }

  .atomic-view-switch button span {
    display: none;
  }
}

@media (max-width: 820px) {
  .atomic-toolbar-sticky {
    position: static;
    grid-template-columns: 1fr auto;
  }

  .atomic-main-search {
    grid-column: 1 / -1;
  }

  .atomic-sort-control {
    min-width: 0;
  }

  .atomic-bulk-bar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .atomic-bulk-actions {
    justify-content: flex-start;
  }

  .atomic-list-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .atomic-list-metrics {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }

  .atomic-list-flags {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }

  .atomic-plan-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .atomic-view-switch {
    width: 100%;
    grid-column: 1 / -1;
  }

  .atomic-view-switch button {
    flex: 1 1 0;
  }

  .atomic-view-switch button span {
    display: inline;
  }

  .atomic-selection-toggle {
    min-width: 0;
  }

  .atomic-list-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .atomic-list-metrics,
  .atomic-list-flags {
    grid-column: 2;
    flex-wrap: wrap;
  }

  .atomic-table-wrap {
    border: 0;
    overflow: visible;
    background: transparent;
  }

  .atomic-table,
  .atomic-table thead,
  .atomic-table tbody,
  .atomic-table tr,
  .atomic-table th,
  .atomic-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .atomic-table thead {
    display: none;
  }

  .atomic-table tr {
    margin-bottom: 9px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
  }

  .atomic-table td {
    padding: 4px 0;
    border: 0;
  }

  .atomic-mini-map-section > header,
  .atomic-map-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .atomic-map-canvas {
    height: 330px;
  }

  .atomic-plan-sheet {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .atomic-plan-body {
    max-height: none;
    flex: 1 1 auto;
  }

  .atomic-plan-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .atomic-plan-timeline article {
    grid-template-columns: 54px minmax(0, 1fr);
  }
}

.atomic-hero-tertiary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  color: var(--muted);
  font-size: 9px;
  font-weight: 740;
}

.atomic-hero-tertiary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.atomic-hero-tertiary svg {
  width: 15px;
  height: 15px;
}

.atomic-map-library-error {
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.atomic-map-library-error strong {
  color: var(--text);
  font-size: 12px;
}

.atomic-map-library-error span {
  font-size: 9px;
}


/* =========================================================
   V10.5 — SEZIONI VERE E MAPPE STABILI
   ========================================================= */

.atomic-section-hero {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  min-height: 190px;
  margin-bottom: 14px;
  padding: 26px 30px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 22px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 92%, var(--accent)), var(--surface-soft));
}

.atomic-section-hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -90px;
  bottom: -150px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 0 36px color-mix(in srgb, var(--accent) 4%, transparent), 0 0 0 76px color-mix(in srgb, var(--accent) 3%, transparent);
}

.atomic-section-symbol {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 22px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}

.atomic-section-symbol svg { width: 36px; height: 36px; }
.atomic-section-copy { position: relative; z-index: 1; min-width: 0; }
.atomic-section-copy h1 { margin: 5px 0 0; font-size: clamp(30px, 4vw, 52px); line-height: .98; letter-spacing: -.055em; }
.atomic-section-copy p { max-width: 650px; margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.atomic-section-meta { display: inline-flex; align-items: baseline; gap: 6px; margin-top: 15px; }
.atomic-section-meta strong { color: var(--accent); font-size: 21px; }
.atomic-section-meta span { color: var(--muted); font-size: 10px; }
.atomic-section-actions { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 190px; }
.atomic-section-actions button { min-height: 42px; }

.atomic-single-board { margin: 0 0 14px; }
.atomic-single-board .atomic-priority-boards { grid-template-columns: 1fr; }
.atomic-shortlist-jump { display: flex; gap: 8px; margin: 0 0 12px; }
.atomic-shortlist-jump button { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.atomic-shortlist-jump svg { width: 15px; height: 15px; color: var(--accent); }
.atomic-shortlist-jump strong { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 999px; background: var(--surface-hover); font-size: 9px; }

@media (min-width: 901px) {
  .app:not(.sidebar-collapsed) .atomic-category-rail { display: none; }
}

.atomic-map-view { overflow: hidden; }
.atomic-map-split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, .8fr); min-height: 570px; border-top: 1px solid var(--border); }
.atomic-map-canvas { position: relative; isolation: isolate; min-height: 360px; background: #dbe9ec; }
.atomic-map-canvas-large { min-height: 570px; border-radius: 0; }
.atomic-map-list { max-height: 570px; overflow-y: auto; padding: 12px; border-left: 1px solid var(--border); background: var(--surface-soft); }
.atomic-map-list > header { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; gap: 10px; margin: -12px -12px 10px; padding: 12px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); }
.atomic-map-list > header strong { font-size: 11px; }
.atomic-map-list > header span { color: var(--muted); font-size: 9px; }
.atomic-map-list .atomic-list-row { margin-bottom: 7px; }
.atomic-map-header > div:last-child { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

.atomic-map-empty-state { min-height: 360px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 35px; border: 1px dashed var(--border-strong); border-radius: 18px; background: var(--surface-soft); text-align: center; }
.atomic-map-empty-state > div { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: var(--accent-soft); color: var(--accent); }
.atomic-map-empty-state svg { width: 28px; height: 28px; }
.atomic-map-empty-state h3 { margin: 0; font-size: 18px; }
.atomic-map-empty-state p { max-width: 540px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.atomic-map-empty-state small { color: var(--faint); font-size: 9px; }

.atomic-unpositioned-section { margin-top: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); }
.atomic-unpositioned-section > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.atomic-unpositioned-section h3 { margin: 3px 0 0; }
.atomic-unpositioned-list { display: grid; gap: 7px; }

.atomic-mini-map-section { overflow: hidden; }
.atomic-mini-map-section .atomic-map-canvas { border-top: 1px solid var(--border); }

.atomic-map-marker { box-sizing: border-box; }
.atomic-leaflet-icon { background: transparent !important; border: 0 !important; }
.atomic-map-canvas .leaflet-pane, .atomic-map-canvas .leaflet-control { z-index: auto; }
.atomic-map-canvas .leaflet-map-pane { z-index: 2; }
.atomic-map-canvas .leaflet-tile-pane { z-index: 2; }
.atomic-map-canvas .leaflet-overlay-pane { z-index: 4; }
.atomic-map-canvas .leaflet-marker-pane { z-index: 6; }
.atomic-map-canvas .leaflet-popup-pane { z-index: 8; }
.atomic-map-canvas .leaflet-control-container { position: relative; z-index: 20; }

.atomic-view-switch button.empty { opacity: .72; }



@media (max-width: 920px) {
  .atomic-section-hero { grid-template-columns: 58px minmax(0,1fr); padding: 22px; }
  .atomic-section-symbol { width: 58px; height: 58px; border-radius: 17px; }
  .atomic-section-symbol svg { width: 28px; height: 28px; }
  .atomic-section-actions { grid-column: 1 / -1; flex-direction: row; min-width: 0; }
  .atomic-section-actions button { flex: 1 1 0; }
  .atomic-map-split { grid-template-columns: 1fr; }
  .atomic-map-list { max-height: none; border-left: 0; border-top: 1px solid var(--border); }
  .atomic-map-canvas-large { min-height: 460px; }
}

@media (max-width: 620px) {
  .atomic-section-hero { grid-template-columns: 48px minmax(0,1fr); gap: 13px; min-height: 0; padding: 17px; border-radius: 18px; }
  .atomic-section-symbol { width: 48px; height: 48px; border-radius: 14px; }
  .atomic-section-symbol svg { width: 23px; height: 23px; }
  .atomic-section-copy h1 { font-size: 30px; }
  .atomic-section-copy p { margin-top: 8px; font-size: 11px; }
  .atomic-section-actions { flex-direction: column; }
  .atomic-shortlist-jump { overflow-x: auto; }
  .atomic-map-canvas-large { min-height: calc(100dvh - 270px); }
  .atomic-map-list { display: none; }
  .atomic-map-header { align-items: stretch; }
  .atomic-map-header > div:last-child { justify-content: stretch; }
  .atomic-map-header button { flex: 1 1 auto; }
}


/* =========================================================
   V10.6 — PICCOLA, CHIARA, ATOMICA
   ========================================================= */

:root {
  --mobile-nav-height: 70px;
  --touch-size: 44px;
}

html,
body {
  overscroll-behavior: none;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

.atomic-mobile-toolbar,
.mobile-control-backdrop,
.onboarding-backdrop,
.contextual-hint {
  display: none;
}

/* Onboarding */
.onboarding-backdrop {
  z-index: 160;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(6, 6, 7, 0.82);
  backdrop-filter: blur(18px);
}

.onboarding-sheet {
  width: min(92vw, 520px);
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background:
    radial-gradient(circle at 85% 5%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 34%),
    var(--surface);
  box-shadow: var(--shadow-lg);
}

.onboarding-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 11px;
  font-weight: 820;
}

.onboarding-brand img {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  object-fit: cover;
}

.onboarding-progress {
  display: flex;
  gap: 6px;
  margin: 26px 0 20px;
}

.onboarding-progress span {
  width: 26px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-hover);
  transition: background .18s ease, width .18s ease;
}

.onboarding-progress span.active {
  width: 42px;
  background: var(--accent);
}

.onboarding-content h2 {
  max-width: 430px;
  margin: 7px 0 0;
  font-size: clamp(25px, 5vw, 38px);
  line-height: 1.02;
  letter-spacing: -.045em;
}

.onboarding-content p {
  max-width: 440px;
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.onboarding-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 28px;
}

.onboarding-actions button {
  min-height: 44px;
}

.contextual-hint {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 145;
  width: min(390px, calc(100vw - 36px));
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border));
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.contextual-hint:not(.hidden) {
  display: grid;
}

.contextual-hint-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.contextual-hint-icon svg {
  width: 20px;
  height: 20px;
}

.contextual-hint strong {
  display: block;
  font-size: 10px;
}

.contextual-hint p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.contextual-hint button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 9px;
  font-weight: 760;
}

/* Mobile control sheet */
.mobile-control-body {
  min-height: 180px;
  max-height: 70dvh;
  overflow-y: auto;
  padding: 15px;
}

.mobile-control-search {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-soft);
}

.mobile-control-search svg {
  width: 19px;
  height: 19px;
  color: var(--muted);
}

.mobile-control-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.mobile-control-clear {
  margin-top: 10px;
}

.mobile-control-section + .mobile-control-section {
  margin-top: 20px;
}

.mobile-control-label {
  display: block;
  margin-bottom: 8px;
  color: var(--faint);
  font-size: 8px;
  font-weight: 820;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.mobile-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mobile-control-grid button {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: left;
}

.mobile-control-grid button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.mobile-control-grid button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.mobile-choice-list {
  display: grid;
  gap: 8px;
}

.mobile-choice-list > button {
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: left;
}

.mobile-choice-list > button > svg {
  width: 19px;
  height: 19px;
}

.mobile-choice-list > button span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mobile-choice-list strong {
  color: var(--text);
  font-size: 11px;
}

.mobile-choice-list small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.mobile-choice-list > button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Less jumping and less work while scrolling */
.atomic-card,
.atomic-list-row,
.atomic-tonight-card,
.message {
  contain: layout paint;
}

.atomic-card-grid > *,
.atomic-list-view > * {
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}

@media (hover: none), (pointer: coarse) {
  .atomic-card,
  .atomic-tonight-card,
  button,
  .modal,
  .atomic-sheet {
    transition-duration: .08s !important;
  }

  .atomic-card:hover,
  .atomic-import-card:hover {
    transform: none;
  }
}

@media (max-width: 900px) {
  .contextual-hint {
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 10px);
  }
}

@media (max-width: 620px) {
  :root {
    --mobile-nav-height: 68px;
  }

  body {
    overflow: hidden;
  }

  .app {
    height: var(--app-height, 100dvh);
    min-height: 0;
  }

  .main-panel {
    min-width: 0;
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  }

  .chat-header {
    min-height: 56px;
    padding: 7px 10px;
    border-bottom-color: var(--border);
  }

  .chat-header .header-actions {
    display: none !important;
  }

  .chat-heading {
    min-width: 0;
  }

  .chat-title-row {
    min-width: 0;
    gap: 6px;
  }

  .chat-title-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }

  .space-badge {
    flex: 0 0 auto;
    max-width: 95px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #headerSubtitle {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8px;
  }

  .header-icon-button,
  .menu-button {
    width: 42px;
    height: 42px;
  }

  .messages,
  .atomic-workspace {
    overscroll-behavior: contain;
    scroll-behavior: auto;
  }

  .message-form {
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding: 5px 8px 7px;
    background: linear-gradient(to top, var(--page) 72%, transparent);
  }

  .composer-region {
    width: 100%;
  }

  .composer-topbar {
    margin-bottom: 4px;
  }

  .composer-context {
    min-width: 0;
    max-width: calc(100vw - 104px);
    padding: 4px 7px;
  }

  .composer-context small,
  .composer-hint {
    display: none;
  }

  .composer-box {
    min-height: 50px;
    padding: 4px;
    border-radius: 16px;
  }

  .composer-box textarea {
    min-height: 40px;
    max-height: 126px;
    padding: 9px 6px 6px;
    font-size: 16px;
  }

  .composer-icon-button,
  .composer-send-button,
  .composer-stop-button {
    width: 42px;
    height: 42px;
  }

  .mobile-bottom-nav {
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
    gap: 1px;
    padding: 5px 5px env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(22px);
  }

  .mobile-bottom-nav > button {
    min-width: 0;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 3px 1px;
    border-radius: 12px;
    font-size: 8px;
  }

  .mobile-bottom-nav > button svg {
    width: 20px;
    height: 20px;
  }

  .mobile-bottom-nav .mobile-primary-action {
    align-self: start;
    width: auto;
    height: 58px;
    margin: -14px 2px 0;
    border: 4px solid var(--page);
    border-radius: 19px;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 28%, transparent);
  }

  .mobile-bottom-nav .mobile-primary-action span {
    display: block;
    color: inherit;
    font-size: 7px;
  }

  /* Atomiche home: less content, stronger hierarchy */
  .atomic-workspace {
    padding: 10px 9px calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 16px);
  }

  .atomic-page {
    width: 100%;
    max-width: none;
  }

  .atomic-hero-panel {
    min-height: 0;
    margin-bottom: 9px;
    padding: 18px 16px;
    border-radius: 18px;
  }

  .atomic-hero-copy h1 {
    max-width: 280px;
    font-size: 38px;
    line-height: .92;
  }

  .atomic-hero-copy > p,
  .atomic-hero-visual,
  .atomic-stat-strip {
    display: none;
  }

  .atomic-hero-actions {
    margin-top: 15px;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 7px;
  }

  .atomic-hero-primary,
  .atomic-hero-secondary,
  .atomic-hero-tertiary {
    min-height: 44px;
    width: 100%;
    padding: 0 9px;
    font-size: 9px;
  }

  .atomic-hero-tertiary {
    grid-column: 1 / -1;
  }

  .atomic-section-hero {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 11px;
    margin-bottom: 9px;
    padding: 14px;
    border-radius: 16px;
  }

  .atomic-section-symbol {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .atomic-section-copy h1 {
    font-size: 26px;
  }

  .atomic-section-copy p {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 5px;
    font-size: 10px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .atomic-section-meta {
    margin-top: 7px;
  }

  .atomic-section-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
  }

  .atomic-section-actions .atomic-quiet-button {
    display: none;
  }

  .atomic-priority-boards {
    gap: 8px;
    margin: 0 0 10px;
  }

  .atomic-priority-boards .atomic-tonight-section,
  .atomic-single-board .atomic-tonight-section {
    padding: 13px;
    border-radius: 16px;
  }

  .atomic-board-heading {
    margin-bottom: 9px;
  }

  .atomic-board-heading h2 {
    margin-top: 2px;
    font-size: 15px;
  }

  .atomic-board-count {
    min-width: 29px;
    height: 29px;
    font-size: 10px;
  }

  .atomic-priority-boards .atomic-tonight-rail,
  .atomic-single-board .atomic-tonight-rail {
    min-height: 0;
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    gap: 6px;
    overflow: visible;
  }

  .atomic-tonight-card {
    min-width: 0;
    border-radius: 12px;
  }

  .atomic-tonight-card .atomic-card-open {
    min-height: 61px;
    padding: 8px;
  }

  .atomic-tonight-icon {
    width: 38px;
    height: 38px;
  }

  .atomic-tonight-copy strong {
    font-size: 10px;
  }

  .atomic-tonight-copy > small {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8px;
  }

  .atomic-tonight-metrics {
    margin-top: 3px;
  }

  .atomic-mini-reactions button {
    min-height: 30px;
    font-size: 8px;
  }

  .atomic-board-actions {
    margin-top: 8px;
  }

  .atomic-board-actions button {
    flex: 1 1 0;
    min-height: 38px;
  }

  .atomic-mobile-toolbar {
    position: sticky;
    top: 0;
    z-index: 24;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin: 0 0 8px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(18px);
  }

  .atomic-mobile-toolbar button {
    min-width: 0;
    min-height: 43px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 3px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 7.5px;
    font-weight: 720;
  }

  .atomic-mobile-toolbar button:active {
    background: var(--surface-hover);
  }

  .atomic-mobile-toolbar svg {
    width: 17px;
    height: 17px;
  }

  .atomic-mobile-toolbar strong {
    display: inline-grid;
    place-items: center;
    min-width: 15px;
    height: 15px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 7px;
  }

  .atomic-desktop-toolbar,
  .atomic-category-rail,
  .atomic-shortlist-jump {
    display: none !important;
  }

  .atomic-library-section {
    margin-top: 0;
  }

  .atomic-section-heading {
    align-items: flex-end;
    margin-bottom: 8px;
  }

  .atomic-section-heading h2 {
    font-size: 18px;
  }

  .atomic-section-heading > button {
    display: none;
  }

  /* Compact card view */
  .atomic-card-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .atomic-card {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    min-height: 132px;
    border-radius: 15px;
  }

  .atomic-card-visual {
    min-height: 100%;
    height: auto;
    border-radius: 14px 0 0 14px;
  }

  .atomic-card-orbit,
  .atomic-card-type {
    display: none;
  }

  .atomic-card-category-icon {
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }

  .atomic-card-shortlist-badges {
    top: 7px;
    right: 6px;
  }

  .atomic-card-body {
    min-width: 0;
    padding: 11px 10px 9px;
  }

  .atomic-card-title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }

  .atomic-card-title-row > div {
    min-width: 0;
  }

  .atomic-card-title-row span {
    font-size: 7px;
  }

  .atomic-card-title-row h3 {
    overflow: hidden;
    margin-top: 2px;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .atomic-card-title-row .atomic-rating-badge {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    margin: 0;
  }

  .atomic-card-favorite,
  .atomic-card-description,
  .atomic-card-facts,
  .atomic-card-tags,
  .atomic-card-people,
  .atomic-card-actions a {
    display: none !important;
  }

  .atomic-card-footer {
    margin-top: 9px;
    padding-top: 8px;
  }

  .atomic-card-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .atomic-card-actions button {
    width: 100%;
    height: 36px;
    display: grid !important;
    place-items: center;
  }

  .atomic-card-actions button[data-atomic-action="detail"] svg {
    display: none;
  }

  .atomic-card-actions button[data-atomic-action="detail"]::before {
    content: "•••";
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 1px;
  }

  /* List view is the dense alternative */
  .atomic-list-row {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 68px;
    padding: 8px;
    border-radius: 13px;
  }

  .atomic-list-open {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 8px;
  }

  .atomic-list-icon {
    width: 38px;
    height: 38px;
  }

  .atomic-list-copy strong {
    font-size: 11px;
  }

  .atomic-list-metrics {
    grid-column: 1 / -1;
    padding-left: 46px;
  }

  .atomic-list-flags {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  .atomic-list-flags button {
    width: 34px;
    height: 34px;
  }

  .atomic-table-wrap,
  .atomic-selection-toggle,
  .atomic-bulk-bar {
    display: none !important;
  }

  .atomic-mini-map-section {
    margin-top: 10px;
  }

  /* Bottom sheets instead of desktop dialogs */
  .modal-backdrop,
  .atomic-modal-backdrop,
  .model-picker-backdrop,
  .web-picker-backdrop,
  .onboarding-backdrop {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .modal,
  .atomic-sheet,
  .model-picker-sheet,
  .web-picker-sheet,
  .onboarding-sheet {
    position: relative;
    width: 100%;
    max-width: none;
    max-height: calc(var(--app-height, 100dvh) - 34px);
    margin: 0;
    border-radius: 22px 22px 0 0;
    transform: translateY(16px);
    opacity: .98;
  }

  .modal-backdrop.is-open .modal,
  .modal-backdrop.is-open .atomic-sheet,
  .modal-backdrop.is-open .model-picker-sheet,
  .modal-backdrop.is-open .web-picker-sheet,
  .modal-backdrop.is-open .onboarding-sheet {
    transform: translateY(0);
  }

  .atomic-sheet::before,
  .modal::before,
  .model-picker-sheet::before,
  .web-picker-sheet::before,
  .onboarding-sheet::before {
    content: "";
    position: absolute;
    top: 7px;
    left: 50%;
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
    transform: translateX(-50%);
  }

  .atomic-sheet-header,
  .modal-header,
  .model-picker-header {
    position: sticky;
    top: 0;
    z-index: 4;
    padding-top: 22px;
    background: var(--surface);
  }

  .atomic-add-body,
  .atomic-detail-body,
  .atomic-decide-body,
  .settings-scroll-body,
  .mobile-control-body {
    overscroll-behavior: contain;
  }

  .onboarding-backdrop {
    display: flex;
  }

  .onboarding-sheet {
    padding: 24px 18px max(20px, env(safe-area-inset-bottom));
  }

  .onboarding-content h2 {
    font-size: 29px;
  }

  .onboarding-actions button {
    flex: 1 1 0;
  }

  .mobile-control-backdrop:not(.hidden) {
    display: flex;
  }
}

@media (max-width: 390px) {
  .atomic-hero-copy h1 {
    font-size: 34px;
  }

  .mobile-bottom-nav > button span {
    font-size: 7px;
  }

  .atomic-card {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .atomic-card-category-icon {
    width: 39px;
    height: 39px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}


/* V10.6 navigation and onboarding finishing rules */
.onboarding-backdrop:not(.hidden) {
  display: flex;
}

@media (max-width: 900px) {
  .mobile-bottom-nav {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
  }

  .mobile-bottom-nav .mobile-primary-action {
    transform: none;
  }
}

@media (max-width: 620px) {
  .mobile-bottom-nav {
    bottom: 0;
    right: 0;
    left: 0;
  }
}

/* =========================================================
   V10.6.1 — MOBILE CLEANUP
   Nessuna nuova funzione: meno livelli, zero scatti, drawer pulito.
   ========================================================= */

.atomic-library-count {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
}

.atomic-library-count strong {
  color: var(--accent);
  font-size: 20px;
}

.atomic-library-count span {
  color: var(--muted);
  font-size: 10px;
}

@media (hover: hover) and (pointer: fine) {
  .atomic-card-open:hover {
    background: var(--surface-hover);
  }

  .atomic-mini-reactions button:hover {
    background: var(--accent-soft);
    color: var(--text);
  }

  .atomic-card-visual:hover {
    filter: brightness(1.05);
  }
}

@media (hover: none), (pointer: coarse) {
  .atomic-card-open:hover,
  .atomic-mini-reactions button:hover,
  .atomic-card-visual:hover,
  .atomic-card:hover,
  .atomic-import-card:hover {
    filter: none !important;
    transform: none !important;
  }

  .atomic-card-open:hover {
    background: transparent !important;
  }
}

@media (max-width: 900px) {
  .sidebar {
    z-index: 220;
    width: min(88vw, 380px);
  }

  .mobile-overlay {
    z-index: 210;
  }

  html.sidebar-open,
  body.sidebar-open {
    overflow: hidden !important;
    touch-action: none;
  }

  html.sidebar-open .mobile-bottom-nav,
  html.sidebar-open .atomic-mobile-toolbar,
  body.sidebar-open .mobile-bottom-nav,
  body.sidebar-open .atomic-mobile-toolbar {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body.sidebar-open .chat-area {
    pointer-events: none;
  }

  body.sidebar-open .sidebar,
  body.sidebar-open .mobile-overlay {
    pointer-events: auto;
  }

  .sidebar-footer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 620px) {
  /* Un solo scorrimento interno, senza mutazioni di altezza durante il gesto. */
  .atomic-workspace {
    padding: 0 !important;
    scroll-anchor: none;
  }

  .atomic-page {
    padding:
      12px
      12px
      calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 18px) !important;
  }

  .atomic-page-compact .atomic-hero-panel,
  .atomic-page-compact .atomic-section-hero {
    min-height: inherit !important;
    padding: inherit !important;
  }

  .atomic-card,
  .atomic-list-row,
  .atomic-tonight-card,
  .message {
    contain: none !important;
  }

  .atomic-card-grid > *,
  .atomic-list-view > * {
    content-visibility: visible !important;
    contain-intrinsic-size: auto !important;
  }

  /* Header: sul telefono l'azione Aggiungi esiste già al centro della barra bassa. */
  #atomicHeaderActions {
    display: none !important;
  }

  .chat-header {
    min-height: 58px;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 8px;
    padding: 7px 11px;
    backdrop-filter: none;
  }

  .chat-heading strong {
    font-size: 15px;
  }

  #headerSubtitle {
    font-size: 9px;
  }

  /* Hero categoria: riconoscibile, ma non occupa più quasi uno schermo. */
  .atomic-section-hero {
    min-height: 0 !important;
    grid-template-columns: 44px minmax(0, 1fr) !important;
    align-items: start;
    gap: 11px;
    margin-bottom: 10px;
    padding: 14px !important;
    border-radius: 17px;
    box-shadow: none;
  }

  .atomic-section-hero::after {
    width: 170px;
    height: 170px;
    right: -76px;
    bottom: -100px;
    box-shadow:
      0 0 0 24px color-mix(in srgb, var(--accent) 3%, transparent),
      0 0 0 48px color-mix(in srgb, var(--accent) 2%, transparent);
  }

  .atomic-section-symbol {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }

  .atomic-section-symbol svg {
    width: 22px;
    height: 22px;
  }

  .atomic-section-copy h1 {
    margin-top: 2px;
    font-size: clamp(25px, 8vw, 31px);
    line-height: .98;
  }

  .atomic-section-copy p {
    margin-top: 6px;
    font-size: 10px;
    line-height: 1.35;
    -webkit-line-clamp: 2;
  }

  .atomic-section-meta {
    margin-top: 7px;
  }

  .atomic-section-meta strong {
    font-size: 18px;
  }

  .atomic-section-actions {
    grid-column: 1 / -1;
    margin-top: 1px;
  }

  .atomic-section-actions button {
    width: 100%;
    min-height: 48px !important;
    height: 48px;
    padding: 0 14px;
    font-size: 11px;
  }

  .atomic-section-actions .atomic-quiet-button {
    display: none !important;
  }

  /* Home: niente compressione al superamento di una soglia di scroll. */
  .atomic-hero-panel {
    min-height: 0 !important;
    margin-bottom: 10px;
    padding: 16px 15px !important;
    border-radius: 17px;
    box-shadow: none;
  }

  .atomic-hero-copy h1 {
    max-width: 270px;
    font-size: 34px;
    line-height: .94;
  }

  .atomic-hero-actions {
    margin-top: 13px;
  }

  /* Lavagna e cassetto: importanti, ma non più una seconda pagina dentro la pagina. */
  .atomic-priority-boards,
  .atomic-single-board {
    margin-bottom: 10px;
  }

  .atomic-priority-boards .atomic-tonight-section,
  .atomic-single-board .atomic-tonight-section {
    padding: 12px;
    border-radius: 16px;
  }

  .atomic-board-heading {
    margin-bottom: 8px;
  }

  .atomic-board-heading h2 {
    font-size: 15px;
    line-height: 1.12;
  }

  .atomic-tonight-card .atomic-card-open {
    min-height: 60px;
    padding: 8px;
  }

  .atomic-board-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
  }

  .atomic-single-board .atomic-board-actions {
    grid-template-columns: 1fr;
  }

  .atomic-board-actions button {
    min-height: 42px;
  }

  /* Cerca vive nella barra bassa. Qui rimangono solo i controlli dell'elenco. */
  .atomic-mobile-toolbar {
    position: relative !important;
    top: auto !important;
    z-index: 1 !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    margin: 0 0 9px;
    padding: 5px;
    border-radius: 13px;
    background: var(--surface);
    backdrop-filter: none;
    box-shadow: none;
  }

  .atomic-mobile-toolbar button {
    min-height: 42px;
  }

  /* La categoria non è un filtro: il titolo non viene ripetuto sotto l'hero. */
  .atomic-section-heading-minimal {
    min-height: 30px;
    align-items: center;
    margin: 2px 2px 8px;
  }

  .atomic-section-heading-minimal .atomic-library-count {
    margin: 0;
  }

  .atomic-library-section {
    margin-top: 0 !important;
  }

  .atomic-section-heading:not(.atomic-section-heading-minimal) {
    margin-bottom: 8px;
  }

  .atomic-section-heading h2 {
    font-size: 18px;
  }

  /* Card mobile: una riga visuale, non una card desktop alta mezzo schermo. */
  .atomic-card-grid {
    gap: 9px;
  }

  .atomic-card {
    height: auto !important;
    min-height: 126px !important;
    max-height: 160px;
    grid-template-columns: 58px minmax(0, 1fr) !important;
    align-self: start;
    border-radius: 15px;
    box-shadow: none;
  }

  .atomic-card-visual {
    width: 58px !important;
    height: 100% !important;
    min-height: 126px !important;
    border-radius: 14px 0 0 14px;
  }

  .atomic-card-category-icon {
    width: 38px;
    height: 38px;
  }

  .atomic-card-main-icon {
    width: 22px;
    height: 22px;
  }

  .atomic-card-body {
    min-height: 126px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px !important;
  }

  .atomic-card-title-row {
    align-items: center;
  }

  .atomic-card-title-row h3 {
    max-width: 100%;
    font-size: 13px;
  }

  .atomic-rating-badge {
    min-height: 27px;
    padding: 4px 7px;
  }

  .atomic-rating-badge small {
    display: none;
  }

  .atomic-card-footer {
    margin-top: auto !important;
    padding-top: 8px !important;
  }

  .atomic-card-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .atomic-card-actions button {
    height: 36px;
    border-radius: 10px;
  }

  /* Drawer: lo sfondo non scorre e nessun comando resta sospeso davanti. */
  .sidebar {
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    overflow: hidden;
  }

  .atomic-sidebar,
  .chat-list {
    overscroll-behavior: contain;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Bottom nav più stabile e senza blur durante lo scroll. */
  .mobile-bottom-nav {
    background: var(--surface);
    backdrop-filter: none;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .07);
  }

  /* Riduce il lavoro di Safari durante lo scroll. */
  .atomic-section-hero,
  .atomic-hero-panel,
  .atomic-tonight-section,
  .atomic-card,
  .atomic-mobile-toolbar,
  .mobile-bottom-nav {
    backdrop-filter: none !important;
  }
}
