:root {
  color-scheme: dark;
  --bg: #060a12;
  --panel: rgba(11, 18, 32, 0.86);
  --panel-strong: rgba(14, 24, 43, 0.96);
  --field: rgba(5, 12, 24, 0.86);
  --ink: #edf7ff;
  --muted: #90a4bb;
  --line: rgba(116, 144, 178, 0.22);
  --accent: #29e6ff;
  --accent-2: #8b5cf6;
  --accent-3: #34d399;
  --danger: #ff6b8a;
  --glow: 0 0 28px rgba(41, 230, 255, 0.2);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  --fast: 0.18s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(41, 230, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(41, 230, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(41, 230, 255, 0.18), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(139, 92, 246, 0.2), transparent 28%),
    linear-gradient(135deg, #050713 0%, #07101d 48%, #060a12 100%);
  background-size:
    42px 42px,
    42px 42px,
    auto,
    auto,
    auto;
  color: var(--ink);
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 18%);
}

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

button {
  cursor: pointer;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.tool-button,
.history-item {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: rgba(6, 11, 21, 0.78);
  backdrop-filter: blur(22px);
}

.brand,
.usage-row,
.button-row,
.result-toolbar,
.topbar-actions,
.dialog-header {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(41, 230, 255, 0.48);
  clip-path: polygon(18% 0, 82% 0, 100% 28%, 100% 72%, 82% 100%, 18% 100%, 0 72%, 0 28%);
  background:
    linear-gradient(135deg, rgba(41, 230, 255, 0.35), rgba(139, 92, 246, 0.32)),
    rgba(11, 21, 38, 0.95);
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
  letter-spacing: 0;
  box-shadow:
    inset 0 0 18px rgba(41, 230, 255, 0.2),
    0 0 26px rgba(41, 230, 255, 0.24);
  animation: pulseCore 3.4s ease-in-out infinite;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.brand-mark::before {
  width: 22px;
  height: 1px;
}

.brand-mark::after {
  width: 1px;
  height: 22px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-heading h3,
.section-heading p {
  margin: 0;
}

.brand h1 {
  max-width: 190px;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.16;
}

.brand p,
.section-heading p,
.eyebrow,
label,
.usage-row,
.price-card p,
.empty-state span,
.history-item span {
  color: var(--muted);
}

.brand p {
  max-width: 190px;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
}

.tool-nav {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(41, 230, 255, 0.42) transparent;
}

.tool-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(14, 24, 43, 0.62);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  transition:
    transform var(--fast),
    border-color var(--fast),
    background var(--fast),
    box-shadow var(--fast);
}

.tool-button:hover,
.tool-button.active {
  border-color: rgba(41, 230, 255, 0.7);
  background: linear-gradient(135deg, rgba(41, 230, 255, 0.13), rgba(139, 92, 246, 0.12));
  box-shadow: var(--glow);
  transform: translateX(2px);
}

.tool-button:active,
.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.icon-button:active,
.history-item:active {
  transform: translateY(1px) scale(0.992);
}

.tool-button[data-tool="image"],
.tool-button[data-tool="videoGen"] {
  border-color: rgba(52, 211, 153, 0.24);
}

.tool-button[data-tool="image"] .tool-icon,
.tool-button[data-tool="videoGen"] .tool-icon {
  color: var(--accent-3);
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(41, 230, 255, 0.26);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.82);
  color: var(--accent);
}

.tool-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 5px rgba(41, 230, 255, 0.34));
}

.tool-button:hover .tool-icon,
.tool-button.active .tool-icon {
  border-color: rgba(41, 230, 255, 0.7);
  background: rgba(41, 230, 255, 0.08);
  box-shadow: inset 0 0 16px rgba(41, 230, 255, 0.1);
}

.tool-button strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-button span {
  display: block;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.usage-panel {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(14, 24, 43, 0.72);
}

.usage-row,
.dialog-header {
  justify-content: space-between;
  gap: 14px;
}

.usage-track {
  height: 7px;
  margin: 10px 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(144, 164, 187, 0.14);
}

.usage-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px rgba(41, 230, 255, 0.42);
  transition: width 0.24s ease;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  margin-bottom: 16px;
}

