* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-start: #f1ece5;
  --bg-end: #dbe5f0;
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(34, 52, 74, 0.08);
  --text-main: #1f2937;
  --text-muted: #64748b;
  --accent: #1d4ed8;
  --accent-strong: #0f172a;
  --accent-soft: rgba(29, 78, 216, 0.08);
  --danger-bg: #fff1f2;
  --danger-border: #fb7185;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 28%),
    linear-gradient(135deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
  padding: 24px;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
  backdrop-filter: blur(16px);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 32px;
  background:
    radial-gradient(circle at right top, rgba(29, 78, 216, 0.16), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.84));
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.page-header h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.1;
  margin-bottom: 10px;
}

.subtitle {
  max-width: 720px;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.7;
}

.back-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(29, 78, 216, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 600;
}

main {
  flex: 1;
  padding: 32px;
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  gap: 24px;
}

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

.panel,
.result-section {
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 24px;
  min-width: 0;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.panel-heading p {
  color: var(--text-muted);
  line-height: 1.6;
}

textarea {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  background: rgba(248, 250, 252, 0.95);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  min-height: 280px;
}

textarea:focus {
  outline: none;
  border-color: rgba(29, 78, 216, 0.45);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.08);
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

button {
  padding: 12px 18px;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  min-width: 132px;
}

button:hover {
  transform: translateY(-1px);
}

#visualizeBtn,
#downloadBtn,
#fullscreenBtn {
  background: linear-gradient(135deg, #173b8f, #2563eb);
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.16);
}

.secondary-btn {
  background: rgba(15, 23, 42, 0.06);
  color: var(--accent-strong);
}

.helper-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.example-chip {
  min-width: auto;
  padding: 10px 14px;
  border: 1px solid rgba(29, 78, 216, 0.16);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}

.drop-hint {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.04);
  color: var(--text-muted);
  font-size: 14px;
}

.image-container {
  background:
    linear-gradient(45deg, rgba(148, 163, 184, 0.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.12) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  border: 1px dashed rgba(100, 116, 139, 0.35);
  border-radius: 22px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  margin-bottom: 20px;
  overflow: auto;
}

#previewImage {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.14);
  animation: fadeIn 0.24s ease;
}

#svgPreview {
  width: 100%;
  min-height: 380px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.08);
  animation: fadeIn 0.24s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.result-section {
  display: grid;
  gap: 16px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.info-item .label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 13px;
}

.info-item span:last-child {
  color: var(--text-main);
  font-size: 15px;
  font-family: Consolas, "SFMono-Regular", monospace;
  word-break: break-word;
}

.error-section {
  background: var(--danger-bg);
  border: 1px solid rgba(251, 113, 133, 0.22);
  border-left: 4px solid var(--danger-border);
  padding: 16px 18px;
  border-radius: 16px;
  margin-bottom: 16px;
}

#errorMessage {
  color: #be123c;
  font-weight: 500;
}

.empty-state {
  flex: 1;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  border-radius: 22px;
  background: rgba(248, 250, 252, 0.72);
  border: 1px dashed rgba(148, 163, 184, 0.24);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.7;
}

footer {
  background: rgba(248, 250, 252, 0.72);
  padding: 20px 32px 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  .container {
    min-height: calc(100vh - 24px);
    border-radius: 20px;
  }

  .page-header,
  main,
  footer {
    padding: 20px;
  }

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

  .back-link {
    width: fit-content;
  }

  .panel,
  .result-section {
    padding: 18px;
    border-radius: 20px;
  }

  .image-container {
    min-height: 280px;
  }

  button {
    width: 100%;
  }
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.12);
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.48);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(71, 85, 105, 0.66);
}

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.94);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.fullscreen-overlay[hidden],
.toast[hidden],
.error-section[hidden],
.result-section[hidden] {
  display: none !important;
}

.fullscreen-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-content img,
.fullscreen-content .svg-stage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.36);
}

.fullscreen-overlay .close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  color: white;
  font-size: 30px;
  cursor: pointer;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  padding: 8px;
  background: rgba(15, 23, 42, 0.05);
  border-radius: 16px;
  width: fit-content;
  flex-wrap: wrap;
}

.mode-btn {
  min-width: auto;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.78);
}

.mode-btn.active {
  background: #fff;
  color: var(--accent-strong);
  border-color: rgba(148, 163, 184, 0.18);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 10000;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: white;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.28);
  font-size: 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
