/**
 * PDFMERGE Stylesheet
 */

/* Self-hosted web fonts */
@font-face {
  font-family: 'Roboto';
  src: url('../fonts/web/roboto.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/web/jetbrains-mono.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Material Icons Outlined';
  src: url('../fonts/web/material-icons-outlined.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

.material-icons-outlined {
  font-family: 'Material Icons Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga';
}

/* ====================================
 * 1. CSS CUSTOM PROPERTIES (VARIABLES)
 * Centralized design tokens for consistency
 * ==================================== */

:root {
  /* Color Palette - Organized from lightest to darkest */
  --color-white: #ffffff;
  --color-blue-1: #0183ff;
  --color-blue-2: #005ab5;
  --color-blue-3: #004085;
  --color-cyan-1: #1fb2d3;
  --color-red-1: #c44438;
  --color-red-2: #913128;
  --color-green-1: #529a4a;
  --color-orange-1: #d76f24;
  --color-gray-1: #fafafa;
  --color-gray-2: #ebebeb;
  --color-gray-3: #bebebe;
  --color-gray-4: #999999;
  --color-gray-5: #666666;
  --color-gray-6: #4e4e4e;
  --color-gray-7: #303030;
  --color-gray-8: #1d1d1d;
  
  /* Typography */
  --font-family: "Roboto", sans-serif;
  --font-mono: "JetBrains Mono", "Courier New", monospace;
  --base-font-size: 1rem;
  --line-height: 1.4;
  
  /* Theme Variables - Light Mode */
  --bg-color: #f3f4f6;
  --surface-color: #ffffff;
  --surface2-color: #f6f7f9;
  --border-color: rgba(17, 24, 39, 0.08);
  --font-color: var(--color-gray-8);
  --font-color-2: var(--color-gray-5);
  --font-color-footer: var(--color-gray-5);
  
  /* Component-Specific Variables */
  --branding-font-color: var(--color-gray-8);
  --branding-span-font-color: var(--color-blue-1);
  --branding-font-size: 2.2rem;
  --branding-letter-spacing: -0.025em;
  
  --link-font-color: var(--font-color-2);
  --link-hover-color: var(--color-blue-2);
  --link-active-color: var(--color-blue-3);
  
  --hero-font-size: 1.6rem;
  --hero-line-height: 1.4;
  --hero-letter-spacing: 0.05em;
  
  --button-padding: 1.125rem 1.5rem;
  --button-border-radius: 4px;
  --button-bg-color: var(--color-blue-1);
  --button-hover-bg-color: var(--color-blue-2);
  --button-active-bg-color: var(--color-blue-3);
  --button-font-color: var(--color-gray-1);
  --button-disabled-font-color: var(--color-gray-6);
  --button-disabled-bg-color: var(--color-gray-4);
  --accent: var(--color-blue-1);
  --accent-dim: rgba(1, 131, 255, 0.1);
  --accent-glow: rgba(1, 131, 255, 0.2);
  
  --font-color-filelist: var(--color-gray-6);
  --bg-color-filelist: var(--surface-color);
  --card-shell-border: rgba(17, 24, 39, 0.08);
  --card-preview-stage-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(0, 0, 0, 0.03));
  --card-preview-stage-border: rgba(0, 0, 0, 0.06);
  --card-preview-frame-bg: rgba(255, 255, 255, 0.82);
  --card-action-bg: rgba(255, 255, 255, 0.58);
  --card-action-border: rgba(0, 0, 0, 0.1);
  --orientation-portrait-bg: rgba(53, 120, 229, 0.12);
  --orientation-portrait-color: #2457a6;
  --orientation-landscape-bg: rgba(82, 154, 74, 0.14);
  --orientation-landscape-color: #2b6d38;
  --orientation-neutral-bg: rgba(0, 0, 0, 0.05);
  --orientation-neutral-color: #5b6472;
  --orientation-toggle-bg: rgba(1, 131, 255, 0.1);
  --orientation-toggle-bg-hover: rgba(1, 131, 255, 0.16);
  --orientation-toggle-border: rgba(1, 131, 255, 0.35);
  --orientation-toggle-color: #0c4f99;
  
  --border-color-drop-area: rgba(1, 131, 255, 0.28);
  --font-color-drop-area: var(--color-gray-5);
  
  --form-input-font-color: var(--color-gray-6);
  --form-input-bg-color: var(--color-gray-1);
  --form-input-border: 1px solid rgba(17, 24, 39, 0.12);
  --form-placeholder-color: var(--color-gray-4);
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 10px 30px rgba(0, 0, 0, 0.4);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  color-scheme: dark;
  --bg-color: #16181c;
  --surface-color: #22252b;
  --surface2-color: #2d3138;
  --border-color: rgba(255, 255, 255, 0.08);
  --font-color: #f1f3f5;
  --font-color-2: #b5bac2;
  --branding-font-color: #f1f3f5;
  --branding-span-font-color: #0183ff;
  --link-hover-color: #0183ff;
  --font-color-filelist: #f1f3f5;
  --bg-color-filelist: #262a31;
  --card-shell-border: rgba(1, 131, 255, 0.12);
  --card-preview-stage-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(0, 0, 0, 0.16));
  --card-preview-stage-border: rgba(255, 255, 255, 0.055);
  --card-preview-frame-bg: rgba(248, 250, 252, 0.96);
  --card-action-bg: rgba(255, 255, 255, 0.03);
  --card-action-border: rgba(255, 255, 255, 0.08);
  --orientation-portrait-bg: rgba(53, 120, 229, 0.16);
  --orientation-portrait-color: #b7d7ff;
  --orientation-landscape-bg: rgba(77, 170, 113, 0.16);
  --orientation-landscape-color: #b7f2c7;
  --orientation-neutral-bg: rgba(255, 255, 255, 0.08);
  --orientation-neutral-color: rgba(255, 255, 255, 0.78);
  --orientation-toggle-bg: rgba(1, 131, 255, 0.12);
  --orientation-toggle-bg-hover: rgba(1, 131, 255, 0.2);
  --orientation-toggle-border: rgba(1, 131, 255, 0.35);
  --orientation-toggle-color: #d9eaff;
  --border-color-drop-area: rgba(1, 131, 255, 0.38);
  --font-color-drop-area: #b5bac2;
  --form-input-font-color: #f1f3f5;
  --form-input-bg-color: #181b20;
  --form-input-border: 1px solid rgba(255, 255, 255, 0.1);
  --form-placeholder-color: var(--color-gray-4);
  --font-color-footer: #a6acb4;
  --accent-dim: rgba(1, 131, 255, 0.16);
  --accent-glow: rgba(1, 131, 255, 0.28);
}

/* ====================================
 * 2. BASE STYLES
 * Foundation styles applied globally
 * ==================================== */

body {
  font-family: var(--font-family);
  margin: 0;
  padding: 0.9375rem;
  color: var(--font-color);
  background:
    radial-gradient(circle at top, rgba(1, 131, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 28%),
    var(--bg-color);
  font-size: var(--base-font-size);
  line-height: var(--line-height);
  min-height: 100vh;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at top, rgba(1, 131, 255, 0.14), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%),
    var(--bg-color);
}

h1 {
  font-size: 2rem;
  line-height: 1.2;
}

p {
  margin: 0.625rem 0.3125rem;
}

a,
a:link,
a:visited {
  color: var(--link-font-color);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover-color);
}