.topbar > div:first-child {
  min-width: 0;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  overflow-wrap: anywhere;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.02;
  letter-spacing: 0;
}

.topbar-actions {
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  min-width: 0;
}

.topbar-actions > * {
  flex: 0 0 auto;
}

.topbar-actions .language-switch {
  flex: 1 1 186px;
  max-width: 240px;
  display: block;
}

.topbar-actions .language-switch > span {
  display: none;
}

.topbar-actions .language-switch select,
.topbar-actions .primary-button,
.topbar-actions .secondary-button,
.topbar-actions .icon-button {
  min-height: 42px;
}

.topbar-actions .account-button {
  flex: 0 1 auto;
  min-width: 42px;
}

.generator-layout {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.input-panel,
.output-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: riseIn 0.28s ease both;
}

.input-panel {
  padding: 16px;
}

.output-panel {
  min-height: calc(100vh - 96px);
  padding: 16px;
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading h3 {
  color: var(--ink);
  font-size: 16px;
}

.section-heading p {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.42;
}

.compact {
  margin: 0;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
  font-size: 12px;
  font-weight: 800;
}

.language-switch,
.api-switch {
  min-width: 156px;
  margin: 0;
  gap: 4px;
}

.api-switch {
  min-width: 142px;
}

.field-grid .api-switch {
  min-width: 0;
}

.account-button {
  max-width: 170px;
  padding: 0 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  transition:
    border-color var(--fast),
    box-shadow var(--fast),
    background var(--fast);
}

input::placeholder,
textarea::placeholder {
  color: rgba(144, 164, 187, 0.66);
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

textarea {
  min-height: 76px;
  max-height: 132px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(41, 230, 255, 0.72);
  background: rgba(6, 14, 28, 0.95);
  box-shadow: 0 0 0 3px rgba(41, 230, 255, 0.12);
}

.file-input-native {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.file-picker-ui {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(41, 230, 255, 0.08), rgba(139, 92, 246, 0.06)),
    var(--field);
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color var(--fast),
    box-shadow var(--fast),
    transform var(--fast);
}

.file-picker-ui:hover,
.file-picker-ui:focus {
  border-color: rgba(41, 230, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(41, 230, 255, 0.1);
  outline: 0;
  transform: translateY(-1px);
}

.file-picker-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(41, 230, 255, 0.3);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.82);
}

.file-picker-icon::before,
.file-picker-icon::after {
  content: "";
  position: absolute;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(41, 230, 255, 0.5);
}

.file-picker-icon::before {
  width: 16px;
  height: 2px;
}

.file-picker-icon::after {
  width: 2px;
  height: 16px;
}

.file-picker-ui strong,
.file-picker-ui small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker-ui small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.upload-preview {
  display: grid;
  gap: 8px;
  margin: -2px 0 12px;
  padding: 10px;
  border: 1px dashed rgba(41, 230, 255, 0.35);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.54);
  color: var(--muted);
  font-size: 12px;
}

.upload-preview[hidden] {
  display: none;
}

.upload-preview img {
  width: 100%;
  max-height: 180px;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.22);
}

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

.advanced-options {
  margin: 2px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.52);
  overflow: hidden;
}

.advanced-options summary {
  position: relative;
  min-height: 38px;
  padding: 10px 34px 10px 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  list-style: none;
  cursor: pointer;
}

.advanced-options summary::-webkit-details-marker {
  display: none;
}

.advanced-options summary::after {
  content: "+";
  position: absolute;
  top: 8px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(41, 230, 255, 0.26);
  border-radius: 8px;
  background: rgba(14, 24, 43, 0.95);
  color: var(--accent);
  font-weight: 900;
  transition: transform var(--fast);
}

.advanced-options[open] {
  padding: 0 12px 2px;
}

.advanced-options[open] summary {
  margin: 0 -12px 10px;
  border-bottom: 1px solid var(--line);
}

.advanced-options[open] summary::after {
  transform: rotate(45deg);
}

.button-row,
.result-toolbar {
  gap: 8px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 900;
  transition:
    transform var(--fast),
    box-shadow var(--fast),
    border-color var(--fast),
    background var(--fast),
    color var(--fast);
}

