:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #69727d;
  --line: #d9d5ca;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --danger: #d8422f;
  --danger-strong: #b63123;
  --soft-danger: #fff1ee;
  --success: #2d8a50;
  --focus: #f6a434;
  --shadow: 0 16px 40px rgba(31, 41, 51, 0.11);
  --thumb: 184px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button,
label.button,
a.button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100vh;
}

.upload-view {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(calc(100vh - 96px), auto) auto;
  padding: 28px;
}

.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark,
.upload-icon,
.success-icon {
  display: inline-grid;
  place-items: center;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.tool-hero {
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 16px;
  width: min(680px, 100%);
}

.upload-panel {
  width: min(680px, 100%);
  min-height: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 44px 32px;
  border: 2px dashed #b7afa1;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease;
}

.tutorial-entry {
  display: flex;
  justify-content: center;
}

.tutorial-entry a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--primary-strong);
  font-weight: 850;
  text-decoration: none;
}

.tutorial-entry a:hover {
  text-decoration: underline;
}

.info-section,
.content-page {
  width: min(1080px, 100%);
  margin: 0 auto;
}

.info-section {
  display: grid;
  gap: 26px;
  padding: 28px 0 44px;
}

.content-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.content-nav a,
.text-link {
  color: var(--primary-strong);
  font-weight: 800;
  text-decoration: none;
}

.content-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.content-nav a:hover,
.text-link:hover {
  text-decoration: underline;
}

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

.info-grid article,
.steps-section,
.faq-section,
.language-card,
.tutorial-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.info-grid h2,
.steps-section h2,
.faq-section h2,
.tutorial-card h2,
.language-card h2,
.panel-section h2 {
  margin-bottom: 12px;
}

.page-hero h1 + p,
.upload-panel h1 + p {
  margin-top: 12px;
}

.info-grid p,
.steps-section p,
.faq-section p,
.content-page p,
.content-page li {
  color: #46515d;
  line-height: 1.62;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary-strong) !important;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.steps-list,