a:active {
  color: var(--link-active-color);
}

/* ====================================
 * 3. LAYOUT COMPONENTS
 * Structural elements for page layout
 * ==================================== */

.wrapper {
  margin: 0 auto;
  max-width: 1024px;
}

header {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  padding-top: 0.15rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

main {
  display: flex;
  justify-content: center;
  margin-top: 0.35rem;
  color: var(--font-color);
}

footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.15rem 1rem 0.5rem;
  font-size: 0.78rem;
  color: var(--font-color-footer);
  text-align: center;
  max-width: 52rem;
  margin: 0.75rem auto 0;
}

footer a {
  color: inherit;
  text-underline-offset: 0.18rem;
}

footer a:hover {
  color: var(--link-hover-color);
}

/* ====================================
 * 4. UI COMPONENTS
 * Reusable interface elements
 * ==================================== */

/* Utility Classes */
.bold {
  font-weight: 600;
}

.hidden {
  display: none;
}

.align-center {
  text-align: center;
}

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

/* Branding */
.branding {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1rem 0.35rem 0.85rem;
  font-size: 2.35rem;
  letter-spacing: var(--branding-letter-spacing);
  color: var(--branding-font-color);
  border-radius: 5px;
  font-weight: 800;
}

.branding-wordmark {
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.branding-wordmark span {
  color: var(--branding-span-font-color);
  font-weight: 700;
}

/* Domain suffix recedes so "PDFMerge" stays dominant */
.branding-wordmark .branding-tld {
  color: inherit;
  opacity: 0.45;
  font-weight: 700;
}

.branding-icon {
  width: 2.8rem;
  height: 2.8rem;
  object-fit: contain;
  flex-shrink: 0;
}

.branding a,
.branding a:link,
.branding a:active,
.branding a:visited,
.branding a:hover {
  color: var(--branding-font-color);
  text-decoration: none;
}

/* Hero Section */
.hero {
  text-align: center;
  margin: 0.5rem auto 1rem;
  max-width: 760px;
  color: var(--font-color);
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-color) 86%, transparent);
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.06);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--font-color-2);
}

.hero h1 {
  margin: 1rem auto 0;
  max-width: 12ch;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
  font-weight: 700;
  text-wrap: balance;
}

.hero p {
  margin: 1rem auto 0;
  max-width: 38rem;
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--font-color-2);
  text-wrap: balance;
}

.hero-points {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 auto 1.5rem;
  padding: 0;
}

.hero-point {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.58rem 0.85rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-color) 88%, transparent);
  border: 1px solid var(--border-color);
  color: var(--font-color);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Theme Switcher */
#theme-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0;
  background: transparent;
  border: none;
  padding: var(--spacing-sm);
  width: auto;
  height: auto;
  outline: none;
  transform: none;
  box-shadow: none;
  color: var(--font-color-2);
  transition: color var(--transition-fast);
}

#theme-switcher:hover {
  background: transparent;
  color: var(--link-hover-color);
}

