:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --primary: #a855f7;
  --primary-2: #ec4899;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

img,
svg {
  display: block;
  max-width: 100%;
}

.tool-hero {
  padding: 3.5rem 1.5rem 2rem;
  text-align: center;
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  color: #fff;
}

.tool-hero h1 {
  margin: 0.75rem 0 0.75rem;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.1;
  color: #fff;
}

.tool-hero p {
  margin: 0 auto;
  max-width: 720px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.05rem;
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

.tool-page {
  width: 100%;
  padding: 1rem 1.25rem 3rem;
}

.tool-shell {
  max-width: 1280px;
  margin: 0 auto;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 1.5rem;
  align-items: start;
}

.tool-main,
.tool-aside {
  min-width: 0;
}

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card-head {
  margin-bottom: 1.25rem;
}

.card-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.form-field {
  min-width: 0;
}

.form-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.range-value {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.input-styled,
.color-input,
.range-input,
.code-output {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.input-styled,
.color-input {
  height: 46px;
  padding: 0 0.9rem;
}

.input-styled:focus,
.color-input:focus,
.range-input:focus,
.code-output:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
}

.select:not(.is-multiple):not(.is-rounded) {
  width: 100%;
}

.select select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 0 0.9rem;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

.color-input {
  padding: 0.25rem;
  cursor: pointer;
  height: 46px;
}

.range-input {
  appearance: none;
  height: 10px;
  background: #e2e8f0;
  cursor: pointer;
  border-radius: 5px;
}

.range-input::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.35);
}

.range-input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.35);
}

.action-row {
  display: flex;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.calc-btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 700;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.calc-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.output-block label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.code-output {
  min-height: 200px;
  resize: vertical;
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  background: #0f172a;
  color: #e2e8f0;
  border-color: #1e293b;
}

.preview-card {
  position: sticky;
  top: 1rem;
}

.preview-box {
  margin-top: 0.5rem;
}

.preview-frame {
  width: 100%;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  overflow: hidden;
}

#animTarget {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #4f46e5, #a855f7);
  border-radius: 16px;
}

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

@keyframes loader-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-0.45rem);
    opacity: 1;
  }
}

@keyframes loader-bars {
  0%,
  100% {
    transform: scaleY(0.6);
    opacity: 0.55;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes loader-pulse {
  0%,
  100% {
    transform: scale(0.85);
    opacity: 0.55;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

.related-tools-section,
.content-section {
  margin-top: 2rem;
}

.related-tools-section h3,
.prose-card h2 {
  margin: 0 0 1rem;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
}

.tool-card:hover {
  border-color: #c7d2fe;
}

.icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 0.8rem;
}

.tool-title {
  margin: 0 0 0.25rem;
  font-weight: 700;
}

.tool-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.prose-card h2 {
  margin-top: 1.5rem;
}

.prose-card h2:first-child {
  margin-top: 0;
}

.prose-card p,
.prose-card li {
  color: #334155;
  line-height: 1.75;
}

.steps-box {
  counter-reset: steps;
  padding-left: 1.2rem;
}

.steps-box li {
  list-style: none;
  padding: 0.5rem 0 0.5rem 2.5rem;
  position: relative;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.steps-box li:last-child {
  border-bottom: none;
}

.steps-box li::before {
  counter-increment: steps;
  content: counter(steps);
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 24px;
  text-align: center;
}

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

.feature-pill {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  background: #fff;
}

.feature-pill strong {
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.feature-pill p {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.85rem;
}

.faq-item h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.faq-item p {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.65;
}

.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-list li {
  border-bottom: 1px solid var(--border);
}

.related-list li:last-child {
  border-bottom: none;
}

.related-list a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.related-list a:hover {
  color: var(--primary);
}

.related-list a::before {
  content: "→";
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}

.footer {
  margin-top: auto;
}

@media (max-width: 1024px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .preview-card {
    position: static;
  }

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

@media (max-width: 768px) {
  .tool-hero {
    padding-top: 2.5rem;
  }

  .tool-page {
    padding-inline: 0.75rem;
  }

  .calc-card {
    padding: 1rem;
  }

  .form-grid--2,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .action-row {
    flex-direction: column;
  }

  .preview-frame {
    min-height: 220px;
  }
}