.avc {
  --avc-bg: #08111f;
  --avc-bg-2: #0c1629;
  --avc-surface: rgba(255, 255, 255, 0.075);
  --avc-surface-2: rgba(255, 255, 255, 0.11);
  --avc-text: #eef4ff;
  --avc-muted: #a8b4ca;
  --avc-muted-2: #75829a;
  --avc-line: rgba(255, 255, 255, 0.13);
  --avc-accent: #8b5cf6;
  --avc-accent-2: #06b6d4;
  --avc-good: #22c55e;
  --avc-danger: #ef4444;
  --avc-warning: #f59e0b;
  --avc-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --avc-font:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Arial, Helvetica, sans-serif;

  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  color: var(--avc-text);
  font-family: var(--avc-font);
  line-height: 1.5;
}

.avc *,
.avc *::before,
.avc *::after {
  box-sizing: border-box;
}

.avc button,
.avc input,
.avc select {
  font: inherit;
}

.avc button,
.avc input,
.avc select,
.avc label {
  -webkit-tap-highlight-color: transparent;
}

.avc button {
  color: inherit;
}

.avc img {
  display: block;
  max-width: 100%;
}

.avc [hidden] {
  display: none !important;
}

.avc-shell {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 20px 14px 60px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 8% -4%, rgba(139, 92, 246, 0.25), transparent 34%),
    radial-gradient(circle at 92% 10%, rgba(6, 182, 212, 0.18), transparent 30%),
    linear-gradient(180deg, var(--avc-bg), #050914 72%);
}

.avc-hero {
  margin-bottom: 24px;
}

.avc-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(27px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.avc-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--avc-muted);
  font-size: 15px;
}

.avc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  align-items: start;
}

.avc-card,
.avc-result {
  border: 1px solid var(--avc-line);
  border-radius: 20px;
  background: var(--avc-surface);
}

.avc-card {
  margin-bottom: 16px;
  padding: 18px;
}

.avc-card h2 {
  margin: 0 0 14px;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.avc-help {
  margin: -6px 0 14px;
  color: var(--avc-muted);
  font-size: 13px;
}

.avc-search {
  position: relative;
  z-index: 20;
}

.avc-input,
.avc-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--avc-line);
  border-radius: 12px;
  outline: none;
  background: rgba(0, 0, 0, 0.25);
  color: var(--avc-text);
}

.avc-input:focus,
.avc-select:focus {
  border-color: var(--avc-accent-2);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.11);
}

.avc-results {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  z-index: 100;
  max-height: min(420px, 60vh);
  overflow: auto;
  border: 1px solid var(--avc-line);
  border-radius: 14px;
  background: var(--avc-bg-2);
  box-shadow: var(--avc-shadow);
  overscroll-behavior: contain;
}

.avc-search-message {
  padding: 14px;
  color: var(--avc-muted);
  font-size: 13px;
  text-align: center;
}

