:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Cloudflare Signature Orange */
  --cf-orange: #f38020;
  --cf-orange-hover: #fa8b28;
  --cf-orange-active: #dc6803;
  --cf-orange-tint: #fff5ed;
  --cf-orange-tint-border: #fed7aa;
  --cf-amber: #fba434;

  /* Google Material You / Flat Light Theme (Default clean & round) */
  --bg-app: #f0f4f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-input: #f8fafc;
  --border-card: #e2e8f0;
  --border-subtle: #edf2f7;

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;

  --accent-green: #059669;

  --shadow-flat: 0 1px 3px rgba(0, 0, 0, 0.04), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 6px 20px -2px rgba(243, 128, 32, 0.15);

  --radius-pill: 9999px;
  --radius-card: 24px;
  --radius-inner: 16px;
}

[data-theme="dark"] {
  --bg-app: #0f141c;
  --bg-card: #18202d;
  --bg-card-subtle: #1e2736;
  --bg-input: #131a24;
  --border-card: #283344;
  --border-subtle: #222c3b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --cf-orange-tint: rgba(243, 128, 32, 0.14);
  --cf-orange-tint-border: rgba(243, 128, 32, 0.35);

  --shadow-flat: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 6px 20px rgba(243, 128, 32, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
  padding-bottom: 50px;
}

/* App Container */
.app-layout {
  max-width: 980px;
  margin: 16px auto;
  padding: 0 20px;
}

/* Header */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px;
  margin-bottom: 20px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon-pill {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-inner);
  background: var(--cf-orange-tint);
  border: 1px solid var(--cf-orange-tint-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon-pill svg {
  width: 24px;
  height: 24px;
  stroke: var(--cf-orange);
}

.brand-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-heading h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.cf-badge {
  background: var(--cf-orange-tint);
  color: var(--cf-orange);
  border: 1px solid var(--cf-orange-tint-border);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
}

.round-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-flat);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.round-action-btn:hover {
  background: var(--bg-card-subtle);
  color: var(--cf-orange);
  border-color: var(--cf-orange-tint-border);
  transform: scale(1.05);
}

/* Material You Ultra-Round Cards */
.flat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 32px 28px;
  box-shadow: var(--shadow-flat);
  margin-bottom: 24px;
  transition: all 0.2s ease;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed var(--border-card);
  border-radius: 20px;
  background: var(--bg-card-subtle);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--cf-orange);
  background: var(--cf-orange-tint);
  transform: scale(1.01);
  box-shadow: var(--shadow-hover);
}

.upload-icon-wrapper {
  width: 68px;
  height: 68px;
  border-radius: 22px;
  background: var(--cf-orange-tint);
  border: 1px solid var(--cf-orange-tint-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.dropzone:hover .upload-icon-wrapper {
  transform: translateY(-4px);
}

.upload-icon-wrapper svg {
  width: 32px;
  height: 32px;
  stroke: var(--cf-orange);
}

.upload-text-main {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.upload-text-sub {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.btn-upload-pill {
  padding: 11px 26px;
  font-size: 0.92rem;
  font-weight: 700;
  background: var(--cf-orange);
  border: none;
  border-radius: var(--radius-pill);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(243, 128, 32, 0.3);
  transition: all 0.2s ease;
}

.btn-upload-pill:hover {
  background: var(--cf-orange-hover);
  box-shadow: 0 6px 20px rgba(243, 128, 32, 0.45);
}

/* Uploading State & Progress */
.upload-progress-box {
  display: none;
  width: 100%;
  margin-top: 10px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--border-card);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cf-orange), var(--cf-amber));
  transition: width 0.3s ease;
}

/* Result Section */
.result-card {
  display: none;
  margin-top: 24px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 24px;
}

.preview-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: center;
}

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

.preview-thumb-box {
  width: 100%;
  height: 160px;
  border-radius: 16px;
  border: 1px solid var(--border-card);
  background: var(--bg-card-subtle);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preview-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.result-tabs-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tab-pills-row {
  display: flex;
  gap: 8px;
}

.tab-pill {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-pill.active {
  background: var(--cf-orange-tint);
  border-color: var(--cf-orange);
  color: var(--cf-orange);
}

.link-output-box {
  display: flex;
  gap: 8px;
}

.pill-input {
  flex: 1;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  outline: none;
}

.btn-copy {
  padding: 10px 20px;
  font-size: 0.86rem;
  font-weight: 700;
  background: var(--cf-orange);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-copy:hover {
  background: var(--cf-orange-hover);
  transform: translateY(-1px);
}

/* Recent Uploads Section */
.history-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-clear-btn {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
}

.history-clear-btn:hover {
  color: var(--cf-orange);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
}

.history-card {
  border-radius: 14px;
  border: 1px solid var(--border-card);
  background: var(--bg-card-subtle);
  overflow: hidden;
  height: 110px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.history-card:hover {
  border-color: var(--cf-orange);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.history-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--cf-orange-tint-border);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