#theme-switcher:focus-visible {
  outline: 2px solid var(--color-blue-1);
  outline-offset: 4px;
  border-radius: 8px;
}

#theme-switcher .material-icons-outlined {
  font-size: 1.5rem !important;
}

.icon-light {
  display: flex;
}

.icon-dark {
  display: none;
}

[data-theme="dark"] .icon-light {
  display: none;
}

[data-theme="dark"] .icon-dark {
  display: flex;
}

/* Buttons */
.button,
button,
button[type="submit"] {
  margin: var(--spacing-md) var(--spacing-xs) var(--spacing-md) 0;
  font-weight: 600;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--button-bg-color), var(--button-hover-bg-color));
  color: var(--button-font-color);
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--font-family);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(1, 131, 255, 0.15);
  transform: translateY(0);
}

.button:focus,
button:focus,
button[type="submit"]:focus {
  outline: 2px solid var(--color-blue-1);
  outline-offset: 2px;
}

.button:hover,
button:hover {
  background: linear-gradient(135deg, var(--button-hover-bg-color), var(--button-active-bg-color));
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(1, 131, 255, 0.25);
}

.button:active,
button:active {
  background: linear-gradient(135deg, var(--button-active-bg-color), var(--button-hover-bg-color));
  color: var(--button-font-color);
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(1, 131, 255, 0.2);
}

.button[disabled],
button[disabled],
button[disabled]:hover {
  background-color: var(--button-disabled-bg-color);
  color: var(--button-disabled-font-color);
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* File Upload Label */
#file-upload-label {
  margin: var(--spacing-lg) var(--spacing-xs) var(--spacing-lg) 0;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--color-blue-1), var(--color-blue-2));
  color: var(--color-gray-1);
  padding: 1.25rem 2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(1, 131, 255, 0.2);
  font-size: 1.1rem;
  transform: translateY(0);
}

#file-upload-label .material-icons-outlined {
  font-size: 1.2rem !important;
}

#file-upload-label:hover {
  background: linear-gradient(135deg, var(--color-blue-2), var(--color-blue-3));
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(1, 131, 255, 0.3);
}

#file-upload-label:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(1, 131, 255, 0.2);
}

#file-upload-label:focus-within {
  outline: 3px solid var(--color-blue-1);
  outline-offset: 2px;
}

/* Hide file input but keep it accessible */
#file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Flash Messages */
.flash-banner-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  min-width: 280px;
  max-width: min(600px, 90vw);
  color: var(--color-white);
  font-weight: 600;
  text-align: center;
  padding: var(--button-padding);
  border-radius: var(--button-border-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  pointer-events: none;
}

.flash-banner-container.flash-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.flash-banner-success {
  background-color: var(--color-green-1);
}

.flash-banner-danger {
  background-color: var(--color-red-1);
}

.flash-banner-warning {
  background-color: var(--color-orange-1);
}

.flash-banner-info {
  background-color: var(--color-cyan-1);
}

.tool-shell {
  width: 100%;
}

.tool-surface {
  background: color-mix(in srgb, var(--surface-color) 94%, transparent);
  border: 1px solid var(--card-shell-border);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 28px 70px rgba(17, 24, 39, 0.1);
}

[data-theme="dark"] .tool-surface {
  box-shadow: 0 30px 72px rgba(0, 0, 0, 0.34);
}

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

.tool-actions .button {
  margin: 0;
}

.footer-primary,
.footer-secondary {
  margin: 0;
}

.footer-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.footer-secondary {
  margin: 0;
  line-height: 1.55;
}

.footer-icon {
  font-size: 0.78rem !important;
}

.footer-divider {
  opacity: 0.45;
}

/* Output Filename */
#output-filename-container {
    margin: 18px 0 8px;
}

#output-filename-container label {
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--font-color-2);
}

.output-filename-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#output-filename {
    flex: 1;
    padding: 0.8rem 1rem;
    border: var(--form-input-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--form-input-bg-color);
}

.output-filename-ext {
    font-size: 14px;
    color: var(--font-color-2);
    background: color-mix(in srgb, var(--surface2-color) 92%, transparent);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.5rem 0.8rem;
}

/* Progress Bar */
#progress-container {
  display: none;
  margin: 20px 0 10px 0;
}

.button.danger {
    background: linear-gradient(135deg, var(--color-red-1), var(--color-red-2));
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(196, 68, 56, 0.18);
}

.button.danger:hover {
    background: linear-gradient(135deg, var(--color-red-1), var(--color-red-2));
    box-shadow: 0 4px 16px rgba(196, 68, 56, 0.28);
}

#progress-bar {
  width: 0;
  height: 20px;
  background-color: var(--color-blue-1);
  transition: width var(--transition-normal);
}

/* Spinner */
.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid var(--color-blue-1);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
  display: none;
  will-change: transform;
}