.avc-search-result {
  display: grid;
  width: 100%;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--avc-line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.avc-search-result:last-child {
  border-bottom: 0;
}

.avc-search-result:hover,
.avc-search-result:focus-visible {
  outline: none;
  background: var(--avc-surface-2);
}

.avc-search-image {
  width: 52px;
  height: 52px;
  border: 1px solid var(--avc-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  object-fit: cover;
}

.avc-search-copy {
  min-width: 0;
}

.avc-search-title,
.avc-search-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avc-search-title {
  font-size: 13px;
  font-weight: 800;
}

.avc-search-meta {
  color: var(--avc-muted-2);
  font-size: 11px;
}

.avc-search-price {
  color: var(--avc-accent-2);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.avc-or {
  margin: 14px 0;
  color: var(--avc-muted-2);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.avc-goal-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 125px;
  gap: 10px;
}

.avc-emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.avc-emoji {
  width: 36px;
  height: 36px;
  border: 1px solid var(--avc-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 18px;
  cursor: pointer;
}

.avc-emoji.is-active {
  border-color: var(--avc-accent);
  background: rgba(139, 92, 246, 0.25);
}

.avc-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.avc-upload-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 9px 13px;
  border: 1px solid var(--avc-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  cursor: pointer;
}

.avc-upload-input {
  display: none;
}

.avc-image-preview {
  width: 52px;
  height: 52px;
  border: 1px solid var(--avc-line);
  border-radius: 12px;
  object-fit: cover;
}

.avc-image-status {
  color: var(--avc-muted-2);
  font-size: 11px;
}

.avc-habits {
  display: grid;
  gap: 8px;
}

.avc-habit {
  position: relative;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.avc-habit.is-enabled {
  border-color: rgba(139, 92, 246, 0.36);
  background: rgba(139, 92, 246, 0.1);
}

.avc-habit.is-custom {
  border-color: rgba(6, 182, 212, 0.23);
}

.avc-habit-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
}

.avc-habit-emoji {
  font-size: 24px;
  text-align: center;
}

.avc-habit-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avc-habit-unit {
  margin-top: 2px;
  color: var(--avc-muted-2);
  font-size: 11px;
}

.avc-habit-value {
  color: var(--avc-accent-2);
  font-size: 14px;
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.avc-habit-value small {
  display: block;
  color: var(--avc-muted-2);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.avc-habit-body {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--avc-line);
}

.avc-habit.is-enabled .avc-habit-body {
  display: grid;
}

.avc-field label {
  display: block;
  margin-bottom: 5px;
  color: var(--avc-muted);
  font-size: 11px;
  font-weight: 700;
}

.avc-number-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 8px;
  align-items: center;
}

.avc-range {
  width: 100%;
  accent-color: var(--avc-accent-2);
}

.avc-number {
  width: 100%;
  padding: 6px;
  border: 1px solid var(--avc-line);
  border-radius: 8px;
  outline: none;
  background: rgba(0, 0, 0, 0.3);
  color: var(--avc-accent-2);
  text-align: center;
}

.avc-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.13);
  color: #fca5a5;
  cursor: pointer;
}

.avc-add-habit {
  width: 100%;
  margin-top: 9px;
  padding: 13px;
  border: 2px dashed rgba(6, 182, 212, 0.38);
  border-radius: 14px;
  background: rgba(6, 182, 212, 0.05);
  color: #67e8f9;
  font-weight: 800;
  cursor: pointer;
}

.avc-result {
  position: sticky;
  top: 20px;
  padding: 20px;
  background:
    linear-gradient(
      180deg,
      rgba(139, 92, 246, 0.12),
      rgba(6, 182, 212, 0.06)
    );
}

.avc-goal-summary {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 16px;
}

.avc-goal-thumb {
  display: grid;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--avc-line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 28px;
}

.avc-goal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avc-result-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.avc-result-price {
  color: var(--avc-accent-2);
  font-size: 14px;
  font-weight: 800;
}

.avc-result-days {
  margin: 10px 0 4px;
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
}

.avc-result-days small {
  color: var(--avc-muted);
  font-size: 15px;
  letter-spacing: 0;
}

.avc-result-sub {
  color: var(--avc-muted);
  font-size: 13px;
}

.avc-message {
  margin-top: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.avc-message.is-good {
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
}

.avc-message.is-info {
  border: 1px solid rgba(6, 182, 212, 0.3);
  background: rgba(6, 182, 212, 0.12);
  color: #67e8f9;
}

.avc-message.is-warning {
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.avc-bars {
  display: grid;
  gap: 8px;
  margin-top: 13px;
}

.avc-bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 3px;
  font-size: 12px;
}

.avc-bar-track {
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
}

.avc-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    var(--avc-accent),
    var(--avc-accent-2)
  );
}

.avc-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.avc-button {
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--avc-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
  font-weight: 800;
  cursor: pointer;
}

.avc-button:hover {
  background: var(--avc-surface-2);
}

.avc-button.is-primary {
  border-color: transparent;
  background: linear-gradient(
    135deg,
    var(--avc-accent),
    var(--avc-accent-2)
  );
  color: #fff;
}

.avc-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.avc-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding:
    max(14px, env(safe-area-inset-top))
    14px
    max(14px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.avc-modal.is-open {
  display: flex;
}

.avc-modal-card {
  width: min(780px, 100%);
  max-height: 94vh;
  max-height: 94dvh;
  overflow-y: auto;
  padding: 17px;
  border: 1px solid var(--avc-line);
  border-radius: 20px;
  background: var(--avc-bg-2);
  box-shadow: var(--avc-shadow);
}

.avc-modal-card.is-small {
  width: min(500px, 100%);
}

.avc-modal-card h3 {
  margin: 0 0 8px;
}

.avc-modal-card h4 {
  margin: 15px 0 8px;
  color: var(--avc-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.avc-modal-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 13px;
}

.avc-designer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.avc-designer-head p {
  margin: 4px 0 0;
  color: var(--avc-muted);
  font-size: 12px;
}

.avc-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.avc-choice {
  display: grid;
  gap: 4px;
  place-items: center;
  min-width: 0;
  padding: 5px;
  border: 1px solid var(--avc-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.avc-choice.is-active {
  border-color: var(--avc-accent-2);
  background: rgba(6, 182, 212, 0.15);
}

.avc-choice-preview {
  width: 100%;
  height: 34px;
  border-radius: 6px;
}

.avc-designer-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 14px;
}

.avc-toggle {
  display: flex;
  min-height: 45px;
  gap: 8px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--avc-line);
  border-radius: 12px;
  color: var(--avc-muted);
  font-size: 12px;
}

.avc-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--avc-accent-2);
}

.avc-canvas-shell {
  display: grid;
  min-height: 280px;
  place-items: center;
  margin-top: 14px;
  padding: 8px;
  border: 1px solid var(--avc-line);
  border-radius: 14px;
  background: #050914;
}

.avc-preview-canvas {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(62vh, 760px);
  border-radius: 10px;
  box-shadow: 0 20px 65px rgba(0, 0, 0, 0.5);
}

.avc-render-status {
  margin-top: 8px;
  color: var(--avc-muted-2);
  font-size: 11px;
  text-align: right;
}

.avc-form-grid {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 10px;
}

.avc-form-grid + .avc-form-grid {
  margin-top: 10px;
}

.avc-error {
  min-height: 20px;
  margin-top: 8px;
  color: #fca5a5;
  font-size: 12px;
}

.avc-toast {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 11000;
  max-width: calc(100% - 28px);
  padding: 11px 16px;
  border: 1px solid var(--avc-line);
  border-radius: 999px;
  opacity: 0;
  background: rgba(5, 9, 20, 0.96);
  color: var(--avc-text);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
  transform: translate(-50%, 25px);
  transition:
    opacity 0.2s,
    transform 0.2s;
  pointer-events: none;
}

.avc-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.avc[data-mode="compact"] .avc-hero {
  display: none;
}

.avc[data-mode="compact"] .avc-shell {
  padding-top: 14px;
}

@media (max-width: 860px) {
  .avc-grid {
    grid-template-columns: 1fr;
  }

  .avc-result {
    position: static;
  }
}

@media (max-width: 620px) {
  .avc-shell {
    padding-right: 9px;
    padding-left: 9px;
    border-radius: 18px;
  }

  .avc-card,
  .avc-result {
    padding: 14px;
  }

  .avc-goal-fields {
    grid-template-columns: minmax(0, 1fr) 105px;
  }

  .avc-habit-body,
  .avc-designer-options {
    grid-template-columns: 1fr;
  }

  .avc-choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .avc-modal-actions {
    grid-template-columns: 1fr;
  }

  .avc-designer-head {
    display: grid;
  }

  .avc-results {
    position: fixed;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: min(440px, 62vh);
  }

  .avc-search-result {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .avc-search-price {
    grid-column: 2;
    margin-top: -7px;
  }
}

@media (max-width: 390px) {
  .avc-habit-head {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 7px;
  }

  .avc-habit-name {
    font-size: 13px;
  }

  .avc-habit-value {
    font-size: 12px;
  }

  .avc-choice {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .avc *,
  .avc *::before,
  .avc *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
/* ============ Loading state ============ */
.avc-loading {
  display: flex;
  min-height: 320px;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 1px solid var(--avc-line, rgba(255, 255, 255, 0.13));
  border-radius: 20px;
  background:
    radial-gradient(circle at 20% 0, rgba(139, 92, 246, 0.18), transparent 40%),
    #08111f;
  color: var(--avc-muted, #a8b4ca);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  text-align: center;
}

.avc-loading.is-error {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(127, 29, 29, 0.16);
  color: #fca5a5;
}