.tutorial-list {
  display: grid;
  gap: 10px;
  padding-left: 22px;
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-list details {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.faq-list summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 850;
}

.faq-list p {
  margin-top: 10px;
}

.content-page {
  display: grid;
  gap: 28px;
  padding: 28px;
}

.page-header {
  display: grid;
  gap: 26px;
  min-height: 58vh;
  align-content: center;
}

.page-header .brand-row {
  justify-self: start;
}

.page-hero {
  display: grid;
  gap: 18px;
  max-width: 760px;
}

.page-hero h1 {
  font-size: 44px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.tutorial-card h2,
.language-card h2 {
  margin-bottom: 12px;
}

.tutorial-walkthrough {
  display: grid;
  gap: 18px;
}

.tutorial-step {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(320px, 1.15fr);
  gap: 22px;
  align-items: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tutorial-step-copy {
  display: grid;
  gap: 12px;
}

.tutorial-step-copy ul,
.tutorial-feature ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.tutorial-figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tutorial-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.tutorial-figure figcaption {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tutorial-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.tutorial-feature,
.tutorial-note {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tutorial-feature {
  display: grid;
  gap: 10px;
}

.tutorial-feature h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.share-logo-panel {
  display: grid;
  gap: 16px;
}

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

.share-logo-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 134px;
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.share-logo-card img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.share-logo-card span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.tutorial-note {
  border-color: #b9dbc6;
  background: #effaf3;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.language-footer {
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.language-footer > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.language-footer .footer-links {
  padding: 0;
  border-top: 0;
}

.upload-panel.drag-over {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.upload-icon {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background: #e4f4ef;
  color: var(--primary);
}

.upload-icon svg {
  width: 34px;
  height: 34px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 36px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.upload-panel p,
.hint,
.file-meta,
.metric-label,
.message,
.drop-copy {
  color: var(--muted);
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

input[readonly] {
  cursor: text;
  background: #fbfaf7;
}

.button,
.icon-button,
.icon-only {
  border: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button {
  min-height: 44px;
  display: inline-flex;
  padding: 0 16px;
}

.button svg,
.icon-button svg,
.icon-only svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-strong);
}

.button-secondary {
  background: #f1eee7;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button-secondary:hover {
  background: #e9e4da;
}

.button-danger {
  background: var(--danger);
  color: #fff;
}

.button-danger:hover {
  background: var(--danger-strong);
}

.button:disabled,
.icon-button:disabled,
.icon-only:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button.is-busy,
.icon-button.is-busy {
  opacity: 0.78;
}

.button.is-busy > svg,
.icon-button.is-busy > svg {
  display: none;
}

.button.is-busy::before,
.icon-button.is-busy::before,
.spinner {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 720ms linear infinite;
}

.source-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.upload-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #b9dbc6;
  border-radius: 8px;
  background: #effaf3;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 850;
}

.icon-button {
  min-height: 38px;
  display: inline-flex;
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.icon-button:hover {
  color: var(--ink);
  border-color: #aaa295;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.file-summary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-name {
  max-width: 52vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.file-meta {
  margin-top: 4px;
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-only {
  width: 40px;
  height: 40px;
  display: inline-grid;
  padding: 0;
  background: #f1eee7;
  color: var(--ink);
  border: 1px solid var(--line);
}

.icon-only:hover {
  background: #e9e4da;
}

.work-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 510px;
  min-height: 0;
}

.page-stage {
  min-width: 0;
  padding: 18px;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 10px 14px;
  margin-bottom: 18px;
  background: rgba(246, 244, 239, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(14px);
}

.status-group {
  display: flex;
  gap: 22px;
}

.metric-label {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 700;
}

.status-group strong {
  font-size: 20px;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.zoom-control input {
  width: 140px;
  accent-color: var(--primary);
}

.progress-strip {
  margin-bottom: 18px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.progress-text {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #e7e2d8;
}

.progress-track span {
  position: relative;
  display: block;
  width: 0%;
  height: 100%;
  overflow: hidden;
  background: var(--primary);
  transition: width 120ms ease;
}

.progress-strip.is-active .progress-track span::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  animation: progress-shine 1.1s ease-in-out infinite;
}

.page-grid {
  --grid-thumb: var(--thumb);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-thumb), 100%), var(--grid-thumb)));
  gap: 16px;
  justify-content: start;
  align-items: start;
}

.page-card {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 10px;
  min-width: 0;
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(31, 41, 51, 0.08);
  cursor: pointer;
  user-select: none;
}

.page-card:hover {
  border-color: #b9d7d0;
}

.page-card.selected {
  background: var(--soft-danger);
  border-color: var(--danger);
}

.thumb-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 10px;
  background: #ebe7de;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.thumb-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
  box-shadow: 0 2px 10px rgba(31, 41, 51, 0.14);
}

.remove-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(216, 66, 47, 0.35);
}

.page-card.selected .remove-badge {
  display: inline-flex;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.page-number {
  font-weight: 800;
}

.page-size {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-panel {
  position: sticky;
  top: 74px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(100vh - 74px);
  min-width: 0;
  overflow-y: auto;
  padding: 18px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.panel-section {
  display: grid;
  gap: 10px;
}

.hint {
  line-height: 1.45;
}

.field-label,
.list-title {
  font-size: 13px;
  font-weight: 800;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
}

.range-row input {
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.range-row input:focus,
.button:focus-visible,
.icon-button:focus-visible,
.icon-only:focus-visible {
  outline: 3px solid rgba(246, 164, 52, 0.55);
  outline-offset: 2px;
}

.message {
  min-height: 19px;
  font-size: 13px;
}

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

.selected-list-wrap {
  min-height: 110px;
  overflow: hidden;
}

.list-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.list-title span:last-child {
  color: var(--muted);
  font-weight: 700;
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow: auto;
  max-height: 210px;
  padding-right: 2px;
}

.page-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft-danger);
  color: var(--danger-strong);
  font-weight: 800;
  font-size: 13px;
}

.result-section {
  grid-template-columns: 40px 1fr;
  align-items: start;
  min-width: 0;
  gap: 12px;
  padding: 14px;
  border: 1px solid #b9dbc6;
  border-radius: 8px;
  background: #effaf3;
}

.result-section > .button,
.result-actions,
.action-group {
  grid-column: 1 / -1;
}

.result-actions {
  display: grid;
  gap: 12px;
}

.action-group {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(45, 138, 80, 0.18);
}

.action-label {
  margin: 0;
  color: #42624b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.button-grid .button {
  min-width: 0;
}

.cloud-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #42624b;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.cloud-status::before {
  content: "";
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 720ms linear infinite;
}

.share-box {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.share-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: start;
}

.share-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

#shareUrl {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
}

.qr-note {
  margin: 0;
  color: #46515d;
  font-size: 13px;
  line-height: 1.45;
}

.qr-wrap {
  display: grid;
  place-items: center;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-wrap canvas,
.qr-wrap img {
  display: block;
  width: min(164px, 100%) !important;
  height: auto !important;
  aspect-ratio: 1;
}

.share-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.share-action {
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}

.share-action:hover {
  background: #f1eee7;
}

.share-action svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.success-icon {
  width: 40px;
  height: 40px;
  color: var(--success);
}

.success-icon svg {
  width: 28px;
  height: 28px;
}

#resultMeta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.full-width {
  width: 100%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 40;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 700;
}

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

@keyframes progress-shine {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(100%);
  }
}

@media (max-width: 980px) {
  .work-area {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  .button-grid,
  .share-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .upload-view {
    padding: 18px;
    grid-template-rows: auto minmax(calc(100vh - 80px), auto) auto;
  }

  .upload-panel {
    min-height: 380px;
    padding: 30px 18px;
  }

  h1 {
    font-size: 30px;
  }

  .info-grid,
  .tutorial-grid,
  .language-grid,
  .tutorial-step,
  .tutorial-feature-grid {
    grid-template-columns: 1fr;
  }

  .share-logo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-page {
    padding: 18px;
  }

  .page-hero h1 {
    font-size: 34px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .file-name {
    max-width: calc(100vw - 92px);
  }

  .top-actions {
    width: 100%;
    justify-content: stretch;
  }

  .top-actions .button {
    flex: 1 1 auto;
    padding: 0 10px;
  }

  .stage-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-group {
    width: 100%;
    justify-content: space-between;
  }

  .zoom-control,
  .zoom-control input {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .page-grid {
    justify-content: center;
  }

  .button span,
  .icon-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
