:root {
  --background: 210 40% 98%;
  --foreground: 222 47% 11%;
  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;
  --muted: 210 40% 96%;
  --muted-foreground: 215 16% 40%;
  --border: 214 32% 91%;
  --input: 214 32% 91%;
  --ring: 199 89% 48%;
  --primary: 199 89% 48%;
  --primary-foreground: 0 0% 100%;
  --secondary: 32 98% 56%;
  --secondary-foreground: 24 100% 16%;
  --accent: 262 83% 58%;
  --accent-foreground: 0 0% 100%;
  --success: 160 84% 39%;
  --success-foreground: 0 0% 100%;
  --warning: 32 95% 44%;
  --destructive: 0 84% 60%;
  --radius: 1rem;
  --shadow: 0 1px 2px hsl(222 47% 11% / 0.04), 0 12px 32px hsl(210 40% 20% / 0.06);
  --shadow-lg: 0 24px 60px hsl(210 50% 20% / 0.1);
  --sans: "Plus Jakarta Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  font-family: var(--sans);
  line-height: 1.55;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 520px at 8% -8%, hsl(199 95% 82% / 0.7), transparent 58%),
    radial-gradient(720px 480px at 96% 4%, hsl(32 100% 84% / 0.75), transparent 52%),
    radial-gradient(640px 420px at 72% 100%, hsl(262 90% 88% / 0.55), transparent 55%);
}

.page {
  position: relative;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 80px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-end;
  margin-bottom: 28px;
}

.masthead-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  color: hsl(var(--muted-foreground));
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.lang-btn {
  appearance: none;
  border: 0;
  background: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 4px;
  border-radius: 6px;
  transition: color 120ms ease;
}

.lang-btn:hover,
.lang-btn:focus-visible {
  color: hsl(var(--primary));
}

.lang-btn.is-active {
  color: hsl(var(--primary));
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(145deg, hsl(199 89% 48%), hsl(262 83% 58%));
  color: white;
  box-shadow: 0 10px 24px hsl(199 89% 48% / 0.28);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: hsl(var(--primary));
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.privacy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px 8px 10px;
  border: 1px solid hsl(160 60% 80%);
  border-radius: 999px;
  background: hsl(160 84% 95%);
  color: hsl(160 70% 22%);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.privacy::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: hsl(var(--success));
  box-shadow: 0 0 0 4px hsl(160 84% 39% / 0.16);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 750;
  letter-spacing: -0.05em;
  line-height: 1;
}

.lede {
  max-width: 36rem;
  margin: 0;
  color: hsl(var(--muted-foreground));
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 20px;
}

.panel {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel-head,
.status-row,
.result-stats,
.stats,
.result-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.panel-head {
  align-items: baseline;
  margin-bottom: 16px;
}

h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
}

.text-btn {
  appearance: none;
  border: 0;
  background: none;
  color: hsl(var(--primary));
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
}

.text-btn:hover,
.text-btn:focus-visible {
  color: hsl(199 89% 32%);
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 196px;
  padding: 28px 16px;
  border: 1.5px dashed hsl(199 80% 72%);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, hsl(199 100% 97%), hsl(0 0% 100%)),
    hsl(var(--muted));
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.dropzone.is-hot {
  border-color: hsl(var(--primary));
  background: hsl(199 100% 95%);
  box-shadow: 0 0 0 4px hsl(199 89% 48% / 0.12);
}

.dropzone.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}

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

.dropzone-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 6px;
  border-radius: 16px;
  background: linear-gradient(160deg, hsl(199 89% 48%), hsl(199 89% 62%));
  color: white;
  box-shadow: 0 8px 18px hsl(199 89% 48% / 0.28);
}

.dropzone-mark svg {
  width: 24px;
  height: 24px;
}

.dropzone-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dropzone-hint,
.budget-copy,
.skipped,
.warning,
.status p,
.result-stats dd,
.file-meta,
.result-size {
  color: hsl(var(--muted-foreground));
}

.skipped {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: hsl(32 100% 95%);
  color: hsl(24 80% 28%);
  font-size: 0.88rem;
}

.file-list,
.result-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.file-card,
.result-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
}

.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  background: hsl(210 40% 92%);
}

.file-name,
.result-name {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta,
.result-size {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 0.74rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  color: hsl(var(--destructive));
  border-color: hsl(0 84% 80%);
  background: hsl(0 86% 97%);
}

.budget-copy {
  margin: 8px 0 20px;
}

.budget-control {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 4px 14px;
  border-bottom: 1px solid hsl(var(--border));
}

.budget-value {
  width: 5.2ch;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: clamp(3rem, 8vw, 4.2rem);
  font-weight: 750;
  letter-spacing: -0.06em;
  line-height: 1;
}

.budget-value:focus {
  outline: none;
}

.budget-value::-webkit-outer-spin-button,
.budget-value::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.budget-value[type="number"] {
  appearance: textfield;
}

.budget-unit {
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(32 100% 95%);
  color: hsl(24 90% 32%);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
}

.budget-unit:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.stats {
  margin: 20px 0;
}

.stats div,
.result-stats div {
  flex: 1;
  padding: 10px 12px;
  border-radius: 14px;
  background: hsl(var(--muted));
}

.stats div:nth-child(1) {
  background: hsl(199 100% 95%);
}

.stats div:nth-child(2) {
  background: hsl(262 100% 96%);
}

.stats div:nth-child(3) {
  background: hsl(32 100% 95%);
}

dt {
  color: hsl(var(--muted-foreground));
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dd {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 650;
}

.primary-btn {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px hsl(199 89% 48% / 0.28);
}

.primary-btn:hover:not(:disabled),
.primary-btn:focus-visible:not(:disabled) {
  background: hsl(199 89% 42%);
}

.primary-btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 3px;
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.status,
.result {
  margin-top: 22px;
}

.status-row {
  align-items: baseline;
  margin-bottom: 8px;
}

.status p {
  margin: 0;
  font-size: 0.88rem;
}

.track,
.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: hsl(var(--muted));
}

.track-fill,
.meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, hsl(199 89% 48%), hsl(262 83% 58%));
  transition: width 160ms ease;
}

.meter {
  margin-bottom: 16px;
}

.meter.is-over .meter-fill {
  background: linear-gradient(90deg, hsl(32 95% 50%), hsl(0 84% 60%));
}

.result-stats {
  margin: 0 0 16px;
}

.warning {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: hsl(32 100% 95%);
  color: hsl(24 80% 28%);
  font-size: 0.9rem;
}

.result-actions {
  margin-bottom: 14px;
}

.result-card {
  grid-template-columns: 48px minmax(0, 1fr) auto;
}

.result-card .thumb {
  width: 48px;
  height: 48px;
}

.download-link {
  color: hsl(var(--primary));
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
}

.download-link:hover,
.download-link:focus-visible {
  background: hsl(199 100% 95%);
  color: hsl(199 89% 28%);
}

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

@media (max-width: 860px) {
  .layout,
  .masthead {
    display: block;
  }

  .masthead-meta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1120px);
    padding-top: 22px;
  }

  .file-card,
  .result-card {
    grid-template-columns: 52px minmax(0, 1fr) auto;
  }

  .stats,
  .result-stats {
    flex-direction: column;
  }

  .pay-dialog {
    width: min(100% - 16px, 420px);
    padding: 18px 16px 16px;
  }

  .pay-dialog h2 {
    font-size: 1.45rem;
  }

  .pay-amount {
    margin-bottom: 12px;
    font-size: 2.1rem;
  }
}