.spinner::after {
  content: 'Loading...';
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ====================================
 * 5. FORM ELEMENTS
 * Form inputs and controls
 * ==================================== */

form {
  margin: 0 auto;
  max-width: 720px;
}

input[type="text"],
input[type="email"],
input[type="number"],
textarea {
  color: var(--form-input-font-color);
  display: block;
  background-color: var(--form-input-bg-color);
  border: var(--form-input-border);
  border-radius: 6px;
  padding: 0.9375rem 1rem;
  font-size: 16px;
  transition: var(--transition-fast);
}

input[type="color"] {
  width: 60px;
  height: 40px;
  padding: 0;
  border: 2px solid var(--color-gray-3);
  border-radius: 6px;
  background-color: var(--bg-color);
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  overflow: hidden;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border: none;
  border-radius: 4px;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 4px;
}

/* iOS Safari specific fixes for color input */
@supports (-webkit-touch-callout: none) {
  input[type="color"] {
    -webkit-appearance: none;
    border-radius: 6px !important;
    width: 60px;
    height: 40px;
    border: 2px solid var(--color-gray-3);
    outline: none;
    background-color: transparent;
  }
  
  input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border: none;
    border-radius: 4px !important;
    width: 100%;
    height: 100%;
  }
  
  input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px !important;
    width: 100%;
    height: 100%;
  }
}

/* Additional iOS fixes using user agent detection */
@media screen and (-webkit-min-device-pixel-ratio: 2) and (max-device-width: 812px) {
  input[type="color"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    border-radius: 6px !important;
    overflow: hidden;
  }
  
  input[type="color"]::-webkit-color-swatch-wrapper {
    border-radius: 4px !important;
  }
  
  input[type="color"]::-webkit-color-swatch {
    border-radius: 4px !important;
  }
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-blue-1);
  outline-offset: 2px;
}

input[type="color"]:focus {
  outline: 2px solid var(--color-blue-1);
  outline-offset: 2px;
}

input[type="file"] {
  display: none;
}

textarea {
  margin: 10px 0;
  resize: none;
}

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  color: var(--form-input-font-color);
  width: 100%;
  background-color: var(--form-input-bg-color);
  border: var(--form-input-border);
  padding: 0.8rem 1rem;
  font-size: 16px;
  border-radius: 6px;
}

select::-ms-expand {
  display: none;
}

/* Toggle Switches */
.toggle-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
  gap: var(--spacing-md);
}

.toggle-item {
  display: flex;
  align-items: center;
}

.toggle-item label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-left: 10px; 
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  margin-right: 10px;
  transition: var(--transition-normal);
}

.switch:hover {
  transform: scale(1.05);
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--color-gray-3);
  transition: var(--transition-normal);
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: var(--color-white);
  transition: var(--transition-normal);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--color-blue-1);
}

input:focus + .slider {
  box-shadow: 0 0 0 3px rgba(1, 131, 255, 0.18);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.toggle-description {
  color: var(--font-color-2);
  font-size: 0.8rem;
  line-height: 1.2;
}

.toggle-item--disabled {
  opacity: 0.4;
  pointer-events: none;
  user-select: none;
}

/* ====================================
 * 6. APPLICATION-SPECIFIC COMPONENTS
 * Components unique to PDFMERGE
 * ==================================== */

/* Drop Area */
#drop-area {
  margin: var(--spacing-lg) 0;
  border: 1px dashed var(--border-color-drop-area);
  border-radius: 14px;
  padding: 2.4rem 1.6rem;
  text-align: center;
  color: var(--font-color-drop-area);
  min-height: 180px;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  cursor: pointer;
  outline: none;
  background: linear-gradient(180deg, rgba(1, 131, 255, 0.04), transparent 45%), var(--surface2-color);
}

#drop-area:hover {
  border-color: var(--color-blue-1);
  background: linear-gradient(180deg, rgba(1, 131, 255, 0.1), transparent 45%), var(--surface2-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(1, 131, 255, 0.1);
}

#drop-area:focus {
  border-color: var(--color-blue-1);
  box-shadow: 0 0 0 3px rgba(1, 131, 255, 0.1);
}

#drop-area .drop-icon,
#drop-area > p {
  position: relative;
  z-index: 0;
  pointer-events: none;
}

#drop-area.has-files .drop-icon,
#drop-area.has-files > p {
  opacity: 0.2;
  transition: opacity var(--transition-normal);
}

#drop-area.drag .drop-icon,
#drop-area.drag > p {
  opacity: 0.3;
}

.drop-icon {
  font-size: 48px;
  display: block;
  margin: 20px auto 15px auto;
  color: var(--font-color-drop-area);
  animation: float 3s ease-in-out infinite;
  will-change: transform;
}

/* File List Container */
#file-list {
  margin: 0;
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 1;
  width: 100%;
}

/* File List - Modern CSS Grid Layout */
#selected-files-list {
  margin: 0;
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: fit-content;
  box-sizing: border-box;
  justify-items: center;
  place-content: start center;
}

/* File Cards with Drag and Drop */
#selected-files-list li {
  background-color: var(--bg-color-filelist);
  color: var(--font-color-filelist);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 6px;
  padding: 14px 14px 16px;
  border: 1px solid var(--card-shell-border);
  border-radius: 14px;
  box-sizing: border-box;
  width: 100%;
  max-width: 400px;
  min-height: 200px;
  position: relative;
  box-shadow: 0 18px 40px rgba(17, 24, 39, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  pointer-events: auto;
  transform-origin: center;
  cursor: grab;
  user-select: none;
  overflow: hidden;
}

