:root {
  --bg: #08111b;
  --panel: rgba(12, 25, 39, 0.92);
  --panel-soft: rgba(22, 39, 58, 0.92);
  --line: rgba(133, 167, 196, 0.18);
  --text: #ecf6ff;
  --muted: #8ca4b7;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --warn: #f59e0b;
  --danger: #f87171;
  --ok: #34d399;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --font: "Segoe UI Variable", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.18), transparent 28%),
    radial-gradient(circle at right center, rgba(56, 189, 248, 0.16), transparent 24%),
    linear-gradient(180deg, #06111a, #08101a 45%, #04080c);
}

body {
  min-height: 100vh;
}

.app-shell {
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.topbar h1,
.workspace h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  letter-spacing: 0.02em;
}

.topbar-right {
  max-width: 380px;
  text-align: right;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.lang-switch {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(140, 164, 183, 0.10);
  border: 1px solid rgba(140, 164, 183, 0.16);
}

.lang-button {
  border: 0;
  border-radius: 999px;
  padding: 8px 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.lang-button.active {
  background: rgba(45, 212, 191, 0.16);
  color: var(--accent);
}

.status-pill {
  display: inline-flex;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.25);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-line,
.muted,
.panel span,
.hint-strip span {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  min-height: calc(100vh - 140px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar,
.inspector {
  padding: 18px;
  overflow: auto;
}

.workspace {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workspace-toolbar,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

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

.section h2 {
  margin: 0;
  font-size: 1.02rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), #38bdf8);
  color: #031019;
  font-weight: 700;
}

.button-ghost {
  background: rgba(140, 164, 183, 0.10);
  color: var(--text);
  border: 1px solid rgba(140, 164, 183, 0.16);
}

.button-danger {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.9rem;
}

.field input[type="range"],
.field select {
  width: 100%;
}

.field select,
#uploadInput {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 12px;
}

.checkbox {
  flex-direction: row;
  align-items: center;
}

.checkbox input {
  width: 18px;
  height: 18px;
}

.image-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 44vh;
  overflow: auto;
}

.folder-row,
.image-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px 12px calc(14px + var(--tree-depth, 0) * 18px);
  border-radius: 16px;
  background: rgba(140, 164, 183, 0.08);
  border: 1px solid transparent;
  transition: border-color 140ms ease, background 140ms ease;
}

.folder-row {
  grid-template-columns: 1fr auto;
  border-style: dashed;
  border-color: rgba(140, 164, 183, 0.12);
  background: rgba(22, 39, 58, 0.5);
}

.tree-row-title {
  font-weight: 700;
}

.tree-row-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.image-row {
  cursor: pointer;
}

.image-row:hover,
.image-row.active {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.08);
}

.image-name {
  margin: 0 0 4px;
  font-weight: 700;
  word-break: break-word;
}

.image-meta {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: pre-line;
}

.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  background: rgba(52, 211, 153, 0.14);
  color: var(--ok);
}

.canvas-card {
  position: relative;
  flex: 1 1 420px;
  min-height: 420px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(17, 33, 47, 0.72), rgba(8, 17, 27, 0.94)),
    radial-gradient(circle at center, rgba(45, 212, 191, 0.08), transparent 58%);
  overflow: hidden;
}

.canvas-stage {
  position: absolute;
  inset: 0;
}

#previewCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.compare-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.compare-ui input[type="range"] {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 18px;
  width: calc(100% - 56px);
  pointer-events: auto;
  accent-color: var(--accent);
}

.compare-label {
  position: absolute;
  top: 18px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(8, 17, 27, 0.72);
  border: 1px solid rgba(140, 164, 183, 0.22);
  font-size: 0.8rem;
  color: var(--text);
  backdrop-filter: blur(10px);
}

.compare-label-left {
  left: 18px;
}

.compare-label-right {
  right: 18px;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.auth-card {
  width: min(100%, 420px);
  padding: 28px;
  border-radius: 24px;
  background: rgba(10, 22, 34, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0 0 12px;
  font-size: 1.4rem;
}

.auth-card input[type="password"] {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.auth-error {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--danger);
}

.hint-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(140, 164, 183, 0.08);
}

.batch-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.batch-card strong {
  font-size: 1rem;
}

.batch-pill {
  min-width: 64px;
  justify-content: center;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(140, 164, 183, 0.16);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), #38bdf8);
  transition: width 180ms ease;
}

.batch-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.batch-result {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.84rem;
  border: 1px solid rgba(140, 164, 183, 0.14);
  background: rgba(14, 29, 44, 0.88);
}

.batch-result.ok {
  color: var(--text);
}

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

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

.stat-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(14, 29, 44, 0.88);
  border: 1px solid var(--line);
}

.stat-card strong {
  display: block;
  font-size: 1.45rem;
  margin-bottom: 4px;
}

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

  .sidebar,
  .inspector {
    max-height: none;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-right {
    text-align: left;
  }

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