:root {
  --bg: #f6f7fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-soft: #f0f2f8;
  --text: #171924;
  --muted: #666b7a;
  --border: #e2e5ee;
  --accent: #645cff;
  --accent-strong: #5148ef;
  --accent-soft: #eeecff;
  --danger: #d7485f;
  --shadow: 0 24px 70px rgba(25, 29, 54, 0.09);
  --radius-lg: 24px;
  --radius-md: 16px;
}

html[data-theme="dark"] {
  --bg: #0d0f16;
  --surface: rgba(23, 26, 37, 0.92);
  --surface-solid: #171a25;
  --surface-soft: #202431;
  --text: #f5f6fb;
  --muted: #a5abba;
  --border: #2c3140;
  --accent: #8c84ff;
  --accent-strong: #a39dff;
  --accent-soft: #292647;
  --danger: #ff7b91;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  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:
    radial-gradient(circle at 15% 5%, rgba(100, 92, 255, 0.11), transparent 30rem),
    radial-gradient(circle at 90% 20%, rgba(98, 200, 255, 0.10), transparent 28rem),
    var(--bg);
  transition: color 0.25s ease, background-color 0.25s ease;
}

button, textarea {
  font: inherit;
}

button {
  color: inherit;
}

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-size: 1.03rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #7d78ff);
  box-shadow: 0 10px 25px rgba(100, 92, 255, 0.3);
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.moon-icon {
  display: none;
}

html[data-theme="dark"] .sun-icon {
  display: none;
}

html[data-theme="dark"] .moon-icon {
  display: block;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 70px;
}

.hero {
  max-width: 760px;
  margin: 26px auto 48px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 4.65rem);
  line-height: 1.03;
  letter-spacing: -0.055em;
}

.hero p {
  max-width: 650px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 22px;
  align-items: stretch;
}

.editor-card,
.converter-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.editor-card {
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar,
.editor-footer {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.editor-toolbar {
  border-bottom: 1px solid var(--border);
}

.editor-toolbar label {
  font-weight: 700;
}

.toolbar-actions,
.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-button {
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.text-button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.text-button.danger:hover {
  color: var(--danger);
  background: rgba(215, 72, 95, 0.1);
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 390px;
  padding: 24px;
  resize: vertical;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 1.04rem;
  line-height: 1.75;
}

textarea::placeholder {
  color: var(--muted);
  opacity: 0.62;
}

textarea:focus {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.editor-footer {
  border-top: 1px solid var(--border);
}

.save-status {
  color: var(--muted);
  font-size: 0.82rem;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  border: 1px solid var(--accent);
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(100, 92, 255, 0.22);
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface-solid);
}

.primary-button svg,
.secondary-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.stat-card {
  min-height: 124px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 35px rgba(22, 25, 45, 0.05);
}

.stat-card.featured {
  grid-column: 1 / -1;
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #817aff);
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
}

.featured .stat-label {
  color: rgba(255, 255, 255, 0.78);
}

.stat-card strong {
  margin-top: 10px;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  letter-spacing: -0.04em;
}

.converter-card {
  margin-top: 24px;
  padding: 28px;
}

.section-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  letter-spacing: -0.04em;
}

.section-heading p {
  max-width: 350px;
  margin: 0 0 4px;
  color: var(--muted);
  text-align: right;
  line-height: 1.6;
}

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

.case-grid button {
  min-height: 105px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  text-align: left;
  background: var(--surface-soft);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.case-grid button:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.case-grid span {
  font-weight: 800;
}

.case-grid small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.info-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.info-grid article {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.info-icon {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.info-grid h3 {
  margin: 14px 0 9px;
  font-size: 1rem;
}

.info-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  padding: 12px 18px;
  border-radius: 12px;
  color: #fff;
  background: #181b26;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

footer {
  padding: 0 20px 34px;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
}

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

  .stats-panel {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat-card.featured {
    grid-column: auto;
  }

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

@media (max-width: 640px) {
  .site-header,
  .page-shell {
    width: min(100% - 24px, 1180px);
  }

  .page-shell {
    padding-top: 15px;
  }

  .hero {
    margin: 20px auto 32px;
  }

  .hero p {
    font-size: 0.98rem;
  }

  .editor-card {
    min-height: 510px;
  }

  .editor-toolbar,
  .editor-footer {
    align-items: flex-start;
  }

  .editor-footer {
    flex-direction: column;
  }

  .footer-actions {
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    flex: 1;
  }

  .stats-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card.featured {
    grid-column: 1 / -1;
  }

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

  .section-heading p {
    text-align: left;
  }

  .converter-card {
    padding: 20px;
  }

  .case-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