.primary-button {
  padding: 0 15px;
  background: linear-gradient(135deg, #12c6ff, #7c3aed);
  color: white;
  box-shadow: 0 0 24px rgba(41, 230, 255, 0.2);
}

.primary-button:hover {
  box-shadow: 0 0 34px rgba(41, 230, 255, 0.32);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.primary-button.is-loading {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.26) 48%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(135deg, #12c6ff, #7c3aed);
  background-size: 170% 100%, auto;
  animation: buttonScan 1.35s ease-in-out infinite;
}

.secondary-button,
.ghost-button,
.icon-button {
  background: rgba(14, 24, 43, 0.76);
  color: var(--ink);
  border-color: var(--line);
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: rgba(41, 230, 255, 0.7);
  color: var(--accent);
  transform: translateY(-1px);
}

.ghost-button {
  width: 100%;
  min-height: 34px;
  font-size: 12px;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.wide {
  flex: 1 1 190px;
}

.result-toolbar {
  justify-content: flex-end;
  margin-bottom: 10px;
}

.result-box {
  position: relative;
  min-height: 340px;
  max-height: calc(100vh - 278px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(41, 230, 255, 0.055), transparent 34%),
    rgba(5, 12, 24, 0.72);
  color: #e9f6ff;
  white-space: pre-wrap;
  line-height: 1.66;
  animation: softPop 0.22s ease;
}

.result-box.is-generating {
  overflow: hidden;
  border-color: rgba(41, 230, 255, 0.42);
  box-shadow:
    inset 0 0 32px rgba(41, 230, 255, 0.08),
    0 0 24px rgba(41, 230, 255, 0.1);
}

.result-box.is-complete {
  animation: resultArrive 0.72s ease both;
}

.click-spark {
  position: absolute;
  z-index: 0;
  width: var(--spark-size, 140px);
  height: var(--spark-size, 140px);
  pointer-events: none;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(237, 247, 255, 0.38), rgba(41, 230, 255, 0.2) 42%, transparent 72%);
  transform: translate(-50%, -50%) scale(0.04);
  animation: clickSpark 0.62s ease-out forwards;
}

.generation-wait {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 22px;
  min-height: 100%;
  text-align: center;
  color: var(--muted);
  background:
    linear-gradient(180deg, rgba(5, 12, 24, 0.82), rgba(5, 12, 24, 0.9)),
    radial-gradient(circle at 50% 28%, rgba(41, 230, 255, 0.12), transparent 46%);
  backdrop-filter: blur(6px);
  animation: waitFadeIn 0.18s ease both;
}

.generation-wait strong {
  color: var(--ink);
  font-size: 18px;
}

.generation-wait p {
  max-width: 440px;
  margin: 0;
}

.wait-orbit {
  position: relative;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(41, 230, 255, 0.28);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(41, 230, 255, 0.12), transparent 58%);
  animation: breatheGlow 1.8s ease-in-out infinite;
}

.wait-orbit span {
  position: absolute;
  inset: 13px;
  border-radius: inherit;
  border: 1px solid transparent;
  border-top-color: rgba(41, 230, 255, 0.84);
  animation: spinSoft 1.25s linear infinite;
}

.wait-orbit span:nth-child(2) {
  inset: 20px;
  border-top-color: rgba(139, 92, 246, 0.78);
  animation-duration: 1.85s;
  animation-direction: reverse;
}

.wait-orbit span:nth-child(3) {
  inset: 5px;
  border-top-color: rgba(52, 211, 153, 0.52);
  animation-duration: 2.4s;
}

.wait-scan {
  position: relative;
  width: min(320px, 82%);
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(116, 144, 178, 0.16);
}

.wait-scan::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(41, 230, 255, 0.8), transparent);
  animation: scanLine 1.55s ease-in-out infinite;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 292px;
  text-align: center;
}

.empty-state strong {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 17px;
}

.generated-image-card {
  display: grid;
  gap: 12px;
}

.generated-image-frame {
  display: grid;
  place-items: center;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid rgba(41, 230, 255, 0.24);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(41, 230, 255, 0.14), transparent 42%),
    rgba(4, 10, 20, 0.92);
}

