:root,
[data-theme="night"] {
  --bg: #0c0f14;
  --surface: #141a22;
  --surface-2: #1b2330;
  --border: #2a3545;
  --text: #e8edf4;
  --muted: #8b9bb4;
  --accent: #3dd6c3;
  --accent-dim: #2a9d8f;
  --accent-glow: rgba(61, 214, 195, 0.15);
  --danger: #f07178;
  --warning: #ffcc66;
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", monospace;
}

[data-theme="day"] {
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --border: #d5ddea;
  --text: #1a2332;
  --muted: #5c6b82;
  --accent: #0d9488;
  --accent-dim: #0f766e;
  --accent-glow: rgba(13, 148, 136, 0.12);
  --danger: #dc2626;
  --warning: #d97706;
  --shadow: 0 20px 50px rgba(20, 40, 80, 0.08);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 214, 195, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(42, 157, 143, 0.08), transparent),
    var(--bg);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-glow);
  border: 1px solid rgba(61, 214, 195, 0.35);
  color: var(--accent);
  font-size: 1.1rem;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rate-badge {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.rate-badge.ready {
  color: var(--accent);
  border-color: rgba(61, 214, 195, 0.4);
}

.rate-badge.limited {
  color: var(--warning);
  border-color: rgba(255, 204, 102, 0.4);
}

.rate-badge.unlimited {
  color: var(--accent);
  background: var(--accent-glow);
}

.theme-toggle-btn {
  min-width: 6.5rem;
  white-space: nowrap;
}

.about-section {
  margin-bottom: 1.75rem;
}

.about-intro {
  margin-bottom: 1rem;
}

.about-intro h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.about-intro p {
  margin: 0;
  max-width: 52rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

@media (max-width: 960px) {
  .about-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .about-grid {
    grid-template-columns: 1fr;
  }
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.about-card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent);
}

.about-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.about-card .tier-list.compact {
  margin-top: 0.25rem;
}

.about-card .tier-list.compact li {
  padding: 0.15rem 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.config-panel {
  margin-bottom: 1.15rem;
  padding: 0.9rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.config-title {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.config-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.config-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 560px) {
  .config-grid-2 {
    grid-template-columns: 1fr;
  }
}

.config-hint,
.result-empty-note {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.config-panel .field {
  margin-bottom: 0;
}

select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.result-meta {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  font-family: var(--mono);
  color: var(--muted);
}

.main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 860px) {
  .main {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.meta {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.25rem;
  background: var(--surface-2);
  border-radius: 10px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.tab.tab-locked {
  opacity: 0.45;
  cursor: not-allowed;
  position: relative;
}

.tab.tab-locked::after {
  content: "🔒";
  font-size: 0.7rem;
  margin-left: 0.25rem;
}

.tab.active {
  background: var(--bg);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.video-lock-note {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 204, 102, 0.35);
  background: rgba(255, 204, 102, 0.08);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.video-lock-note a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.video-lock-note a:hover {
  text-decoration: underline;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

textarea,
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus,
input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.uploads {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 520px) {
  .uploads {
    grid-template-columns: 1fr;
  }
}

.upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.85rem 0.5rem;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}

.upload-card:hover,
.upload-card.has-file {
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

.upload-icon {
  font-size: 1.25rem;
}

.upload-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.upload-hint {
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
  max-width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}

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

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

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #06221e;
  border: none;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent-dim);
}

.btn-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.full-width {
  width: 100%;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(6, 34, 30, 0.25);
  border-top-color: #06221e;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.result-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.result-empty p {
  margin: 0 0 1.25rem;
}

.tier-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  text-align: left;
  display: inline-block;
}

.tier-list li {
  padding: 0.35rem 0;
}

.tier-list strong {
  color: var(--text);
}

.result-content {
  min-height: 200px;
}

.result-text {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.65;
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.result-image,
.result-video {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.result-message {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.auth-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 400px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow);
}

.auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.auth-dialog-inner {
  padding: 1.5rem;
  position: relative;
}

.dialog-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.auth-dialog h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.auth-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.auth-panel-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.auth-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.about-look-label {
  margin: 1rem 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.about-preview {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.about-preview li + li {
  margin-top: 0.25rem;
}

.user-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.user-email {
  margin: 0;
  font-weight: 600;
}

.referral-box {
  padding: 0.85rem;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.referral-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.referral-row code {
  flex: 1;
  padding: 0.45rem 0.6rem;
  background: var(--bg);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--accent);
}

.referral-status {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.error {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--danger);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  z-index: 100;
  animation: fadeUp 0.25s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-compact {
  width: auto;
  padding: 0.55rem 1rem;
}

a.btn {
  text-decoration: none;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  gap: 1rem;
}

.auth-about-card {
  margin-top: 0;
}

.auth-back {
  align-self: flex-start;
  max-width: 440px;
  width: 100%;
  margin-bottom: 1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.auth-back:hover {
  color: var(--accent);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.auth-card-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.auth-footer {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-benefits {
  margin: 1.5rem 0 0;
  padding: 1rem 1rem 1rem 1.75rem;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-benefits li {
  padding: 0.25rem 0;
}

.auth-benefits strong {
  color: var(--text);
}

@media (max-width: 900px) {
  .header-actions {
    gap: 0.5rem;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 1rem;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .header-auth {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .header-auth .btn {
    flex: 1;
    min-width: 0;
  }

  .theme-toggle-btn {
    min-width: 0;
  }

  .rate-badge {
    font-size: 0.75rem;
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  .auth-card {
    padding: 1.25rem;
  }
}
