:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --surface-3: #262626;
  --primary: #ffffff;
  --primary-light: #f2f2f2;
  --primary-dark: #d9d9d9;
  --secondary: #737373;
  --text: #ffffff;
  --text-muted: #a3a3a3;
  --text-dim: #737373;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --space-xs: 6px;
  --space-sm: 10px;
  --space: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --max-width: 760px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space) var(--space) var(--space-xl);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-top: env(safe-area-inset-top, 0);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space);
}

.header__logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.header__logo svg {
  width: 26px;
  height: 26px;
}

.header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header__subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.header__github {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 50%;
  border: 1px solid var(--border);
  transition: background 0.2s, transform 0.15s;
}

.header__github:hover,
.header__github:focus-visible {
  background: var(--surface-3);
  transform: scale(1.05);
}

.header__github svg {
  width: 22px;
  height: 22px;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero {
  position: relative;
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  background: linear-gradient(135deg, var(--surface) 60%, #171717 100%);
}

.hero__blob {
  position: absolute;
  top: -40px;
  right: -30px;
  width: 160px;
  height: 160px;
  background: var(--primary);
  opacity: 0.12;
  border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
  filter: blur(28px);
  pointer-events: none;
}

.hero__content {
  position: relative;
  z-index: 1;
}

.hero__title {
  margin: 0 0 var(--space-sm);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero__desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 560px;
}

/* Panel */
.panel {
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

/* Upload */
.upload {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: var(--space-lg);
  border: 2px dashed var(--surface-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload:hover,
.upload.is-dragover {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.04);
}

.upload__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload__content {
  pointer-events: none;
}

.upload__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-sm);
  color: var(--text-muted);
}

.upload__icon svg {
  width: 100%;
  height: 100%;
}

.upload__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.upload__hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Settings */
.settings {
  margin-top: var(--space-lg);
  display: grid;
  gap: var(--space-lg);
}

.settings__group {
  display: grid;
  gap: var(--space-sm);
}

.settings__subgroup {
  display: grid;
  gap: var(--space-sm);
  margin-top: var(--space);
  padding-top: var(--space);
  border-top: 1px solid var(--border);
}

.settings__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings__value {
  color: var(--primary);
  font-weight: 700;
}

.settings__note {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.settings__row {
  display: grid;
  gap: var(--space-sm);
}

.settings__dimensions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space);
  margin-top: var(--space-sm);
}

.settings__dimensions.is-hidden {
  display: none;
}

.field {
  display: grid;
  gap: var(--space-xs);
}

.field label {
  font-size: 12px;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.chip span {
  display: inline-flex;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.chip input:checked + span {
  background: var(--primary);
  color: #0a0a0a;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

.chip input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.chip--btn {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
}

.chip--btn.is-active span {
  background: var(--primary);
  color: #0a0a0a;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

/* Segmented control */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.segmented__btn {
  flex: 1 1 auto;
  min-width: 60px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
  white-space: nowrap;
}

.segmented__btn:hover {
  color: var(--text);
}

.segmented__btn.is-active {
  background: var(--primary);
  color: #0a0a0a;
  box-shadow: 0 4px 12px rgba(244, 162, 97, 0.25);
}

.segmented__btn:active {
  transform: scale(0.97);
}

/* Range */
.range {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  outline: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--surface);
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.18);
  transition: transform 0.1s;
}

.range::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--surface);
  box-shadow: 0 2px 8px rgba(244, 162, 97, 0.35);
}

/* Actions */
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  padding: var(--space) var(--space-lg);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.actions__info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 14px;
  color: var(--text-muted);
}

.dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-dim);
}

.actions__btns {
  display: flex;
  gap: var(--space-sm);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn--primary {
  background: var(--primary);
  color: #0a0a0a;
  box-shadow: 0 6px 18px rgba(255, 255, 255, 0.12);
}

.btn--primary:hover {
  background: var(--primary-light);
  box-shadow: 0 8px 22px rgba(255, 255, 255, 0.18);
}

.btn--primary:active {
  transform: scale(0.97);
}

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

.btn--secondary:hover {
  background: var(--surface-3);
}

.btn--sm {
  padding: 8px 14px;
  font-size: 13px;
}

/* File list */
.list {
  display: grid;
  gap: var(--space);
}

.file {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: var(--space);
  align-items: center;
  padding: var(--space);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.file__thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.file__info {
  min-width: 0;
}

.file__name {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file__meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.file__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.file__status--ready {
  background: rgba(255, 255, 255, 0.1);
  color: var(--primary);
}

.file__status--error {
  background: rgba(255, 255, 255, 0.08);
  color: var(--secondary);
}

.file__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  padding: 12px 20px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 100;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Footer */
.footer {
  margin-top: var(--space-xl);
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.8;
}

.footer p {
  margin: 0;
}

.footer a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer a:hover {
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 560px) {
  :root {
    --radius: 18px;
    --space: 14px;
    --space-lg: 20px;
  }

  .hero {
    padding: var(--space);
  }

  .hero__title {
    font-size: 20px;
  }

  .panel {
    padding: var(--space);
  }

  .upload {
    min-height: 160px;
    padding: var(--space);
  }

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

  .segmented {
    gap: 4px;
  }

  .segmented__btn {
    padding: 10px 8px;
    font-size: 12px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    padding: var(--space);
  }

  .actions__info {
    justify-content: center;
  }

  .actions__btns {
    width: 100%;
  }

  .actions__btns .btn {
    flex: 1;
  }

  .file {
    grid-template-columns: 64px 1fr;
    grid-template-rows: auto auto;
  }

  .file__thumb {
    width: 64px;
    height: 64px;
    grid-row: span 2;
  }

  .file__actions {
    grid-column: 2;
    flex-direction: row;
  }
}

@media (max-width: 380px) {
  .header__title {
    font-size: 16px;
  }

  .hero__title {
    font-size: 18px;
  }

  .upload__icon {
    font-size: 36px;
  }

  .upload__title {
    font-size: 14px;
  }

  .segmented__btn {
    font-size: 11px;
    padding: 9px 6px;
  }
}
