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

:root {
  --bg: #0c0c10;
  --surface: #16161e;
  --surface2: #1e1e28;
  --border: #2a2a36;
  --border2: #38384a;
  --text: #e2e2ea;
  --text2: #8888a0;
  --text3: #5c5c72;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --accent-bg: rgba(59, 130, 246, 0.1);
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.1);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.1);
  --yellow: #fbbf24;
  --yellow-bg: rgba(251, 191, 36, 0.1);
  --radius: 10px;
  --radius-lg: 14px;
}

html {
  font-size: 15px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand .hl {
  color: var(--accent);
}

.top-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 16px 0 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.content {
  padding: 28px 0 60px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeUp 0.25s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hint {
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.btn {
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn.accent {
  background: var(--accent);
  color: #fff;
}

.btn.accent:hover {
  background: var(--accent2);
}

.btn.ghost {
  background: var(--surface);
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn.ghost:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
}

.lang-btn {
  font-weight: 700;
  letter-spacing: 0.5px;
  min-width: 36px;
  font-size: 0.8rem;
}

.bg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.bg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.bg-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.bg-card p {
  font-size: 0.8rem;
  color: var(--text3);
  margin-bottom: 12px;
}

.preview-box {
  width: 100%;
  aspect-ratio: 256 / 192;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

.upload-btn {
  display: block;
  text-align: center;
  padding: 8px;
  border: 1px dashed var(--border2);
  border-radius: 8px;
  color: var(--text2);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.color-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.color-group h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.color-group p {
  font-size: 0.78rem;
  color: var(--text3);
  margin-bottom: 12px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-row input[type="color"] {
  width: 44px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: var(--surface);
}

.color-hex {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  color: var(--text2);
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.music-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 500px;
}

.music-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.music-card > p {
  font-size: 0.82rem;
  color: var(--text3);
  margin-bottom: 16px;
}

.music-upload {
  margin-bottom: 12px;
}

.upload-btn.wide {
  display: inline-block;
  padding: 10px 24px;
}

.music-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.bgm-tag {
  font-size: 0.82rem;
  color: var(--green);
  background: var(--green-bg);
  padding: 4px 10px;
  border-radius: 6px;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--red);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}

.music-card .note {
  margin-top: 0;
}

.music-card code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--accent);
}

.note {
  margin-top: 20px;
  padding: 12px;
  background: var(--yellow-bg);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--yellow);
}

.toggle-row {
  padding-top: 4px;
}

.toggle {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  border: none;
  background: var(--border2);
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.toggle.on {
  background: var(--green);
}

.toggle.on::after {
  transform: translateX(20px);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.settings-card h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.settings-card p {
  font-size: 0.78rem;
  color: var(--text3);
  margin-bottom: 10px;
}

.text-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.toast-area {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.82rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.2s ease;
}

.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.preview-overlay.open {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 700px;
  width: 92%;
}

.preview-panel .preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.preview-panel .preview-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.preview-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
}

.preview-close:hover {
  color: var(--text);
}

.preview-dsi-wrap {
  text-align: center;
}

.preview-dsi-wrap img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
}
