:root {
  --bg: #0c0c0c;
  --surface: #141414;
  --card: #1a1a1a;
  --card-hover: #202020;
  --border: #2a2a2a;
  --border-strong: #393939;
  --accent: #d4f53c;
  --accent-hover: #bfe22b;
  --white: #f1f1f1;
  --muted: #747474;
  --muted-light: #9b9b9b;
  --danger: #ff5c5c;
  --warning: #f59e0b;
  --success: #22c55e;
  --blue: #3b82f6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--white);
  font-family: "Syne", system-ui, sans-serif;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.03'/%3E%3C/svg%3E");
  content: "";
  opacity: 0.35;
  pointer-events: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: #0c0c0c;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.boot-screen,
.login-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.boot-screen {
  flex-direction: column;
  gap: 18px;
  color: var(--muted-light);
  font-family: "DM Mono", monospace;
  font-size: 12px;
}

.boot-mark {
  color: var(--accent);
  font-family: "Syne", sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.boot-loader {
  width: 30px;
  height: 30px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.login-box {
  position: relative;
  width: min(100%, 400px);
  padding: 48px 40px 36px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: 0 22px 70px rgb(0 0 0 / 35%);
  animation: fade-up 0.42s ease;
}

.login-box::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  content: "";
}

.login-logo {
  margin-bottom: 30px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.login-title {
  margin-bottom: 9px;
  font-size: clamp(25px, 6vw, 30px);
  font-weight: 800;
  line-height: 1.12;
}

.login-sub {
  margin-bottom: 34px;
  color: var(--muted-light);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.field-label,
.panel-heading {
  display: block;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.field-label {
  margin-bottom: 9px;
  color: var(--muted-light);
}

.field-input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  outline: none;
  color: var(--white);
  background: var(--card);
  font-family: "DM Mono", monospace;
  font-size: 14px;
  letter-spacing: 0.08em;
  transition: border-color 0.2s;
}

.field-input:focus {
  border-color: var(--accent);
}

.form-error {
  margin-top: 11px;
  color: var(--danger);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  line-height: 1.5;
}

.btn-primary,
.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border: 0;
  color: #0c0c0c;
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.2s;
}

.btn-primary {
  margin-top: 20px;
  padding: 14px;
}

.btn-primary:hover,
.btn-generate:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active,
.btn-generate:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-primary:disabled,
.btn-generate:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.login-security {
  margin-top: 20px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 70px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgb(12 12 12 / 94%);
  backdrop-filter: blur(14px);
}

.logo-area,
.header-right,
.api-status,
.result-meta,
.result-actions,
.history-heading {
  display: flex;
  align-items: center;
}

.logo-area {
  gap: 12px;
}

.logo-badge {
  padding: 5px 9px;
  color: #0c0c0c;
  background: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.logo-name {
  color: var(--muted-light);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.header-right {
  gap: 16px;
}

.api-status {
  gap: 7px;
  color: var(--muted-light);
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 7px var(--success);
}

.status-dot.error {
  background: var(--danger);
}

.btn-header,
.btn-action,
.btn-link {
  border: 1px solid var(--border-strong);
  color: var(--muted-light);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-header {
  padding: 9px 12px;
}

.btn-header:hover,
.btn-action:hover,
.btn-link:hover {
  border-color: var(--accent);
  color: var(--white);
}

.btn-action-primary {
  border-color: var(--accent);
  color: #0c0c0c;
  background: var(--accent);
}

.btn-action-primary:hover {
  color: #0c0c0c;
  background: var(--accent-hover);
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(430px, 1fr) minmax(430px, 1fr);
  min-height: calc(100vh - 70px);
}

.panel-left,
.panel-right {
  min-width: 0;
  padding: clamp(28px, 4vw, 48px);
}

.panel-left {
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--border);
}

.panel-right {
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 45%, rgb(212 245 60 / 3%), transparent 36%);
}

.form-section {
  min-width: 0;
}

.section-title {
  margin-top: 8px;
  margin-bottom: 14px;
  font-size: 17px;
  line-height: 1.3;
}

.section-sub {
  margin-top: 7px;
  margin-bottom: 13px;
  color: var(--muted-light);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

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

.gen-option {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  color: var(--muted-light);
  background: var(--card);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.gen-option:hover {
  border-color: #4a4a4a;
  color: var(--white);
  background: var(--card-hover);
}

.gen-option.active {
  border-color: var(--accent);
  color: var(--white);
  background: linear-gradient(100deg, rgb(212 245 60 / 7%), var(--card));
}

.gen-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.gen-option[data-platform="gemini"] .gen-dot { background: #4285f4; }
.gen-option[data-platform="gpt_image"] .gen-dot { background: #10a37f; }
.gen-option[data-platform="freepik"] .gen-dot { background: #ff6b2b; }
.gen-option[data-platform="midjourney"] .gen-dot { background: #f0f0f0; }

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

.gen-name,
.gen-tag {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gen-name {
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 700;
}

.gen-tag {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.style-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  color: var(--muted-light);
  background: var(--card);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  color: var(--white);
  border-color: #4a4a4a;
}

.chip.active {
  border-color: var(--accent);
  color: #0c0c0c;
  background: var(--accent);
}

.textarea-wrap {
  position: relative;
}

.idea-textarea {
  width: 100%;
  min-height: 230px;
  padding: 18px 18px 38px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  outline: none;
  color: var(--white);
  background: var(--card);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  line-height: 1.75;
  transition: border-color 0.2s;
}

.idea-textarea:focus {
  border-color: var(--accent);
}

.idea-textarea::placeholder {
  color: #626262;
}

.char-count {
  position: absolute;
  right: 13px;
  bottom: 13px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.btn-generate {
  min-height: 54px;
  margin-top: auto;
}

.btn-arrow {
  font-size: 16px;
}

.spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgb(12 12 12 / 30%);
  border-top-color: #0c0c0c;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-generate.loading .spinner {
  display: block;
}

.btn-generate.loading .btn-arrow {
  display: none;
}

.service-warning {
  margin-top: -18px;
  color: var(--warning);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.result-intro {
  flex: 0 0 auto;
}

.result-empty,
.result-loading {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 430px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  line-height: 1.8;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 17px;
  border: 1px solid var(--border-strong);
  color: #515151;
  font-size: 22px;
}

.result-loading p {
  margin-top: 17px;
  color: var(--muted-light);
}

.result-loading span {
  margin-top: 3px;
  font-size: 9px;
}

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

.result-card {
  margin-top: 28px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  animation: fade-up 0.32s ease;
}

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

.result-meta {
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.result-badge {
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-domain {
  color: var(--accent);
  border-color: rgb(212 245 60 / 35%);
}

.badge-platform {
  color: #8fb3ff;
  border-color: rgb(59 130 246 / 35%);
}

.result-name {
  max-width: 560px;
  font-size: 17px;
  line-height: 1.35;
}

.result-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.btn-action {
  padding: 8px 10px;
}

.prompt-output {
  margin: 0;
  padding: 24px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  color: #dadada;
  background: #111;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.specs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.spec-item {
  min-width: 0;
  padding: 15px 17px;
  border-right: 1px solid var(--border);
}

.spec-item:last-child {
  border-right: 0;
}

.spec-item dt,
.result-section h4 {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.spec-item dd {
  overflow-wrap: anywhere;
  color: var(--white);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  line-height: 1.5;
}

.result-section {
  padding: 19px 22px;
  border-bottom: 1px solid var(--border);
}

.result-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.result-section-heading h4 {
  margin-bottom: 0;
}

.btn-inline {
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  color: var(--muted-light);
  background: transparent;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn-inline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.parameters-instruction {
  margin-bottom: 10px;
  color: var(--muted-light);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  line-height: 1.6;
}

.result-section:last-child {
  border-bottom: 0;
}

.parameters-output {
  display: block;
  padding: 10px 12px;
  color: var(--accent);
  background: #101010;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.rationale-output,
.usage-output {
  color: var(--muted-light);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  line-height: 1.75;
}

.usage-output {
  padding-left: 12px;
  border-left: 2px solid var(--warning);
  color: #d7b36c;
}

.variations-list {
  display: grid;
  gap: 8px;
}

.variation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  background: #111;
}

.variation-preview {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted-light);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.variation-button {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  background: transparent;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.variation-button:hover {
  border-color: var(--accent);
  background: rgb(212 245 60 / 6%);
}

.history-strip {
  padding: 18px 28px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.history-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

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

.history-note {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 8px;
}

.btn-link {
  flex: 0 0 auto;
  padding: 7px 9px;
}

.history-items {
  display: flex;
  gap: 8px;
  padding-bottom: 5px;
  overflow-x: auto;
  scrollbar-color: var(--border-strong) transparent;
}

.history-item {
  flex: 0 0 220px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  color: var(--muted-light);
  background: var(--card);
  text-align: left;
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item strong,
.history-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item strong {
  margin-bottom: 4px;
  color: var(--white);
  font-size: 10px;
}

.history-item span {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 8px;
}

.toast {
  position: fixed;
  z-index: 999;
  right: 24px;
  bottom: 24px;
  max-width: min(390px, calc(100vw - 48px));
  padding: 13px 17px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--success);
  color: var(--white);
  background: var(--card);
  box-shadow: 0 12px 34px rgb(0 0 0 / 38%);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

.toast.warning {
  border-left-color: var(--warning);
}

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

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1040px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .panel-left {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .panel-right {
    min-height: 620px;
  }
}

@media (max-width: 680px) {
  .app-header {
    align-items: flex-start;
    padding: 14px 16px;
  }

  .logo-name {
    display: none;
  }

  .header-right {
    align-items: flex-end;
    flex-direction: column-reverse;
    gap: 8px;
  }

  .api-status {
    font-size: 8px;
  }

  .btn-header {
    padding: 7px 9px;
    font-size: 8px;
  }

  .panel-left,
  .panel-right {
    padding: 28px 18px;
  }

  .gen-selector {
    grid-template-columns: 1fr;
  }

  .idea-textarea {
    min-height: 250px;
  }

  .result-header {
    flex-direction: column;
  }

  .result-actions {
    justify-content: flex-start;
  }

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

  .spec-item {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .spec-item:last-child {
    border-bottom: 0;
  }

  .variation-item {
    grid-template-columns: 1fr;
  }

  .variation-button {
    justify-self: start;
  }

  .history-strip {
    padding: 17px 18px 22px;
  }

  .history-heading {
    align-items: flex-start;
  }

  .history-note {
    display: none;
  }
}

@media (max-width: 450px) {
  .login-box {
    padding: 42px 25px 30px;
  }

  .style-chips {
    gap: 6px;
  }

  .chip {
    padding: 8px 10px;
    font-size: 9px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
    max-width: calc(100vw - 32px);
  }
}

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