.generated-image {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.generated-video {
  display: block;
  width: 100%;
  max-height: 520px;
  border-radius: 8px;
  background: #02060f;
}

.video-frame {
  min-height: 240px;
}

.image-placeholder {
  max-width: 460px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}

.generated-image-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.generated-image-meta a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.image-action-button {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.image-action-button:hover {
  color: var(--ink);
}

.image-prompt {
  max-height: 180px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.68);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.history-strip {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(14, 24, 43, 0.76);
  color: var(--ink);
  text-align: left;
}

.image-history-item {
  grid-template-columns: 46px minmax(0, 1fr);
}

.image-history-item img {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(41, 230, 255, 0.24);
  border-radius: 8px;
  object-fit: cover;
  background: rgba(5, 12, 24, 0.82);
}

.history-item:hover {
  border-color: rgba(41, 230, 255, 0.7);
}

.history-item strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span,
.empty-history {
  color: var(--muted);
  font-size: 11px;
}

.empty-history {
  margin: 0;
}

.pricing-dialog,
.auth-dialog,
.account-dialog,
.payment-dialog {
  width: min(780px, calc(100vw - 28px));
  border: 1px solid rgba(41, 230, 255, 0.24);
  border-radius: 8px;
  padding: 22px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: var(--shadow), var(--glow);
  animation: softPop 0.22s ease;
}

.auth-dialog {
  width: min(460px, calc(100vw - 28px));
}

.pricing-dialog::backdrop,
.auth-dialog::backdrop,
.account-dialog::backdrop,
.payment-dialog::backdrop {
  background: rgba(0, 4, 12, 0.7);
  backdrop-filter: blur(4px);
}

.account-dialog {
  width: min(520px, calc(100vw - 28px));
}

.account-info-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.account-info-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.46);
}

.account-info-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.account-info-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
}

.account-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.payment-dialog {
  width: min(760px, calc(100vw - 24px));
}

.payment-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.payment-qr-frame {
  display: grid;
  place-items: center;
  min-height: 300px;
  border: 1px dashed rgba(41, 230, 255, 0.42);
  border-radius: 8px;
  background: white;
  color: #172033;
  text-align: center;
}

.payment-qr-frame img {
  display: block;
  width: min(260px, 78vw);
  max-width: 100%;
  height: auto;
}

.payment-qr-frame img[src=""],
.payment-qr-frame img:not([src]) {
  display: none;
}

.payment-instructions {
  display: grid;
  align-content: start;
  gap: 12px;
}

.payment-instructions strong {
  font-size: 24px;
}

.payment-instructions label {
  margin: 0;
}

.payment-tip {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.72);
}

.auth-tab {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
  transition:
    background var(--fast),
    color var(--fast),
    box-shadow var(--fast);
}

.auth-tab.active {
  background: linear-gradient(135deg, rgba(41, 230, 255, 0.2), rgba(139, 92, 246, 0.22));
  color: var(--ink);
  box-shadow: inset 0 0 18px rgba(41, 230, 255, 0.1);
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.auth-form label {
  margin-bottom: 0;
}

.auth-dialog .register-only,
.auth-dialog .code-only,
.auth-dialog .reset-only,
.auth-dialog .verify-only {
  display: none;
}

.auth-dialog.is-register .register-only {
  display: grid;
}

.auth-dialog.is-verify .code-only,
.auth-dialog.is-verify .verify-only,
.auth-dialog.is-reset .code-only,
.auth-dialog.is-reset .reset-only {
  display: grid;
}

.auth-dialog.is-verify .auth-tabs,
.auth-dialog.is-recover .auth-tabs,
.auth-dialog.is-reset .auth-tabs,
.auth-dialog.is-verify .forgot-button,
.auth-dialog.is-register .forgot-button,
.auth-dialog.is-reset .forgot-button {
  display: none;
}

.auth-dialog.is-recover .register-only,
.auth-dialog.is-recover .code-only,
.auth-dialog.is-recover .reset-only,
.auth-dialog.is-recover .password-field,
.auth-dialog.is-verify .password-field {
  display: none;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--accent-3);
  font-size: 12px;
  font-weight: 800;
}

