:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-strong: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #111111;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-strong: #005cc5;
  --success: #10b981;
  --danger: #ef4444;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial,
    sans-serif;
  color: var(--text);
  background: #f5f5f7;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.topbar {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.panel,
.stats,
.card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.upload-panel,
.options-panel {
  padding: 18px;
}

.options-panel {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 160px;
  border-radius: calc(var(--radius-xl) - 10px);
  border: 1px dashed rgba(0, 0, 0, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), #ffffff);
  text-align: center;
  transition: 0.2s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  transform: translateY(-1px);
  border-color: rgba(0, 113, 227, 0.45);
  box-shadow: 0 10px 30px rgba(0, 113, 227, 0.08);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone strong {
  display: block;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.option {
  display: grid;
  gap: 10px;
  padding: 4px 0;
}

.option label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

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

.option select {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.option output {
  justify-self: end;
  color: var(--accent);
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 10px;
}

.primary-btn,
.secondary-btn,
.download-btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.primary-btn {
  color: #fff;
  background: var(--accent);
}

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

.secondary-btn {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}

.download-btn {
  min-height: 40px;
  padding: 0 14px;
  color: var(--text);
  background: #f2f2f7;
  border: 1px solid var(--border);
}

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

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

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

.stat {
  display: grid;
  gap: 5px;
}

.stat span {
  color: var(--muted);
  font-size: 0.86rem;
}

.stat strong {
  font-size: 1.7rem;
  letter-spacing: -0.04em;
}

.gallery {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.empty-state {
  padding: 38px;
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.card {
  padding: 18px;
}

.card-head,
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head h3 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: -0.03em;
}

.file-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.views {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

figure {
  margin: 0;
}

figcaption {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.frame {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border-radius: 14px;
  border: 0;
}

.original-frame {
  background: transparent;
}

.transparent-frame {
  background:
    linear-gradient(45deg, rgba(0, 0, 0, 0.045) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.045) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.045) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.045) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill {
  background: #eff6ff;
  color: #2563eb;
}

.hint-pill {
  background: #ecfdf5;
  color: var(--success);
}

.status-pill.is-error {
  background: #fef2f2;
  color: var(--danger);
}

@media (max-width: 920px) {
  .options-panel {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .primary-btn,
  .secondary-btn {
    flex: 1;
  }

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

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

@media (max-width: 640px) {
  .app {
    width: min(100% - 18px, 1160px);
    padding-top: 18px;
  }

  .panel,
  .stats,
  .card,
  .empty-state {
    border-radius: 24px;
  }

  .upload-panel,
  .options-panel {
    padding: 14px;
  }

  .dropzone {
    min-height: 136px;
  }

  .card-head,
  .card-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
