:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --focus: #111827;
  --btn-bg: #0f172a;
  --btn-fg: #ffffff;
  --btn-muted: #f3f4f6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

.site-header {
  display: flex; justify-content: center; padding: 20px;
}
.site-header .brand {
  margin: 0; font-family: "Poppins", sans-serif; font-size: 44px; font-weight: 700;
  background: linear-gradient(90deg, #7c3aed, #f97316);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.site-footer {
  padding: 24px 20px;
  max-width: 980px;
  margin: 0 auto;
  text-align: center;
}
.site-header h1 { margin: 0 0 6px; font-size: 28px; }
.sub { margin: 0; color: var(--muted); }

.app {
  max-width: 980px;
  margin: 8px auto 40px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  justify-items: center;
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
}

.panel {
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 12px;
  width: 100%;
  margin: 0 auto;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.file-label input { display: none; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--btn-muted);
  color: var(--fg);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 120ms ease, background 120ms ease, opacity 120ms ease;
}
.btn:hover { transform: none; }
.btn:active { transform: none; }
.btn.primary,
.btn.gradient {
  background: linear-gradient(90deg, #7c3aed, #f97316);
  color: #fff;
  border-color: transparent;
}
.btn.primary:hover,
.btn.gradient:hover {
  filter: brightness(1.05);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  min-height: 18px;
}

.controls { display: grid; gap: 16px; margin: 16px 0; }
.control label {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600;
}
.control input[type="range"], #settingsFilter input[type="range"], #settingsWatermark input[type="range"] { accent-color: #000; }

.actions { display: flex; gap: 10px; }

.preview {
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.canvas-wrap {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  min-height: 240px;
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  overflow: auto;
}
canvas { display: block; }

.hint { color: var(--muted); font-size: 13px; margin: 0; }

.toolbar {
  display: flex; justify-content: flex-start; align-items: center; gap: 12px; margin: 12px 0;
  position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 12px 0;
}
.toolbar-right { display: flex; gap: 16px; align-items: center; margin-left: 12px; }
.settings-item { min-width: 240px; position: relative; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,1px,1px); white-space: nowrap; border: 0; }

.site-footer small { color: var(--muted); }

@media (max-width: 700px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { flex-direction: column; align-items: stretch; }
}

.modern-select {
  appearance: none; border: 1px solid var(--line); background: #fff; padding: 10px 14px;
  border-radius: 10px; font-weight: 600; transition: box-shadow 120ms ease, border-color 120ms ease;
}
.modern-select:focus { outline: none; border-color: #111; box-shadow: 0 0 0 3px rgba(0,0,0,0.08); }
.select-wrap { position: relative; display: inline-block; }
.select-wrap .modern-select { padding-right: 40px; }
.select-wrap::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 7px solid var(--fg);
  transform: translateY(-30%); pointer-events: none;
}

#settingsOverlay input[type="range"] { accent-color: #000; }