.auth-message.is-error {
  color: var(--danger);
}

.auth-dialog.is-busy {
  pointer-events: auto;
}

.auth-dialog.is-busy .auth-tab,
.auth-dialog.is-busy .forgot-button,
.auth-dialog.is-busy .verify-only {
  cursor: wait;
  opacity: 0.68;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.price-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.72);
}

.price-card.featured {
  border-color: rgba(41, 230, 255, 0.65);
  background: linear-gradient(180deg, rgba(41, 230, 255, 0.16), rgba(5, 12, 24, 0.78));
}

.price-card h3 {
  margin: 0 0 8px;
}

.price-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 32px;
}

.price-card button {
  width: 100%;
  margin-top: auto;
}

@keyframes pulseCore {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.25);
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes softPop {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes clickSpark {
  0% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(0.04);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes waitFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes buttonScan {
  0% {
    background-position: 160% 0, 0 0;
  }
  100% {
    background-position: -70% 0, 0 0;
  }
}

@keyframes breatheGlow {
  0%,
  100% {
    box-shadow: 0 0 14px rgba(41, 230, 255, 0.14);
    transform: scale(0.98);
  }
  50% {
    box-shadow: 0 0 28px rgba(41, 230, 255, 0.26);
    transform: scale(1.03);
  }
}

@keyframes spinSoft {
  to {
    transform: rotate(360deg);
  }
}

@keyframes scanLine {
  0% {
    transform: translateX(-115%);
  }
  100% {
    transform: translateX(250%);
  }
}

@keyframes resultArrive {
  0% {
    border-color: rgba(41, 230, 255, 0.72);
    box-shadow:
      inset 0 0 34px rgba(41, 230, 255, 0.18),
      0 0 34px rgba(41, 230, 255, 0.16);
    transform: translateY(2px);
  }
  100% {
    border-color: var(--line);
    box-shadow: none;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(190px, 230px);
    align-items: center;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tool-nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(145px, 1fr);
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .tool-button {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .usage-panel {
    margin-top: 0;
  }

  .generator-layout {
    grid-template-columns: 1fr;
  }

  .output-panel {
    min-height: auto;
  }

  .result-box {
    max-height: 520px;
  }
}

@media (max-width: 760px) {
  body {
    min-height: 100svh;
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .app-shell {
    min-height: 100svh;
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

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

  .brand {
    min-height: 44px;
  }

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

  .topbar-actions,
  .result-toolbar,
  .button-row {
    width: 100%;
  }

  .topbar-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .language-switch,
  .api-switch {
    min-width: 0;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  .topbar-actions .language-switch {
    flex: 1 1 auto;
    max-width: none;
    display: block;
  }

  .topbar-actions .language-switch > span {
    display: none;
  }

  .topbar-actions .language-switch select {
    height: 42px;
  }

  .topbar-actions .icon-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
  }

  .topbar-actions .account-button {
    min-width: 64px;
    max-width: 76px;
    min-height: 42px;
    padding: 0 10px;
  }

  .topbar-actions .primary-button {
    min-width: 78px;
    min-height: 42px;
    padding: 0 14px;
  }

  .result-toolbar,
  .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tool-nav {
    grid-auto-columns: 150px;
  }

  .tool-button {
    min-height: 62px;
  }

  .field-grid,
  .pricing-grid,
  .payment-layout {
    grid-template-columns: 1fr;
  }

  .account-info-row {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .payment-qr-frame {
    min-height: 260px;
  }

  .result-box {
    min-height: 220px;
    max-height: min(340px, 42svh);
  }

  .history-strip {
    margin-bottom: calc(34px + env(safe-area-inset-bottom, 0px));
    padding-bottom: 12px;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .generation-wait,
  .pricing-dialog::backdrop,
  .auth-dialog::backdrop,
  .payment-dialog::backdrop {
    backdrop-filter: none;
  }

  .pricing-dialog,
  .auth-dialog,
  .payment-dialog {
    animation: none;
  }

  .click-spark {
    display: none;
  }

  .primary-button.is-loading {
    animation: none;
  }
}