.card-thumbnail-wrapper {
    width: 100%;
    height: 196px;
    overflow: hidden;
    border-radius: 14px;
    background: var(--card-preview-stage-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 16px;
    border: 1px solid var(--card-preview-stage-border);
}

.card-thumbnail-wrapper--pdf {
    height: 196px;
}

.card-thumbnail-frame {
    width: 100%;
    height: 100%;
    max-width: 240px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease;
}

.card-thumbnail-page {
    width: 82%;
    height: 82%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-thumbnail-surface {
    height: 100%;
    width: auto;
    aspect-ratio: 210 / 297;
    border-radius: 0;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-preview-frame-bg);
    padding: 0;
    box-sizing: border-box;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    transform-origin: center center;
    transform: rotate(var(--thumbnail-rotation, 0deg)) scale(var(--thumbnail-page-scale, 1));
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
}

.card-thumbnail-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(var(--thumbnail-image-rotation, 0deg)) scale(var(--thumbnail-image-scale, 1));
    transform-origin: center center;
    transition: transform 0.25s ease;
}

.card-thumbnail-content--image {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(var(--thumbnail-image-rotation, 0deg)) scale(var(--thumbnail-image-scale, 1));
}

.card-thumbnail-surface--pdf {
    padding: 0;
}

.card-thumbnail-content--pdf {
    transform: rotate(var(--thumbnail-pdf-content-rotation, 0deg));
}

.card-thumbnail-content--pdf[data-pdf-rotation-mode="sideways"] {
    position: absolute;
    width: 141.43%;
    height: 70.71%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(var(--thumbnail-pdf-content-rotation, 0deg));
    transform-origin: center center;
}

.card-thumbnail--pdf {
    width: 100%;
    height: 100%;
}

.card-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#selected-files-list li[data-image-layout="cover"] .card-thumbnail-surface {
  padding: 0;
}

#selected-files-list li[data-image-layout="cover"] .card-thumbnail-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#selected-files-list li[data-image-layout="cover"] .card-thumbnail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

#selected-files-list li[data-image-layout="cover-rotated"] .card-thumbnail-surface {
  padding: 0;
  background: var(--card-preview-frame-bg);
}

#selected-files-list li[data-image-layout="cover-rotated"] .card-thumbnail-content {
  position: absolute;
  width: 141.43%;
  height: 70.71%;
  top: 50%;
  left: 50%;
  overflow: hidden;
  transform: translate(-50%, -50%) rotate(var(--thumbnail-image-rotation, 90deg)) scale(var(--thumbnail-image-scale, 1));
  transform-origin: center center;
}

#selected-files-list li[data-image-layout="cover-rotated"] .card-thumbnail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

#selected-files-list li[data-image-layout="fit"] .card-thumbnail-surface {
  padding: 0;
}

#selected-files-list li[data-image-layout="fit"] .card-thumbnail-content {
  width: 100%;
  height: 100%;
}

#selected-files-list li[data-image-layout="fit"] .card-thumbnail {
  object-fit: contain;
  background: var(--card-preview-frame-bg);
}

#selected-files-list li[data-image-layout="default"] .card-thumbnail-surface {
  padding: 0;
  background: var(--card-preview-frame-bg);
}

#selected-files-list li[data-image-layout="default"] .card-thumbnail-content {
  width: 84%;
  height: 84%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(var(--thumbnail-image-rotation, 0deg)) scale(var(--thumbnail-image-scale, 1));
}

#selected-files-list li[data-image-layout="default"] .card-thumbnail {
  object-fit: contain;
  background: var(--card-preview-frame-bg);
}

/* fit-rotated: image rotated 90° placed on a portrait page.
   The img is absolutely positioned with swapped dimensions (landscape box = page height × page width)
   then rotated 90° so it maps exactly onto the portrait page area. object-fit: contain then
   scales the image so its longer side fills the corresponding page dimension, matching the
   non-rotated "fit" behaviour (longer side always touches). */
#selected-files-list li[data-image-layout="fit-rotated"] .card-thumbnail-surface {
  height: 100%;
  width: auto;
  padding: 0;
  background: var(--card-preview-frame-bg);
}

#selected-files-list li[data-image-layout="fit-rotated"] .card-thumbnail-content {
  position: absolute;
  width: 141.43%;
  height: 70.71%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(var(--thumbnail-image-rotation, 90deg)) scale(var(--thumbnail-image-scale, 1));
  transform-origin: center center;
}

#selected-files-list li[data-image-layout="fit-rotated"] .card-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--card-preview-frame-bg);
}

/* default-rotated: same as fit-rotated but scaled to 84% so ~8% margin shows on each side,
   matching the visual framing of the default-margins layout. */
#selected-files-list li[data-image-layout="default-rotated"] .card-thumbnail-surface {
  height: 100%;
  width: auto;
  padding: 0;
  background: var(--card-preview-frame-bg);
}

#selected-files-list li[data-image-layout="default-rotated"] .card-thumbnail-content {
  position: absolute;
  width: 118.8%;
  height: 59.4%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(var(--thumbnail-image-rotation, 90deg)) scale(var(--thumbnail-image-scale, 1));
  transform-origin: center center;
}

#selected-files-list li[data-image-layout="default-rotated"] .card-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--card-preview-frame-bg);
}

