:root {
  --bg: #0c0f14;
  --surface: #151a22;
  --surface-2: #1c2330;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #22c55e;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --font: 'Noto Sans SC', 'DM Sans', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-glow), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(99, 102, 241, 0.08), transparent);
  pointer-events: none;
  z-index: 0;
}

.site-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2.5rem 1.5rem 1rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-icon {
  font-size: 1.5rem;
}

.tagline {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.tool-nav {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.nav-btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.nav-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.main-content {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.tool-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tool-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.panel-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.lang-row,
.form-field {
  margin-bottom: 1rem;
}

.lang-row label,
.form-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

select,
input[type='text'],
input[type='file'],
input[type='color'] {
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
}

input[type='color'] {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  margin-top: 0.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.text-area {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.65;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
  min-height: 120px;
}

.text-area:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.status {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  min-height: 1.4em;
}

.status.recording {
  color: #f87171;
}

.status.success {
  color: var(--success);
}

.status.error {
  color: #f87171;
}

.env-hint {
  font-size: 0.85rem;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
}

.progress-wrap {
  margin: 1rem 0 0.75rem;
  padding: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

#tts-progress-percent {
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.progress-bar.done {
  background: linear-gradient(90deg, var(--success), #4ade80);
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}

.link-btn {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.canvas-toolbar input[type='range'] {
  width: 120px;
  vertical-align: middle;
}

.canvas-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.canvas-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.mask-layer {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  touch-action: none;
}

.preview-wrap {
  margin: 1rem 0;
  text-align: center;
}

.preview-wrap canvas {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.wm-controls {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.compress-settings {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.compress-results {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.compress-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.875rem;
}

.compress-item .meta {
  color: var(--text-muted);
}

.compress-item .saved {
  color: var(--success);
  font-weight: 500;
}

.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 100;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 600px) {
  .tool-nav {
    gap: 0.4rem;
  }

  .nav-btn {
    font-size: 0.8rem;
    padding: 0.45rem 0.75rem;
  }

  .card {
    padding: 1.1rem;
  }
}
