:root {
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-strong: #eef2ff;
  --surface-border: #e5e7eb;
  --text: #111827;
  --text-muted: #4b5563;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --danger: #ef4444;
  --radius: 20px;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 20px;
}

.top-banner,
.bottom-banner,
.sidebar-left,
.sidebar-right,
.pre-download-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: #d1d5db;
  border: 1px dashed #9ca3af;
  overflow: hidden;
}

.top-banner,
.bottom-banner {
  width: 100%;
  height: 90px;
  min-height: 90px;
}

.pre-download-banner {
  width: 100%;
  max-width: 728px;
  height: 90px;
  min-height: 90px;
}

.sidebar-left,
.sidebar-right {
  width: 160px;
  min-height: 600px;
  padding: 16px;
}

@media (max-width: 1024px) {
  .pre-download-banner {
    max-width: none;
  }
}

@media (max-width: 767px) {
  .pre-download-banner {
    width: 100%;
    min-height: 250px;
    height: auto;
  }
}

.layout-inner {
  display: grid;
  gap: 20px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
}

.content {
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  display: grid;
  gap: 14px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 2.4vw, 3rem);
  line-height: 1.05;
}

.description {
  margin: 0;
  color: var(--text-muted);
  max-width: 760px;
}

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

.quick-start {
  display: grid;
  gap: 16px;
  background: #eef2ff;
  border: 1px solid #d1d5db;
  border-radius: 22px;
  padding: 18px;
}

