:root {
  --primary-color: #007aff;
  --primary-gradient: linear-gradient(135deg, #007aff 0%, #00c6ff 100%);
  --glass-bg: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.45);
  --text-main: #1d1d1f;
  --text-secondary: #86868b;
  --shadow-soft: 0 8px 32px rgba(31, 38, 135, 0.07);
  --shadow-float: 0 18px 45px rgba(0, 122, 255, 0.12);
  --border-radius-lg: 24px;
  --border-radius-md: 18px;
  --page-top-offset: calc(86px + env(safe-area-inset-top));
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family:
    "Poppins",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text-main);
  background: #f5f7fb;
}

body.modal-open {
  overflow: hidden;
}

#background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(
      circle at 8% 12%,
      rgba(0, 122, 255, 0.08) 0%,
      transparent 40%
    ),
    radial-gradient(
      circle at 92% 78%,
      rgba(0, 198, 255, 0.08) 0%,
      transparent 40%
    ),
    radial-gradient(
      circle at 50% 60%,
      rgba(255, 45, 85, 0.04) 0%,
      transparent 70%
    ),
    linear-gradient(180deg, #f8fbff 0%, #f5f7fb 100%);
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 14px 24px;
  background-color: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
}

.navbarLeft,
.navbarRight {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
}

.navbarLeft {
  left: 24px;
}

.navbarRight {
  right: 24px;
}

.logo,
.desktop-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.logo img {
  height: 30px;
}

.desktop-logo img,
.desktop-logo-mark {
  height: 30px;
}

.navIconButton {
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
  cursor: pointer;
}

.navIconButton img {
  width: 20px;
  height: 20px;
}

body.iframe-embed .navbar {
  display: none;
}

body.iframe-embed {
  --page-top-offset: 0px;
  background: transparent;
}

#toolsMain {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: var(--page-top-offset) 16px calc(24px + env(safe-area-inset-bottom));
}

body.iframe-embed #toolsMain {
  max-width: none;
  min-height: 100dvh;
  padding: 0;
}

.tools-shell {
  min-height: calc(100dvh - var(--page-top-offset) - 24px);
  padding: 18px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow-soft);
}

body.iframe-embed .tools-shell {
  min-height: 100dvh;
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.tools-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.tools-search {
  flex: 1 1 320px;
  max-width: 480px;
  min-height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.tools-search svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.tools-search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font: inherit;
}

.tools-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tools-filter {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.tools-filter.is-active {
  background: var(--primary-gradient);
  color: #fff;
  border-color: transparent;
}

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

.tools-columns {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin: 20px 0 0 auto;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
}

.tools-columns select {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text-main);
  font: inherit;
}

.tool-card {
  padding: 24px 14px 14px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
}

.tool-card.is-hidden {
  display: none;
}

.tool-number-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e3efff;
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1;
}

.tools-balanced-text {
  max-inline-size: var(--balance-width, none);
  text-wrap: pretty;
}

.tool-card-title.tools-balanced-text,
.tool-modal-title.tools-balanced-text {
  text-wrap: balance;
}

.tool-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 22px 12px 12px;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.04);
  overflow: visible;
}

.tool-card-media-pill {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  transform: translate(-50%, -50%);
}

.tool-card-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  border-radius: 14px;
  background: #ffffff;
}

.tool-card-zones {
  position: absolute;
  inset: 0;
  display: flex;
}

.tool-card-zone {
  flex: 1;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.tool-card-title {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  font-weight: 600;
  min-width: 0;
  text-align: center;
}

.tools-empty {
  grid-column: 1 / -1;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.tool-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 2000;
}

.tool-modal.is-open {
  display: block;
}

.tool-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 16, 32, 0.38);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.tool-modal-dialog {
  position: relative;
  width: min(96vw, 1440px);
  height: min(92dvh, 940px);
  margin: max(20px, env(safe-area-inset-top)) auto;
  padding: 20px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.18);
}

.tool-modal-close {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tool-modal-close svg {
  width: 24px;
  height: 24px;
  display: block;
}

.tool-modal-layout {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 30%);
  gap: 18px;
  min-height: 0;
}

