:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1a1f36;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: min(1080px, 92vw);
  margin: 24px auto 48px;
  display: grid;
  gap: 16px;
}

.header h1 {
  margin: 0 0 6px;
}

.header p {
  margin: 0;
  color: var(--muted);
}

.header {
  display: block;
}

.github-link {
  font-size: 12px;
  color: #64748b;
  display: inline-block;
  margin-top: 2px;
  text-decoration: none;
  word-break: break-all;
}

.github-link:hover {
  color: #2563eb;
  text-decoration: underline;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#imageInput {
  display: none;
}

.upload-btn,
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}

.upload-btn {
  background: var(--primary);
  color: #fff;
  border: none;
}

button.secondary {
  margin-left: auto;
}

.canvas-area {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
}

.panel h2,
.config h2,
.kernel-section h2,
.presets h2,
.hover-info h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

canvas {
  width: 100%;
  max-height: 400px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fafafa;
}

.kernel-grid {
  --grid-size: 3;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 80px);
  gap: 8px;
}

.kernel-grid input {
  width: 80px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  text-align: center;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preset-buttons button {
  position: relative;
}

.preset-buttons button.active-preset {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2) inset;
}

.preset-buttons button.active-preset::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #2563eb;
}

.analysis-row {
  display: grid;
  grid-template-columns: minmax(320px, auto) minmax(300px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.analysis-row > .card {
  height: 100%;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 240px));
  gap: 12px;
}

.config-grid label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.config-grid input,
.config-grid select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

#hoverTip {
  margin: 0;
  color: var(--muted);
  font-family: Consolas, Monaco, monospace;
  white-space: pre-wrap;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .canvas-area {
    grid-template-columns: 1fr;
  }

  .analysis-row {
    grid-template-columns: 1fr;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }
}
