.ai-shell {
  max-width: 1280px;
  margin: auto;
  padding: 24px 24px 64px;
}
.ai-shell [hidden],
.ai-dialog[hidden] {
  display: none !important;
}
.ai-shell h2 {
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 12px;
}
.ai-shell h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 10px;
}
.ai-muted {
  color: #a3a3a3;
  font-size: 13px;
  line-height: 1.75;
}
.ai-panel {
  background: #111;
  border: 1px solid #292929;
  border-radius: 20px;
  padding: 24px;
  min-width: 0;
}
.ai-upload {
  text-align: center;
  padding: 42px 20px;
  border: 1px dashed #555;
  border-radius: 20px;
}
.ai-upload.drag-over {
  background: #242424;
}
.ai-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.ai-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid #414141;
  border-radius: 10px;
  background: #1d1d1d;
  color: #eee;
  font:
    600 13px "Space Grotesk",
    sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.2s;
}
.ai-button:hover {
  background: #333;
  transform: translateY(-1px);
}
.ai-button.primary {
  background: #fff;
  color: #111;
  border-color: #fff;
}
.ai-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.ai-shell :is(button, a, input, select, summary):focus-visible,
.ai-dialog :focus-visible {
  outline: 2px solid white;
  outline-offset: 3px;
}
.ai-source {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 18px 0;
}
.ai-source strong {
  overflow-wrap: anywhere;
}
.ai-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.ai-stage {
  height: 370px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  overflow: hidden;
  margin: 16px 0;
  background-color: #d6d6d6;
  background-image: conic-gradient(
    #fff 25%,
    transparent 0 50%,
    #fff 0 75%,
    transparent 0
  );
  background-size: 24px 24px;
}
.ai-stage[data-bg="dark"] {
  background: #222;
}
.ai-stage[data-bg="light"] {
  background: #fff;
}
.ai-stage img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}
.ai-stage button {
  border: 0;
  background: none;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
}
.ai-stage p {
  color: #111;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
}
.ai-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ai-field {
  display: grid;
  gap: 6px;
  margin: 14px 0;
}
.ai-field label {
  font-size: 13px;
  font-weight: 600;
  color: #ddd;
}
.ai-shell :is(select, input[type="number"], input[type="text"]) {
  width: 100%;
  padding: 11px 12px;
  background: #191919;
  color: #fff;
  border: 1px solid #444;
  border-radius: 10px;
  min-height: 42px;
  font: inherit;
}
.ai-shell select option {
  background: #191919;
}
.ai-shell fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.ai-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ai-boards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  max-height: 320px;
  overflow: auto;
  margin-top: 14px;
  padding: 4px;
}
.ai-board {
  border: 1px solid #383838;
  border-radius: 12px;
  padding: 8px;
  min-width: 0;
}
.ai-board.current {
  border-color: #fff;
}
.ai-board button {
  width: 100%;
  display: block;
  background: #ddd;
  border: 0;
  border-radius: 7px;
  padding: 0;
  height: 74px;
  cursor: pointer;
  overflow: hidden;
}
.ai-board img {
  height: 100%;
  width: 100%;
  object-fit: contain;
}
.ai-board label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  margin: 9px 0 3px;
}
.ai-board input {
  flex-shrink: 0;
  accent-color: white;
}
.ai-board small {
  display: block;
  font-size: 10px;
  color: #aaa;
  overflow-wrap: anywhere;
}
.ai-status {
  min-height: 50px;
  padding: 10px 0;
  font-size: 13px;
  line-height: 1.65;
  color: #ccc;
  overflow-wrap: anywhere;
}
.ai-status[data-error="true"] {
  color: #fff;
  border-left: 2px solid #aaa;
  padding-left: 10px;
}
.ai-result {
  margin-top: 22px;
}
.ai-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.ai-result-card {
  border: 1px solid #333;
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
}
.ai-result-card img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: repeating-conic-gradient(#fff 0 25%, #ddd 0 50%) 0/16px 16px;
}
.ai-result-card p {
  font-size: 12px;
  line-height: 1.7;
  color: #aaa;
  overflow-wrap: anywhere;
  margin: 10px 0;
}
.ai-result-card a {
  width: 100%;
}
.ai-dialog {
  color: white;
  background: #111;
  border: 1px solid #555;
  border-radius: 18px;
  padding: 20px;
  max-width: min(1100px, 95vw);
  max-height: 94vh;
}
.ai-dialog::backdrop {
  background: #000c;
}
.ai-dialog img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  background: repeating-conic-gradient(#fff 0 25%, #ddd 0 50%) 0/24px 24px;
  margin: 16px auto;
}
.ai-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 160;
  background: #fff;
  color: #111;
  padding: 14px 22px;
  border-radius: 14px;
  box-shadow: 0 10px 40px #0008;
  max-width: calc(100vw - 40px);
  text-align: center;
  pointer-events: none;
  font-size: 14px;
}
.ai-help {
  max-width: 980px;
  margin: 24px auto;
  padding: 20px;
}
.ai-help details {
  border-bottom: 1px solid #333;
  padding: 16px 0;
}
.ai-help summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  list-style: none;
  font-weight: 600;
}
.ai-help summary::-webkit-details-marker {
  display: none;
}
.ai-help summary svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.26s;
}
.ai-help details[open] summary svg {
  transform: rotate(180deg);
}
.ai-help .ai-answer {
  font-size: 14px;
  color: #aaa;
  line-height: 1.8;
  padding-top: 12px;
}
.ai-info {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 48px;
  border-top: 1px solid #333;
  padding: 36px 0;
}
.ai-info p {
  margin-bottom: 12px;
}
.ai-info h3 {
  font-size: 16px;
  margin-bottom: 6px;
}
.ai-help a {
  color: #eee;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.ai-progress {
  width: 100%;
  accent-color: white;
  height: 8px;
}
.ai-retained {
  padding: 12px;
  background: #202020;
  border-radius: 10px;
  margin: 12px 0;
}
.ai-drop-note {
  max-width: 620px;
  margin: 14px auto 0;
}
.ai-history-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin: 14px 0;
}
.ai-history-label input {
  accent-color: white;
}
.ai-limits {
  border-top: 1px solid #333;
  margin-top: 16px;
  padding-top: 12px;
}
.ai-zip-actions {
  margin-top: 12px;
}
.ai-layout #results-panel {
  padding: 20px 0 0;
  border: 0;
  border-top: 1px solid #333;
  border-radius: 0;
}
.ai-layout .ai-results {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.ai-layout .ai-result-card img {
  height: 125px;
}
.ai-layout .ai-result-card p {
  font-size: 11px;
}
@media (max-width: 900px) {
  .ai-layout {
    grid-template-columns: 1fr;
  }
  .ai-stage {
    height: 300px;
  }
  .ai-source {
    align-items: flex-start;
    flex-direction: column;
  }
  .ai-info {
    gap: 26px;
  }
}
@media (max-width: 600px) {
  .ai-shell {
    padding: 16px 16px 40px;
  }
  .ai-panel {
    padding: 18px;
  }
  .ai-info {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .ai-boards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ai-pair {
    gap: 8px;
  }
  .ai-stage {
    height: 240px;
  }
  .ai-dialog {
    padding: 14px;
  }
  .ai-actions .ai-button {
    flex-grow: 1;
  }
}
.ai-field .ai-actions {
  flex-wrap: nowrap;
}
.ai-field .ai-actions input {
  min-width: 0;
  flex: 1;
}
.ai-field .ai-actions button {
  flex-shrink: 0;
}
.ai-progress {
  appearance: none;
  border: 0;
  background: #333;
  border-radius: 8px;
  overflow: hidden;
}
.ai-progress::-webkit-progress-bar {
  background: #333;
}
.ai-progress::-webkit-progress-value {
  background: #eee;
}
.ai-progress::-moz-progress-bar {
  background: #eee;
}
.ai-help details[data-target="false"] summary svg {
  transform: rotate(0deg);
}
.ai-help details[data-target="true"] summary svg {
  transform: rotate(180deg);
}
.ai-help h2 {
  font-size: 25px;
  font-weight: 700;
  margin-bottom: 16px;
}
.ai-result button {
  border: 0;
  background: none;
  padding: 0;
  cursor: zoom-in;
}
.ai-result button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  .ai-shell *,
  .ai-help *,
  .ai-dialog * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