.tool-modal-sidebar,
.tool-modal-viewer {
  min-height: 0;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.tool-modal-sidebar {
  order: 2;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.tool-modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tool-modal-heading h2 {
  margin: 0;
  font-size: clamp(0.98rem, 1.61vw, 1.4rem);
  line-height: 1.22;
}

.tool-modal-heading {
  padding-bottom: 18px;
}

.tool-modal-description {
  margin: 20px 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

.tool-modal-pill-row {
  display: flex;
  justify-content: flex-start;
  flex: 1;
}

.tool-sidebar-section h3 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.tool-versions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-version {
  min-height: 52px;
  padding: 12px 12px 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-version.is-active {
  border-color: rgba(0, 122, 255, 0.2);
  background: linear-gradient(
    135deg,
    rgba(0, 122, 255, 0.12),
    rgba(0, 198, 255, 0.08)
  );
}

.tool-version-button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.tool-version-download {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.tool-version-download svg {
  width: 18px;
  height: 18px;
}

.tool-sidebar-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-action-button {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  background: var(--primary-gradient);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tool-action-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.external-link-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.external-link-action svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.tool-action-button.secondary {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-main);
}

.tool-modal-viewer {
  order: 1;
  position: relative;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: transparent;
  border: 0;
}

.tool-viewer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-viewer-control {
  min-width: 40px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-main);
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.tool-viewer-control svg {
  width: 20px;
  height: 20px;
  display: block;
}

.tool-viewer-fit {
  padding: 0 14px;
  font-size: 0.8rem;
}

.tool-viewer-status {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.tool-viewer-status[hidden] {
  display: none;
}

.tool-viewer-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(0, 122, 255, 0.05), transparent 50%),
    rgba(248, 250, 255, 0.92);
  cursor: grab;
}

.tool-viewer-overlay {
  position: absolute;
  left: 50%;
  bottom: 5%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
  transform: translateX(-50%);
}

.tool-viewer-overlay .tool-viewer-controls,
.tool-viewer-overlay .tool-viewer-status {
  pointer-events: auto;
}

.tool-viewer-scroll.is-dragging {
  cursor: grabbing;
}

.tool-viewer-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
}

.tool-viewer-page {
  width: fit-content;
  max-width: none;
  padding: 14px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.tool-viewer-page canvas {
  display: block;
  max-width: none;
}

.tool-viewer-empty {
  position: absolute;
  inset: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

.tool-viewer-empty.is-visible {
  display: flex;
}

.tool-viewer-empty h3 {
  margin: 0 0 8px;
}

.tool-viewer-empty p {
  margin: 0;
  color: var(--text-secondary);
}

.tools-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  min-width: 180px;
  max-width: min(92vw, 360px);
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  font-size: 0.85rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 2200;
}

.tools-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 920px) {
  .navbarLeft,
  .navbarRight {
    display: none;
  }

  .logo img {
    height: 28px;
  }

  .tool-modal-dialog {
    width: min(96vw, 960px);
    height: min(94dvh, 980px);
    padding: 16px;
  }

  .tool-modal-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .tool-modal-sidebar {
    order: 1;
  }

  .tool-modal-viewer {
    order: 2;
    min-height: 320px;
  }

  .tools-columns {
    display: none;
  }

  .tool-viewer-overlay {
    bottom: 16px;
    width: calc(100% - 24px);
    max-width: calc(100% - 24px);
    justify-content: center;
  }
}

@media (hover: none) {
  .tool-card-zones {
    display: none;
  }
}

@media (max-width: 640px) {
  #toolsMain {
    padding: var(--page-top-offset) 10px
      calc(18px + env(safe-area-inset-bottom));
  }

  .tools-shell {
    padding: 12px;
    border-radius: 24px;
  }

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

  .tool-card {
    padding: 12px;
    border-radius: 20px;
  }

  .tool-card-media {
    border-radius: 18px;
  }

  .tool-modal-dialog {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    margin: 6px auto;
    border-radius: 24px;
  }

  .tool-modal-sidebar,
  .tool-modal-viewer {
    border-radius: 20px;
  }
}