.step-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.step-pill {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #ffffff;
  border-radius: 18px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.step-number {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.tool-steps {
  display: grid;
  gap: 18px;
}

.tool-step {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.tool-step .step-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.tool-step h3 {
  margin: 0;
  font-size: 1.05rem;
}

.tool-step p {
  margin: 0;
  color: var(--text-muted);
}

.tool-step .button-group {
  margin-top: 12px;
}

@media (max-width: 767px) {
  .step-summary {
    grid-template-columns: 1fr;
  }
  .tool-step {
    padding: 16px;
  }
}

.bottom-banner {
  transition: transform 0.2s ease;
}

@media (max-width: 767px) {
  .bottom-banner {
    position: sticky;
    bottom: 0;
    z-index: 20;
    width: 100%;
    background: #d1d5db;
  }
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.95rem;
  color: #6b7280;
}

.breadcrumb-separator {
  margin: 0 4px;
}

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

.breadcrumbs a:hover,
.breadcrumbs a:focus-visible {
  text-decoration: underline;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(75, 85, 99, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  vertical-align: middle;
}

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

.tab-menu,
.pdf-subtab-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--surface-muted);
  border-radius: 16px;
  padding: 10px;
}

.tab-button,
.pdf-subtab {
  border: none;
  border-radius: 14px;
  background: transparent;
  color: #374151;
  cursor: pointer;
  padding: 12px 18px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  font-weight: 600;
  min-height: 48px;
}

.tab-button.active,
.tab-button:hover,
.pdf-subtab.active,
.pdf-subtab:hover {
  background: var(--accent);
  color: #ffffff;
}

.tool-panel,
.pdf-subtab-panel {
  display: none;
  gap: 24px;
}

.tool-panel.active,
.pdf-subtab-panel.active {
  display: grid;
}

.panel-description {
  margin: 0;
  color: var(--text-muted);
}

fieldset {
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  padding: 20px;
  background: var(--surface-muted);
}

fieldset legend {
  padding: 0 10px;
  font-weight: 700;
  color: #111827;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.control-grid.single-column {
  grid-template-columns: 1fr;
}

.control-group {
  display: grid;
  gap: 16px;
}

.control-group label,
label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #1f2937;
  font-weight: 600;
}

input[type="file"],
input[type="number"],
input[type="range"],
select,
textarea,
button {
  width: 100%;
}

input[type="file"] {
  cursor: pointer;
}

input[type="number"],
input[type="range"],
select,
textarea {
  border: 1px solid #d1d5db;
  border-radius: 14px;
  background: #ffffff;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
}

input[type="range"] {
  accent-color: var(--accent);
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.drag-drop-area {
  min-height: 180px;
  border: 2px dashed #cbd5e1;
  border-radius: 20px;
  background: var(--surface-muted);
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: #475569;
  cursor: pointer;
}

.drag-drop-area.dragover {
  background: #eef2ff;
  border-color: #6366f1;
  color: #3730a3;
}

.batch-list,
.pdf-list {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.batch-card,
.pdf-item {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 16px;
  align-items: center;
}

.batch-card {
  grid-template-columns: 100px 1fr;
}

.batch-card img,
.preview-card img,
.preview-card canvas {
  width: 100%;
  height: auto;
  border-radius: 14px;
  object-fit: cover;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.batch-card .card-details,
.pdf-item .item-content {
  display: grid;
  gap: 8px;
}

.batch-card .card-details strong,
.pdf-item .item-content strong,
.preview-card strong {
  display: block;
  margin-bottom: 4px;
  color: #111827;
}

.item-actions,
.batch-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.item-actions button,
.batch-actions button,
.button-group button {
  min-width: auto;
  padding: 10px 14px;
  border-radius: 14px;
}

.item-actions button.secondary,
.batch-actions button.secondary {
  background: var(--accent);
}

.item-actions button.danger,
.batch-actions button.danger {
  background: var(--danger);
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
}

button {
  min-height: 48px;
  border: none;
  border-radius: 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  padding: 14px 24px;
  transition: transform 0.15s ease, background 0.2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

button:disabled {
  background: #c7d2fe;
  color: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

.status-area {
  display: grid;
  gap: 10px;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.95rem;
  min-height: 22px;
}

.progress {
  width: 100%;
}

progress {
  width: 100%;
  height: 14px;
  border-radius: 10px;
  appearance: none;
}

progress::-webkit-progress-bar {
  background: #eef2ff;
  border-radius: 10px;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 10px;
}

.progress-hidden {
  display: none;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.preview-card,
.tool-summary,
.file-details {
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  padding: 18px;
}

.preview-card {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ad-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ad-placeholder {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-align: center;
}

.ad-slot {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.ad-slot iframe {
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

.legal-panel .tool-step {
  display: grid;
  gap: 12px;
}

.site-footer {
  border-top: 1px solid var(--surface-border);
  padding-top: 14px;
}

.cookie-note {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legal-links a {
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.legal-links a:hover,
.legal-links a:focus-visible {
  text-decoration: underline;
}

.layout-inner .sidebar-left,
.layout-inner .sidebar-right {
  display: none;
}

@media (min-width: 1025px) {
  .layout-inner .sidebar-left,
  .layout-inner .sidebar-right {
    display: flex;
  }
}

@media (max-width: 1024px) {
  .top-banner,
  .bottom-banner {
    min-height: 70px;
    height: 70px;
  }
}

@media (max-width: 767px) {
  .page-shell {
    padding: 14px;
    gap: 16px;
  }

  .layout-inner {
    grid-template-columns: 1fr;
  }

  .control-grid,
  .preview-grid,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .tab-menu,
  .pdf-subtab-menu {
    gap: 10px;
    justify-content: space-between;
  }

  .tab-button,
  .pdf-subtab {
    min-height: 46px;
    flex: 1 1 auto;
  }

  .tool-step p,
  .panel-description {
    display: none;
  }

  .legal-panel .tool-step p,
  .legal-panel .panel-description {
    display: block;
  }

  .quick-start .step-pill p {
    display: none;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .drag-drop-area {
    min-height: 140px;
  }

  .status-line {
    font-size: 0.92rem;
  }

  .top-banner,
  .bottom-banner {
    min-height: 50px;
    height: 50px;
    border-radius: 14px;
  }

  .pre-download-banner {
    min-height: 250px;
  }

  .button-group {
    flex-direction: column;
  }

  .batch-card,
  .pdf-item {
    grid-template-columns: 80px 1fr;
  }
}