/* Enhanced dragging state */
#selected-files-list li.dragging,
#selected-files-list li.is-dragging {
  opacity: 0.9;
  z-index: 1000;
  cursor: grabbing;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
  transition: none;
  border-color: var(--color-blue-1);
}

/* When the card is reparented to document.body during drag, all
   #selected-files-list li rules stop matching. Repeat the critical
   visual properties here so the ghost card still looks like a card. */
li.is-dragging {
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 6px;
  padding: 14px 14px 16px;
  border: 1px solid var(--color-blue-1);
  border-radius: 12px;
  box-sizing: border-box;
  background-color: var(--bg-color-filelist);
  color: var(--font-color-filelist);
  overflow: hidden;
  user-select: none;
  opacity: 0.9;
  z-index: 1000;
  cursor: grabbing;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
  transition: none;
}

.drag-placeholder {
  border: 2px dashed rgba(1, 131, 255, 0.35);
  background: linear-gradient(135deg, rgba(1, 131, 255, 0.08), rgba(1, 131, 255, 0.03));
  border-radius: 16px;
  box-sizing: border-box;
  pointer-events: none;
}

/* Card hover effects */
#selected-files-list li:not(.dragging) {
  cursor: grab;
}

#selected-files-list li:not(.dragging):hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Smooth transitions for reordering */
#selected-files-list li {
  transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1), opacity 0.3s ease, box-shadow 0.3s ease;
}

/* Click to reorder animation */
#selected-files-list li.reordering {
  animation: reorderPulse 0.4s ease;
}

@keyframes reorderPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 8px 25px rgba(1, 131, 255, 0.4); }
  100% { transform: scale(1); }
}

/* Card explosion animation styles */
.card-exploding {
  pointer-events: none;
  position: relative;
  z-index: 1;
}

/* Subtle pre-explosion effect */
@keyframes preExplode {
  0% { 
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.02);
    filter: brightness(1.1);
  }
  100% { 
    transform: scale(1.01);
    filter: brightness(1.05);
  }
}

.card-pre-explode {
  animation: preExplode 0.2s ease-in-out;
}

#selected-files-list li:hover::after {
  opacity: 1;
}

/* View Transition API styles */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.8s;
  animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* All card transitions - matches any view-transition-name starting with 'card-' */
::view-transition-group(*) {
  animation-duration: 0.8s;
  animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
}

::view-transition-old(*),
::view-transition-new(*) {
  animation-duration: 0.8s;
  animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
}

#selected-files-list li:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transform: translateY(-3px);
  border-color: rgba(1, 131, 255, 0.2);
}

#selected-files-list li:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: rgba(1, 131, 255, 0.3);
}

[data-theme="dark"] #selected-files-list li {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(0, 0, 0, 0.04)),
    var(--bg-color-filelist);
  border-color: var(--card-shell-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 16px 34px rgba(0, 0, 0, 0.26);
}

[data-theme="dark"] #selected-files-list li:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 20px 42px rgba(0, 0, 0, 0.34);
  border-color: rgba(1, 131, 255, 0.18);
}

[data-theme="dark"] .card-thumbnail-wrapper {
  background:
    radial-gradient(circle at top, rgba(1, 131, 255, 0.06), transparent 42%),
    var(--card-preview-stage-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

[data-theme="dark"] .card-thumbnail-surface {
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.24),
    0 0 0 1px rgba(17, 24, 39, 0.06);
}

[data-theme="dark"] .delete-file-button {
  color: #9aa3af;
}

[data-theme="dark"] .image-layout-card-select {
  background-color: #3a3f47;
  color: var(--font-color);
}

[data-theme="dark"] #image-details-toggle,
[data-theme="dark"] #paper-size-selection,
[data-theme="dark"] #watermark-details-toggle {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(0, 0, 0, 0.03));
  border-color: rgba(255, 255, 255, 0.07);
}



/* File Card Components */
.file-info-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  height: 100%;
  justify-content: flex-start;
  padding: 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.card-meta-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Order Number Badge */
.order-number {
  color: var(--color-gray-5);
  padding: 0;
  font-size: 0.98rem;
  font-weight: 800;
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  box-shadow: none;
  border: none;
  order: -1;
  cursor: pointer;
}

.file-type-badge {
  background-color: var(--color-gray-4);
  color: var(--color-white);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.file-type-badge.pdf {
  background-color: var(--color-red-1);
}

.file-type-badge.image {
  background-color: var(--color-green-1);
}

.file-type-badge.blank {
  background-color: var(--color-gray-5);
}

.orientation-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 10px 4px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid var(--card-action-border);
  background: var(--orientation-neutral-bg);
  color: inherit;
  flex-shrink: 0;
}

.orientation-badge::before {
  content: "";
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  opacity: 0.85;
}

.orientation-badge--portrait::before {
  width: 10px;
  height: 14px;
}

.orientation-badge--landscape::before {
  width: 14px;
  height: 10px;
}

.orientation-badge--square::before,
.orientation-badge--unknown::before {
  width: 12px;
  height: 12px;
}

.orientation-badge--portrait {
  background: var(--orientation-portrait-bg);
  color: var(--orientation-portrait-color);
}

