:root {
  color-scheme: light;
  --bg: #c8ced7;
  --bg-tint: #8d95a5;
  --surface: rgba(245, 248, 255, 0.72);
  --surface-strong: rgba(252, 253, 255, 0.92);
  --text: #171b24;
  --muted: #677386;
  --line: rgba(39, 56, 87, 0.12);
  --line-strong: rgba(39, 56, 87, 0.18);
  --accent: #24d7ff;
  --accent-strong: #9f4fff;
  --accent-soft: rgba(93, 132, 255, 0.1);
  --success-bg: rgba(36, 215, 255, 0.1);
  --success-text: #197f9a;
  --error-bg: rgba(255, 112, 177, 0.12);
  --error-text: #9b3d70;
  --shadow: 0 24px 70px rgba(32, 42, 64, 0.16);
  --radius-xl: 32px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

html {
  height: 100%;
  height: -webkit-fill-available;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.64), transparent 34%),
    radial-gradient(circle at left 18% top 28%, rgba(36, 215, 255, 0.24), transparent 24%),
    radial-gradient(circle at right 20% top 32%, rgba(181, 92, 255, 0.22), transparent 22%),
    radial-gradient(circle at center bottom, rgba(72, 101, 170, 0.18), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-tint) 100%);
}

button,
input,
select,
a {
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  display: grid;
  place-items: center;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.app-card {
  width: min(100%, 620px);
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.brand-mark {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.upload-form {
  margin-top: 22px;
  display: grid;
  gap: 14px;
}

.field-label {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.file-field input {
  width: 100%;
  min-height: 58px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.file-field input::file-selector-button {
  margin-right: 12px;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--accent-soft);
  color: #314264;
  font-weight: 700;
}

.file-summary {
  margin: 0;
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.95rem;
}

button,
.download-link {
  min-height: 56px;
  border-radius: 18px;
  padding: 16px 20px;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  touch-action: manipulation;
}

button {
  border: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #f7f7f4;
  letter-spacing: 0;
  box-shadow: 0 16px 32px rgba(98, 84, 219, 0.26);
}

.upload-form[data-busy="true"] button {
  opacity: 0.68;
}

.notice {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  line-height: 1.5;
}

.notice-error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid rgba(155, 61, 112, 0.16);
}

.progress-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(248, 250, 255, 0.72), rgba(241, 245, 255, 0.64));
  border: 1px solid var(--line);
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #4759ae;
  font-size: 0.9rem;
  font-weight: 700;
}

.progress-value {
  color: #5867ba;
  font-size: 0.95rem;
  font-weight: 700;
}

.progress-track {
  position: relative;
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(60, 79, 118, 0.1);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #27d8ff 0%, #5a82ff 52%, #b35cff 100%);
  transition: width 220ms ease;
  box-shadow: 0 0 18px rgba(95, 128, 255, 0.3);
}

.progress-track.is-indeterminate .progress-fill {
  width: 32%;
  animation: loading-sweep 1.2s ease-in-out infinite;
}

.progress-message {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.progress-actions {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.download-link {
  display: block;
  background: var(--success-bg);
  color: var(--success-text);
}

.cancel-button {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.44);
  color: var(--text);
  box-shadow: none;
}

.cancel-button:disabled {
  opacity: 0.66;
}

.meta {
  margin: 22px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta div {
  min-width: 120px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(249, 251, 255, 0.52);
  border: 1px solid var(--line);
}

.meta .meta-control {
  flex: 1 1 310px;
}

.meta dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.meta dd {
  margin: 0;
  font-weight: 600;
}

.model-picker {
  position: relative;
}

.model-trigger {
  width: 100%;
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 12px;
  padding: 6px 28px 6px 0;
  background:
    linear-gradient(45deg, transparent 50%, #53617a 50%) right 8px center / 7px 7px no-repeat,
    linear-gradient(135deg, #53617a 50%, transparent 50%) right 1px center / 7px 7px no-repeat;
  color: var(--text);
  box-shadow: none;
  text-align: left;
}

.model-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-trigger-meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.model-trigger:focus {
  outline: 2px solid rgba(93, 132, 255, 0.26);
  outline-offset: 4px;
}

.model-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: -8px;
  right: -8px;
  max-height: min(320px, 45vh);
  overflow-y: auto;
  padding: 8px;
  border-radius: 16px;
  background: rgba(252, 253, 255, 0.94);
  border: 1px solid var(--line-strong);
  box-shadow: 0 18px 44px rgba(32, 42, 64, 0.18);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.model-option {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  font-weight: 600;
  text-align: left;
}

.model-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-option span:last-child {
  color: var(--muted);
  font-size: 0.82rem;
}

.model-option[aria-selected="true"] {
  background: var(--accent-soft);
  color: #4759ae;
}

.model-trigger:disabled {
  opacity: 0.68;
}

.model-option:focus {
  outline: 2px solid rgba(93, 132, 255, 0.26);
  outline-offset: -2px;
}

code {
  font-family: "SF Mono", "Cascadia Code", monospace;
  font-size: 0.95em;
}

@keyframes loading-sweep {
  0% {
    transform: translateX(-140%);
  }
  100% {
    transform: translateX(330%);
  }
}

@media (hover: hover) and (pointer: fine) {
  button:hover,
  .download-link:hover {
    transform: translateY(-1px);
  }

  .model-trigger:hover,
  .model-option:hover {
    transform: none;
  }

  .model-option:hover {
    background: rgba(93, 132, 255, 0.08);
  }

  .model-option[aria-selected="true"]:hover {
    background: var(--accent-soft);
  }
}

@media (max-width: 640px) {
  .app-card {
    padding: 22px;
    border-radius: 28px;
  }

  .meta {
    display: grid;
    grid-template-columns: 1fr;
  }
}
