:root {
      color-scheme: light;
      --bg: #f6f8fb;
      --surface: #ffffff;
      --surface-soft: #f0f5f7;
      --text: #17212b;
      --muted: #667789;
      --line: #d9e2ea;
      --brand: #0f766e;
      --brand-strong: #0b5d57;
      --blue: #2563eb;
      --amber: #b7791f;
      --red: #b42318;
      --shadow: 0 18px 50px rgba(29, 45, 57, 0.11);
      --stage-shadow: 0 34px 90px rgba(23, 33, 43, 0.18), 0 8px 22px rgba(15, 118, 110, 0.08);
      --radius: 8px;
      --max: 1180px;
    }

    [data-theme="dark"] {
      color-scheme: dark;
      --bg: #08111f;
      --surface: #0f1b2d;
      --surface-soft: #17263b;
      --text: #edf5ff;
      --muted: #a7b4c7;
      --line: #27384f;
      --brand: #2dd4bf;
      --brand-strong: #5eead4;
      --blue: #60a5fa;
      --amber: #f6c86d;
      --red: #f87171;
      --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
      --stage-shadow: 0 36px 110px rgba(0, 0, 0, 0.58), 0 0 42px rgba(45, 212, 191, 0.12);
    }

    * {
      box-sizing: border-box;
    }

    html {
      scroll-behavior: smooth;
    }

    body {
      margin: 0;
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(246, 248, 251, 0) 260px),
        linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.04) 42%, rgba(183, 121, 31, 0.06)),
        var(--bg);
      color: var(--text);
      font-family: Arial, Helvetica, sans-serif;
      font-size: 16px;
      line-height: 1.55;
      letter-spacing: 0;
    }

    [data-theme="dark"] body {
      background:
        radial-gradient(circle at 50% -8%, rgba(45, 212, 191, 0.22), rgba(8, 17, 31, 0) 30%),
        radial-gradient(circle at 82% 18%, rgba(96, 165, 250, 0.16), rgba(8, 17, 31, 0) 28%),
        linear-gradient(180deg, #08111f 0%, #0b1422 42%, #09111d 100%);
    }

    a {
      color: inherit;
      text-decoration: none;
    }

    button,
    input,
    select,
    textarea {
      font: inherit;
      letter-spacing: 0;
    }

    button {
      cursor: pointer;
    }

    .topbar {
      position: sticky;
      top: 0;
      z-index: 10;
      background: rgba(246, 248, 251, 0.94);
      border-bottom: 1px solid rgba(217, 226, 234, 0.8);
      backdrop-filter: blur(14px);
    }

    [data-theme="dark"] .topbar {
      background: rgba(8, 17, 31, 0.84);
      border-bottom-color: rgba(54, 76, 107, 0.7);
    }

    .topbar-inner {
      width: min(100% - 32px, var(--max));
      min-height: 68px;
      margin: 0 auto;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 20px;
    }

    .brand {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      font-weight: 800;
      white-space: nowrap;
    }

    .brand-mark {
      width: 34px;
      height: 34px;
      display: grid;
      place-items: center;
      border-radius: 8px;
      background: var(--brand);
      color: #ffffff;
      font-size: 15px;
      font-weight: 800;
    }

    [data-theme="dark"] .brand-mark {
      box-shadow: 0 0 24px rgba(45, 212, 191, 0.22);
    }

    .topbar-actions {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .nav {
      display: flex;
      align-items: center;
      gap: 6px;
      color: var(--muted);
      font-size: 14px;
    }

    .nav a {
      min-height: 38px;
      padding: 8px 12px;
      border-radius: 8px;
      display: inline-flex;
      align-items: center;
      white-space: nowrap;
    }

    .nav a:hover {
      background: var(--surface-soft);
      color: var(--text);
    }

    .theme-toggle {
      position: relative;
      width: 40px;
      height: 40px;
      flex: 0 0 auto;
      border: 1px solid var(--line);
      border-radius: 8px;
      display: grid;
      place-items: center;
      background: rgba(255, 255, 255, 0.78);
      color: var(--text);
      box-shadow: 0 10px 24px rgba(29, 45, 57, 0.08);
    }

    .theme-toggle:hover {
      border-color: var(--brand);
      background: var(--surface);
    }

    .theme-toggle:focus-visible {
      outline: 3px solid rgba(15, 118, 110, 0.18);
      outline-offset: 2px;
    }

    .theme-toggle-icon {
      position: relative;
      width: 17px;
      height: 17px;
      border-radius: 50%;
      background: var(--brand);
      box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
      transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
    }

    .theme-toggle-icon::before {
      content: "";
      position: absolute;
      inset: -5px;
      border-radius: 50%;
      border: 2px solid rgba(15, 118, 110, 0.3);
      opacity: 1;
    }

    [data-theme="dark"] .theme-toggle {
      background: rgba(15, 27, 45, 0.78);
      box-shadow: 0 0 24px rgba(45, 212, 191, 0.1);
    }

    [data-theme="dark"] .theme-toggle-icon {
      transform: translateX(1px);
      background: #dbeafe;
      box-shadow: -5px 0 0 0 #0f1b2d, 0 0 18px rgba(96, 165, 250, 0.34);
    }

    [data-theme="dark"] .theme-toggle-icon::before {
      opacity: 0;
    }

    main {
      width: min(100% - 32px, var(--max));
      margin: 0 auto;
      padding: 34px 0 54px;
    }

    .hero {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 22px;
      justify-items: center;
      padding: 18px 0 30px;
    }

    .hero-copy {
      max-width: 820px;
      padding-top: 10px;
      text-align: center;
    }

    .eyebrow {
      margin: 0 0 10px;
      color: var(--brand-strong);
      font-size: 13px;
      font-weight: 800;
      text-transform: uppercase;
    }

    h1,
    h2,
    h3,
    p {
      overflow-wrap: anywhere;
    }

    h1 {
      margin: 0 auto;
      max-width: 860px;
      font-size: 44px;
      line-height: 1.08;
      letter-spacing: 0;
    }

    .hero-copy p {
      max-width: 740px;
      margin: 18px auto 0;
      color: var(--muted);
      font-size: 18px;
    }

    .trust-row {
      width: min(100%, 880px);
      margin-top: 0;
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
    }

    .trust-item {
      min-height: 76px;
      padding: 14px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: rgba(255, 255, 255, 0.78);
      box-shadow: 0 12px 30px rgba(29, 45, 57, 0.06);
    }

    [data-theme="dark"] .trust-item {
      background: rgba(15, 27, 45, 0.72);
      box-shadow: 0 16px 42px rgba(0, 0, 0, 0.18);
    }

    .trust-item strong {
      display: block;
      font-size: 14px;
    }

    .trust-item span {
      display: block;
      margin-top: 4px;
      color: var(--muted);
      font-size: 13px;
      line-height: 1.35;
    }

    .converter {
      position: relative;
      width: min(100%, 860px);
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.9)),
        var(--surface);
      border: 1px solid rgba(184, 201, 213, 0.88);
      border-radius: var(--radius);
      box-shadow: var(--stage-shadow);
      overflow: hidden;
    }

    [data-theme="dark"] .converter {
      border: 1px solid transparent;
      background:
        linear-gradient(180deg, rgba(15, 27, 45, 0.98), rgba(11, 22, 38, 0.96)) padding-box,
        linear-gradient(115deg, rgba(45, 212, 191, 0.68), rgba(96, 165, 250, 0.62), rgba(246, 200, 109, 0.5), rgba(45, 212, 191, 0.68)) border-box;
      background-size: 100% 100%, 260% 260%;
      animation: converterBorderFlow 9s linear infinite;
    }

    @keyframes converterBorderFlow {
      0% {
        background-position: 0 0, 0% 50%;
      }
      50% {
        background-position: 0 0, 100% 50%;
      }
      100% {
        background-position: 0 0, 0% 50%;
      }
    }

    .converter::before {
      content: "";
      position: absolute;
      inset: 0 0 auto;
      height: 3px;
      background: linear-gradient(90deg, var(--brand), var(--blue), var(--amber));
      pointer-events: none;
    }

    .converter::after {
      content: "";
      position: absolute;
      inset: 3px 0 auto;
      height: 86px;
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0));
      pointer-events: none;
    }

    [data-theme="dark"] .converter::before {
      background: linear-gradient(90deg, rgba(45, 212, 191, 0.9), rgba(96, 165, 250, 0.9), rgba(246, 200, 109, 0.75), rgba(45, 212, 191, 0.9));
      background-size: 240% 100%;
      animation: topGlowFlow 7s linear infinite;
      opacity: 0.82;
    }

    [data-theme="dark"] .converter::after {
      background: linear-gradient(180deg, rgba(96, 165, 250, 0.1), rgba(15, 27, 45, 0));
    }

    @keyframes topGlowFlow {
      from {
        background-position: 0% 50%;
      }
      to {
        background-position: 200% 50%;
      }
    }

    .tabs {
      position: relative;
      z-index: 1;
      display: grid;
      grid-template-columns: 1fr 1fr;
      border-bottom: 1px solid var(--line);
      background: rgba(249, 251, 252, 0.86);
    }

    [data-theme="dark"] .tabs {
      border-bottom-color: rgba(39, 56, 79, 0.92);
      background: rgba(13, 25, 42, 0.82);
    }

    .tab-button {
      min-height: 58px;
      border: 0;
      border-bottom: 3px solid transparent;
      background: transparent;
      color: var(--muted);
      font-weight: 800;
    }

    .tab-button.is-active {
      border-bottom-color: var(--brand);
      background: #ffffff;
      color: var(--text);
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }

    [data-theme="dark"] .tab-button.is-active {
      background: rgba(18, 33, 54, 0.95);
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 24px rgba(45, 212, 191, 0.08);
    }

    .tool-panel {
      position: relative;
      z-index: 1;
      display: none;
      padding: 26px;
    }

    .tool-panel.is-active {
      display: block;
    }

    .drop-zone {
      position: relative;
      min-height: 188px;
      display: grid;
      place-items: center;
      padding: 22px;
      border: 2px dashed #b7c7d5;
      border-radius: var(--radius);
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 252, 253, 0.96)),
        #fbfdff;
      text-align: center;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
      transition: border-color 160ms ease, background 160ms ease;
    }

    [data-theme="dark"] .drop-zone {
      border-color: #3d526f;
      background:
        linear-gradient(180deg, rgba(17, 31, 52, 0.96), rgba(12, 24, 41, 0.98)),
        var(--surface);
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    }

    .drop-zone.is-dragging,
    .drop-zone:hover,
    .drop-zone:focus-visible {
      border-color: var(--brand);
      background: #f2fbf8;
      outline: 0;
    }

    [data-theme="dark"] .drop-zone.is-dragging,
    [data-theme="dark"] .drop-zone:hover,
    [data-theme="dark"] .drop-zone:focus-visible {
      border-color: var(--brand);
      background: rgba(14, 42, 57, 0.92);
    }

    .drop-zone input {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
    }

    .drop-icon {
      width: 52px;
      height: 52px;
      margin: 0 auto 12px;
      display: grid;
      place-items: center;
      border-radius: 8px;
      background: linear-gradient(180deg, #effbf8, #dff2ee);
      color: var(--brand-strong);
      font-weight: 900;
      box-shadow: 0 10px 24px rgba(15, 118, 110, 0.12);
    }

    [data-theme="dark"] .drop-icon {
      background: linear-gradient(180deg, rgba(45, 212, 191, 0.22), rgba(96, 165, 250, 0.12));
      color: var(--brand-strong);
      box-shadow: 0 0 28px rgba(45, 212, 191, 0.18);
    }

    .drop-title {
      display: block;
      font-weight: 800;
    }

    .drop-note {
      display: block;
      margin-top: 5px;
      color: var(--muted);
      font-size: 14px;
    }

    .image-list {
      margin: 18px 0 0;
      display: grid;
      gap: 10px;
    }

    .image-item {
      display: grid;
      grid-template-columns: 56px minmax(0, 1fr) auto;
      gap: 12px;
      align-items: center;
      min-height: 72px;
      padding: 8px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #ffffff;
    }

    [data-theme="dark"] .image-item {
      border-color: var(--line);
      background: rgba(15, 27, 45, 0.88);
    }

    .image-item.is-previewed {
      border-color: rgba(15, 118, 110, 0.62);
      background: #f5fbf9;
    }

    [data-theme="dark"] .image-item.is-previewed {
      border-color: rgba(45, 212, 191, 0.76);
      background: rgba(14, 48, 58, 0.68);
    }

    .thumb {
      width: 56px;
      height: 56px;
      object-fit: cover;
      border-radius: 6px;
      background: #eef3f7;
    }

    [data-theme="dark"] .thumb {
      background: #17263b;
    }

    .file-name {
      margin: 0;
      font-size: 14px;
      font-weight: 800;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .file-meta {
      display: block;
      margin-top: 2px;
      color: var(--muted);
      font-size: 13px;
    }

    .item-actions {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .icon-button {
      width: 34px;
      height: 34px;
      padding: 0;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: #ffffff;
      color: var(--text);
      font-weight: 800;
    }

    [data-theme="dark"] .icon-button {
      background: rgba(15, 27, 45, 0.9);
      border-color: var(--line);
    }

    .icon-button:hover {
      border-color: #b7c7d5;
      background: var(--surface-soft);
    }

    .preview-panel {
      margin-top: 18px;
      display: grid;
      grid-template-columns: minmax(180px, 0.72fr) minmax(0, 1fr);
      gap: 18px;
      align-items: center;
      padding: 16px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #fbfdff;
    }

    [data-theme="dark"] .preview-panel {
      border-color: var(--line);
      background: rgba(11, 22, 38, 0.72);
    }

    .page-preview {
      width: min(100%, 220px);
      min-height: 156px;
      justify-self: center;
      display: grid;
      place-items: center;
      border: 1px solid #c8d5df;
      background: #ffffff;
      box-shadow: 0 12px 30px rgba(29, 45, 57, 0.12);
    }

    [data-theme="dark"] .page-preview {
      border-color: #3d526f;
      background: #e8edf3;
      box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    }

    .page-preview-inner {
      width: 100%;
      height: 100%;
      display: grid;
      place-items: center;
      padding: 10%;
    }

    .page-preview img {
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
      border-radius: 2px;
    }

    .preview-copy strong,
    .preview-copy span {
      display: block;
    }

    .preview-copy strong {
      font-size: 15px;
    }

    .preview-copy span {
      margin-top: 6px;
      color: var(--muted);
      font-size: 13px;
    }

    .settings {
      margin-top: 22px;
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 14px;
    }

    label {
      display: grid;
      gap: 7px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 800;
    }

    select,
    input[type="text"],
    input[type="number"],
    textarea {
      width: 100%;
      min-height: 44px;
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: #ffffff;
      color: var(--text);
    }

    [data-theme="dark"] select,
    [data-theme="dark"] input[type="text"],
    [data-theme="dark"] input[type="number"],
    [data-theme="dark"] textarea {
      border-color: var(--line);
      background: rgba(8, 17, 31, 0.62);
      color: var(--text);
    }

    [data-theme="dark"] select {
      color-scheme: dark;
    }

    select:focus,
    input:focus,
    textarea:focus {
      border-color: var(--brand);
      outline: 3px solid rgba(15, 118, 110, 0.12);
    }

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

    .range-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 46px;
      align-items: center;
      gap: 10px;
    }

    .range-value {
      color: var(--text);
      text-align: right;
      font-size: 13px;
    }

    .full {
      grid-column: 1 / -1;
    }

    textarea {
      min-height: 268px;
      resize: vertical;
      line-height: 1.5;
    }

    [data-theme="dark"] textarea::placeholder {
      color: #75859b;
    }

    .actions {
      margin-top: 22px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
    }

    .button {
      min-height: 46px;
      padding: 11px 16px;
      border: 1px solid transparent;
      border-radius: 7px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      font-weight: 800;
    }

    .button.primary {
      background: var(--brand);
      color: #ffffff;
      box-shadow: 0 12px 26px rgba(15, 118, 110, 0.22);
    }

    [data-theme="dark"] .button.primary {
      color: #04111f;
      box-shadow: 0 14px 30px rgba(45, 212, 191, 0.2);
    }

    .button.primary:hover {
      background: var(--brand-strong);
      box-shadow: 0 14px 30px rgba(15, 118, 110, 0.28);
    }

    .button.secondary {
      border-color: var(--line);
      background: #ffffff;
      color: var(--text);
    }

    [data-theme="dark"] .button.secondary {
      background: rgba(15, 27, 45, 0.86);
      border-color: var(--line);
    }

    .button.secondary:hover {
      background: var(--surface-soft);
    }

    .button:disabled {
      cursor: not-allowed;
      opacity: 0.54;
    }

    .status {
      margin-top: 14px;
      min-height: 24px;
      color: var(--muted);
      font-size: 14px;
    }

    .status.success {
      color: var(--brand-strong);
      font-weight: 800;
    }

    .status.error {
      color: var(--red);
      font-weight: 800;
    }

    .quick-stats {
      margin-top: 18px;
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 10px;
    }

    .stat {
      min-height: 74px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #fbfdff;
    }

    [data-theme="dark"] .stat {
      border-color: var(--line);
      background: rgba(11, 22, 38, 0.72);
    }

    .stat b {
      display: block;
      font-size: 18px;
    }

    .stat span {
      display: block;
      color: var(--muted);
      font-size: 12px;
    }

    .content-grid {
      display: grid;
      grid-template-columns: minmax(0, 0.9fr) minmax(280px, 0.55fr);
      gap: 24px;
      margin-top: 28px;
      align-items: start;
    }

    .info-section,
    .side-section {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      padding: 24px;
    }

    [data-theme="dark"] .info-section,
    [data-theme="dark"] .side-section {
      background: rgba(15, 27, 45, 0.82);
      box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
    }

    .info-section h2,
    .side-section h2 {
      margin: 0 0 14px;
      font-size: 24px;
      line-height: 1.2;
    }

    .info-section h3 {
      margin: 24px 0 8px;
      font-size: 18px;
    }

    .info-section p,
    .side-section p {
      margin: 0 0 14px;
      color: var(--muted);
    }

    .tool-links {
      display: grid;
      gap: 10px;
      margin: 14px 0 0;
    }

    .tool-link {
      min-height: 48px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: #fbfdff;
      color: var(--text);
      font-weight: 800;
    }

    [data-theme="dark"] .tool-link {
      border-color: var(--line);
      background: rgba(11, 22, 38, 0.72);
    }

    .tool-link span {
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
    }

    .footer {
      width: min(100% - 32px, var(--max));
      margin: 0 auto;
      padding: 0 0 34px;
      color: var(--muted);
      font-size: 14px;
    }

    .footer-inner {
      border-top: 1px solid var(--line);
      padding-top: 20px;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: 12px;
    }

    .hidden {
      display: none !important;
    }

    @media (max-width: 940px) {
      .hero,
      .content-grid {
        grid-template-columns: 1fr;
      }

      h1 {
        font-size: 36px;
      }
    }

    @media (max-width: 680px) {
      .topbar-inner {
        min-height: auto;
        padding: 12px 0;
        align-items: flex-start;
        flex-direction: column;
      }

      .nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
      }

      .topbar-actions {
        width: 100%;
        align-items: center;
      }

      .topbar-actions .nav {
        flex: 1 1 auto;
      }

      h1 {
        font-size: 30px;
      }

      .hero-copy p {
        font-size: 16px;
      }

      .trust-row,
      .settings,
      .quick-stats {
        grid-template-columns: 1fr;
      }

      .tool-panel {
        padding: 18px;
      }

      .image-item {
        grid-template-columns: 48px minmax(0, 1fr);
      }

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

      .thumb {
        width: 48px;
        height: 48px;
      }

      .item-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
      }

      .actions {
        align-items: stretch;
        flex-direction: column;
      }

      .button {
        width: 100%;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      [data-theme="dark"] .converter,
      [data-theme="dark"] .converter::before {
        animation: none;
      }
    }