.orientation-badge--landscape {
  background: var(--orientation-landscape-bg);
  color: var(--orientation-landscape-color);
}

.orientation-badge--square,
.orientation-badge--unknown {
  background: var(--orientation-neutral-bg);
  color: var(--orientation-neutral-color);
}

.card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  text-align: center;
}

.card-top-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 0 4px;
  flex-shrink: 0;
}

.file-name {
  font-weight: 600;
  color: inherit;
  font-size: 0.95rem;
  display: -webkit-box;
  line-height: 1.3;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
  max-height: 2.6rem;
}

.file-size,
.file-pages {
  font-size: 0.75rem;
  color: var(--color-gray-5);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}

.pdf-page-range-input {
  border: 1px solid var(--card-action-border);
  outline: none;
  box-shadow: none;
  font-size: 0.8rem;
  padding: 10px 12px;
  color: var(--form-input-font-color);
  background-color: var(--form-input-bg-color);
  width: 100%;
  max-width: 220px;
  line-height: 1.2;
  text-align: center;
  margin-top: 2px;
  border-radius: 10px;
}

.pdf-page-range-input:focus, 
.pdf-page-range-input:hover {
  outline: none;
  border-color: rgba(1, 131, 255, 0.45);
  box-shadow: none;
}

.pdf-page-range-input::placeholder {
  color: var(--form-placeholder-color);
  font-size: 0.8rem;
}


.image-layout-card-select {
  width: 100%;
  max-width: 220px;
  min-height: 38px;
  padding: 8px 34px 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(1, 131, 255, 0.25);
  background-color: var(--form-input-bg-color);
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(1, 131, 255, 0.7) 50%),
    linear-gradient(135deg, rgba(1, 131, 255, 0.7) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  color: var(--form-input-font-color);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.04);
  appearance: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.image-layout-card-select:focus,
.image-layout-card-select:hover {
  border-color: rgba(1, 131, 255, 0.5);
  outline: none;
  box-shadow: 0 0 0 3px rgba(1, 131, 255, 0.12);
}

[data-theme="dark"] .image-layout-card-select {
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(100, 170, 255, 0.8) 50%),
    linear-gradient(135deg, rgba(100, 170, 255, 0.8) 50%, transparent 50%);
  border-color: rgba(1, 131, 255, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .image-layout-card-select:focus,
[data-theme="dark"] .image-layout-card-select:hover {
  background-color: #40454e;
  border-color: rgba(1, 131, 255, 0.34);
  box-shadow: 0 0 0 3px rgba(1, 131, 255, 0.1);
}

/* Delete Button */
.delete-file-button {
  background: var(--card-action-bg) !important;
  border: 1px solid var(--card-action-border) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: static;
  color: var(--color-gray-5);
  padding: 0;
  outline: none;
  box-shadow: none !important;
  border-radius: 10px;
  transition: var(--transition-fast);
  opacity: 1;
  z-index: 2;
  width: 40px;
  min-width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.delete-file-button:hover {
  background-color: var(--color-red-1) !important;
  color: var(--color-white) !important;
  opacity: 1;
  transform: none;
  border: none !important;
  box-shadow: none !important;
}

.delete-file-button:focus {
  background: transparent;
  outline: none;
  box-shadow: none;
}

.delete-file-button:active {
  background-color: var(--color-red-2) !important;
  color: var(--color-white) !important;
  box-shadow: none !important;
  border: none !important;
  transform: scale(0.95);
}

.delete-file-button span {
  font-size: 20px;
  line-height: 1;
}

/* Blank Page Card */
.blank-page-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color-drop-area);
  border-radius: 12px;
}

.blank-page-preview .material-icons-outlined {
  font-size: 36px;
  opacity: 0.35;
  color: var(--font-color-filelist);
}

.blank-page-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  color: var(--font-color-filelist);
  font-style: italic;
  border: 2px dashed var(--border-color-drop-area);
  border-radius: 12px;
  min-height: 88px;
}

/* Watermark Controls */
#watermark-details-toggle {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: color-mix(in srgb, var(--surface2-color) 90%, transparent);
  border: 1px solid var(--border-color);
  border-radius: 14px;
}

.watermark-description {
  color: var(--font-color-2);
  font-size: 0.8rem;
  line-height: 1.2;
}

.watermark-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin: 16px 0;
  gap: var(--spacing-md);
}

.watermark-item {
  display: flex;
  align-items: center;
}

.watermark-item label {
  margin-right: 10px;
}

.watermark-tiled-item {
  align-items: flex-start;
}

.watermark-tiled-item label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* Paper Size Selection */
.paper-size-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin: 15px 0;
  gap: var(--spacing-md);
}

#image-details-toggle,
#paper-size-selection {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: color-mix(in srgb, var(--surface2-color) 90%, transparent);
  border: 1px solid var(--border-color);
  border-radius: 14px;
}

.paper-size-item {
  display: flex;
  align-items: center;
}

.paper-size-item label {
  margin-right: 10px;
  font-weight: 600;
}

.paper-size-item select {
  width: 200px;
  margin: 0;
}

.paper-size-description {
  color: var(--font-color-2);
  font-size: 0.8rem;
  line-height: 1.2;
  margin: 5px 0;
  width: 100%;
}

