:root {
  color-scheme: dark;
  --bg: #0a0b0f;
  --bg-2: #0e1016;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ECECF1;
  --text-soft: #A8ADB8;
  --muted: #6E747F;
  --grad: linear-gradient(120deg, #a78bfa 0%, #67e8f9 100%);
  --grad-soft: linear-gradient(120deg, rgba(167,139,250,0.16), rgba(103,232,249,0.16));
  --accent: #a78bfa;
  --accent-2: #67e8f9;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.42);
  --radius: 20px;
  --shell: min(1140px, 90%);
  --font-display: "Sora", "PingFang SC", "Microsoft YaHei UI", "Segoe UI", sans-serif;
  --font-body: "Inter", "PingFang SC", "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fb;
  --bg-2: #eef0f6;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-2: rgba(255, 255, 255, 0.9);
  --surface-hover: rgba(255, 255, 255, 0.96);
  --border: rgba(15, 18, 30, 0.08);
  --border-strong: rgba(15, 18, 30, 0.15);
  --text: #14161d;
  --text-soft: #464b57;
  --muted: #80868f;
  --grad: linear-gradient(120deg, #7c5cff 0%, #0ea5b7 100%);
  --grad-soft: linear-gradient(120deg, rgba(124,92,255,0.12), rgba(14,165,183,0.12));
  --accent: #7c5cff;
  --accent-2: #0ea5b7;
  --shadow: 0 22px 54px rgba(20, 25, 50, 0.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora::before, .aurora::after {
  content: ""; position: absolute; width: 55vw; height: 55vw; border-radius: 50%;
  filter: blur(90px); opacity: 0.85;
}
.aurora::before { top: -16vw; left: -8vw; background: radial-gradient(circle, rgba(167, 139, 250, 0.2), transparent 65%); }
.aurora::after { bottom: -20vw; right: -10vw; background: radial-gradient(circle, rgba(103, 232, 249, 0.12), transparent 65%); }

.shell { width: var(--shell); margin: 0 auto; position: relative; z-index: 1; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; height: 70px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.wordmark {
  display: inline-flex; align-items: center; gap: 11px;
  font-family: var(--font-display); font-weight: 800; letter-spacing: 0.12em; font-size: 0.8rem;
}
.mark {
  width: 30px; height: 30px; border-radius: 9px 9px 9px 3px;
  background: var(--grad); color: #0a0b0f; display: grid; place-items: center; font-weight: 900;
  box-shadow: 0 8px 20px rgba(124, 92, 255, 0.35);
}
.nav { display: flex; align-items: center; gap: 16px; }
.nav a { color: var(--text-soft); font-size: 0.82rem; letter-spacing: 0.04em; }
.nav a:hover { color: var(--text); }

.lang-toggle {
  min-width: 40px; height: 36px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.lang-toggle:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }

.theme-toggle {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="light"] .theme-toggle .sun { display: none; }

main { padding: 48px 0 60px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.tool-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}
.crumbs { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; }
.tool-head h1 {
  margin: 6px 0 0; font-family: var(--font-display); font-size: clamp(1.6rem, 3vw, 2.3rem);
  letter-spacing: -0.03em;
}
.subtitle { margin: 0; color: var(--text-soft); font-size: 0.85rem; text-align: right; max-width: 320px; }

.tool-body {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 22px; padding: 24px;
}
.panel {
  background: rgba(255,255,255,0.015); border: 1px solid var(--border); border-radius: 18px; padding: 20px;
}
.label {
  display: block; margin-bottom: 10px; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}

textarea {
  width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--border); border-radius: 14px;
  background: rgba(255,255,255,0.02); color: var(--text); padding: 14px 16px; outline: none;
}
textarea:focus, input:focus, select:focus { border-color: var(--border-strong); }

.content-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--muted); font-size: 0.7rem; }
.content-meta .hint { flex: 1; }
#contentCount { white-space: nowrap; }
#contentCount.over-limit { color: #fb7185; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick-actions button {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-soft); border-radius: 999px;
  padding: 8px 12px; transition: all 0.2s ease;
}
.quick-actions button:hover { color: var(--text); border-color: var(--border-strong); }

.field { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.field-wide { grid-column: 1 / -1; }
.field label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.field > .label { margin-bottom: 0; }

input[type="file"] {
  width: 100%; border: 1px dashed var(--border-strong); border-radius: 12px; padding: 10px 12px;
  background: rgba(255,255,255,0.02); color: var(--text-soft); font-size: 0.82rem;
}
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 6px 12px; border: none; border-radius: 8px;
  background: var(--grad-soft); color: var(--text); font-weight: 600; cursor: pointer;
}

.thumb-wrap { min-height: 0; }
.thumb-wrap img { max-width: 100%; max-height: 120px; border-radius: 12px; border: 1px solid var(--border); margin-top: 8px; }

.checkbox { display: inline-flex; align-items: center; gap: 9px; color: var(--text-soft); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.settings {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 6px;
  border-top: 1px solid var(--border); padding-top: 16px;
}
select {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,0.02);
  color: var(--text); padding: 10px 12px; outline: none;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

.advanced { margin-top: 16px; border: 1px solid var(--border); border-radius: 14px; padding: 6px 16px; background: rgba(255,255,255,0.015); }
.advanced summary { cursor: pointer; padding: 10px 0; color: var(--text-soft); font-size: 0.82rem; letter-spacing: 0.04em; }
.advanced[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 6px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.primary, .ghost {
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--border); transition: transform 0.2s ease;
}
.primary { background: var(--grad); color: #0a0b0f; border: none; font-weight: 700; }
.ghost { background: var(--surface-2); color: var(--text); }
.primary:hover, .ghost:hover { transform: translateY(-1px); }
.primary:disabled, .ghost:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.status { margin-top: 16px; color: var(--text-soft); font-size: 0.85rem; line-height: 1.7; min-height: 22px; }
.status.is-error { color: #fb7185; }
.meta { margin-top: 4px; color: var(--muted); font-size: 0.78rem; letter-spacing: 0.02em; }

.preview { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; min-height: 340px; }
.canvas-wrap {
  width: min(100%, 300px); aspect-ratio: 1;
  border-radius: 22px; background: linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border: 1px solid var(--border); display: grid; place-items: center; padding: 18px;
}
#canvas {
  width: 100%; height: 100%; display: block; border-radius: 12px;
  background: #fff; box-shadow: 0 8px 26px rgba(0,0,0,0.18); object-fit: contain;
}

footer {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 0 44px;
  color: var(--muted); border-top: 1px solid var(--border); margin-top: 14px; font-size: 0.82rem;
}

@media (max-width: 860px) {
  .tool-body { grid-template-columns: 1fr; }
  .preview { order: -1; }
}
@media (max-width: 640px) {
  .shell { width: calc(100% - 28px); }
  .topbar { height: auto; padding: 12px 0; flex-wrap: wrap; gap: 12px; }
  .tool-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .subtitle { text-align: left; }
  .settings { grid-template-columns: 1fr; }
  footer { flex-direction: column; align-items: flex-start; }
}
