:root {
  --bg: #0d0e12;
  --surface: #16181e;
  --border: #2a2d36;
  --text: #e6e8ec;
  --muted: #8b8f99;
  --accent: #00d4aa;
  --accent-hover: #00f0c0;
  --danger: #ff6b6b;
  --radius: 12px;
  --font-sans: 'Unbounded', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.title {
  font-family: var(--font-sans);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.main {
  flex: 1;
}

.auth-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.auth-status {
  font-size: 0.9rem;
  color: var(--accent);
  margin-right: auto;
}

.auth-user {
  font-size: 0.9rem;
  color: var(--muted);
}

.btn-sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
}

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-modal[hidden] {
  display: none !important;
}

.auth-modal-inner {
  position: relative;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 360px;
  width: 90%;
}

.auth-modal-title {
  margin: 0 0 1.25rem;
  font-size: 1.2rem;
}

.auth-modal-inner .input {
  width: 100%;
  margin-bottom: 0.75rem;
}

.auth-modal-hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-modal-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

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

.auth-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.auth-modal-close:hover {
  color: var(--text);
}

.pricing-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.pricing-modal[hidden] {
  display: none !important;
}

.pricing-modal-inner {
  position: relative;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.pricing-modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.pricing-modal-inner .pricing-cards {
  margin: 1rem 0;
}

.pricing-modal-close {
  margin-top: 1rem;
  width: 100%;
  padding: 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  border-radius: var(--radius);
  cursor: pointer;
}

.pricing-modal-close:hover {
  color: var(--text);
}

.pricing-auth {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--accent-hover);
}

.pricing {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pricing-title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
}

.pricing-desc {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.pricing-free {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--accent);
}

.pricing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.pricing-card {
  position: relative;
  padding: 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pricing-card-yearly {
  border-color: var(--accent);
}

.pricing-badge {
  position: absolute;
  top: -0.5rem;
  right: 0.75rem;
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pricing-name {
  font-size: 0.9rem;
  color: var(--muted);
}

.pricing-price {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.pricing-period {
  font-size: 0.85rem;
  color: var(--muted);
}

.btn-subscribe {
  margin-top: 0.5rem;
  width: 100%;
}

.pricing-active {
  margin: 0;
  font-size: 0.9rem;
  color: var(--accent);
}

.pricing-hd-credits {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.pricing-card-hd {
  border-color: var(--accent);
}

.format-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.35rem;
}

.format-badge-free {
  background: rgba(0, 212, 170, 0.2);
  color: var(--accent);
}

.format-badge-paid {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}

.paywall {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--danger);
}

.form {
  margin-bottom: 1.5rem;
}

.input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: stretch;
}

.input {
  flex: 1;
  min-width: 200px;
  padding: 0.85rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
}

.input::placeholder {
  color: var(--muted);
}

.input:focus {
  border-color: var(--accent);
}

.select-wrap {
  position: relative;
}

.select {
  appearance: none;
  padding: 0.85rem 2.5rem 0.85rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  outline: none;
  min-width: 140px;
  transition: border-color 0.2s;
}

.select:focus {
  border-color: var(--accent);
}

.select-wrap::after {
  content: '';
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-top-color: var(--muted);
  pointer-events: none;
}

.btn {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

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

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-download {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
}

.btn-download:hover:not(:disabled) {
  background: rgba(0, 212, 170, 0.1);
}

.btn-download:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-download-link {
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.status {
  min-height: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.status.loading {
  color: var(--accent);
}

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

.formats {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.formats-title {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  margin: 0 0 0.25rem;
}

.formats-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.formats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.format-card {
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.format-card .label {
  font-size: 0.85rem;
  color: var(--muted);
}

.format-card .value {
  font-weight: 500;
  color: var(--text);
}

.footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.footer p {
  margin: 0;
}

@media (max-width: 520px) {
  .input-row {
    flex-direction: column;
  }

  .input,
  .select {
    width: 100%;
    min-width: 0;
  }
}