.rotation-controls {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 6px;
    justify-content: center;
    padding: 4px 0 2px;
    margin-top: 2px;
}

.orientation-toggle-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    flex-shrink: 0;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--orientation-toggle-border);
    background: var(--orientation-toggle-bg);
    color: var(--orientation-toggle-color);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orientation-toggle-btn span {
    font-size: 20px;
    line-height: 1;
}

.orientation-toggle-btn:hover {
    background: var(--orientation-toggle-bg-hover);
    border-color: rgba(1, 131, 255, 0.32);
    transform: none;
}

[data-theme="dark"] .orientation-toggle-btn:hover {
    background: rgba(1, 131, 255, 0.12);
    border-color: rgba(1, 131, 255, 0.28);
    color: #e6f1ff;
}

[data-theme="dark"] #drop-area:hover {
  border-color: rgba(1, 131, 255, 0.28);
  background: linear-gradient(180deg, rgba(1, 131, 255, 0.06), transparent 45%), var(--surface2-color);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

[data-theme="dark"] .delete-file-button:hover {
  background-color: #b94a3f !important;
}

/* File Link */
#file-link {
  font-weight: bold;
  margin: 0 auto;
  text-align: center;
  display: inline;
}

.file-link {
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px;
  word-break: break-word;
}

.file-link span {
  margin-right: auto;
  padding-right: 5px;
}

.flash-success {
  animation: flash-success 1s ease;
}

/* ====================================
 * 7. ANIMATIONS & KEYFRAMES
 * Motion and visual feedback
 * ==================================== */

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-15px);
  }
}

@keyframes flash-success {
  0%, 100% {
    background: none;
  }
  50% {
    background-color: var(--color-green-1);
    color: #ffffff;
  }
}

/* ====================================
 * 8. RESPONSIVE DESIGN
 * Adaptive layouts for different screen sizes
 * ==================================== */

/* Mobile: Stack cards vertically, smaller size */
@media (max-width: 640px) {
  .button,
  button,
  button[type="submit"] {
    display: block; 
    width: 100%; 
    margin: var(--spacing-xs) 0; 
  }

  #selected-files-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  #selected-files-list li {
    width: 100%;
    max-width: 400px;
    min-height: 220px;
    padding: 12px;
    margin-bottom: 20px;
  }

  .card-thumbnail-wrapper {
    height: 180px;
    padding: 12px;
  }

  .card-thumbnail-frame {
    max-width: 220px;
  }

  .card-thumbnail-page {
    width: 78%;
    height: 78%;
  }

  .card-thumbnail-surface {
    padding: 0;
  }

  .card-header {
    align-items: flex-start;
  }

  .card-meta {
    gap: 6px;
  }

  .orientation-badge,
  .file-type-badge {
    font-size: 0.72rem;
  }

  .card-body {
    gap: 6px;
  }

  .file-name {
    font-size: 0.85rem;
    max-height: 2.4rem;
  }

  .file-size,
  .file-pages {
    font-size: 0.7rem;
  }

  .pdf-page-range-input {
    font-size: 0.7rem;
  }

  .delete-file-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .delete-file-button span {
    font-size: 20px;
  }

  .rotation-controls {
    gap: 6px;
  }

  
  .watermark-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .watermark-item {
    margin: 0;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .watermark-item input[type="text"],
  .watermark-item input[type="number"] {
    width: 100%;
    margin-top: 4px;
  }
  
  .watermark-item input[type="color"] {
    width: 80px;
    height: 40px;
    margin-top: 4px;
    border-radius: 8px;
  }
  
  .watermark-item label {
    margin-right: 0;
    margin-bottom: 4px;
  }
  
  .watermark-tiled-item label {
    flex-direction: row;
    margin-bottom: 8px;
  }
  
  .paper-size-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .paper-size-item {
    margin: 0;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .paper-size-item label {
    margin-bottom: 4px;
    margin-right: 0;
  }
  
  .paper-size-item select {
    width: 100%;
  }
  
  .hero {
    font-size: 1.3rem;
    line-height: 1.3;
    margin-bottom: 20px;
  }
  
}



/* Tablet: 2-column grid layout */
@media (min-width: 641px) and (max-width: 1024px) {
  #selected-files-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 720px;
    margin: 0 auto;
  }
  
  #selected-files-list li {
    width: 100%;
    max-width: 350px;
    min-width: 300px;
    min-height: 220px;
  }
  
  
  .file-size,
  .file-pages {
    font-size: 0.8rem;
    max-width: 100px;
  }
  
  .pdf-page-range-input {
    font-size: 0.8rem;
  }
  
  .delete-file-button {
    width: 32px;
    height: 32px;
    padding: 6px;
  }
  
  .delete-file-button span {
    font-size: 22px;
  }
}

/* Desktop: 3-column grid layout */
@media (min-width: 1025px) {
  #selected-files-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 0 auto;
  }

  #selected-files-list li {
    width: 100%;
    max-width: 100%;
    min-height: 220px;
  }

  .delete-file-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }
}

/* Extra Large Desktop: keep 3-column layout */
@media (min-width: 1400px) {
  #selected-files-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }

  #selected-files-list li {
    width: 100%;
    max-width: 100%;
    min-height: 220px;
  }
}
