:root {
  --bg:#ffffff;
  --fg:#1a1a1a;
  --accent:#0066cc;
  --accent-light:#4da3ff;
  --border:#e0e0e0;
  --panel-bg:#f8f9fa;
  --hover-bg:#f0f0f0;
  --max-width: 1200px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
}
* { box-sizing: border-box; }
html,body {
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
}
.app-header {
  padding:24px 20px;
  border-bottom:1px solid var(--border);
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--bg);
}
h1 {
  margin:0 0 8px;
  font-size:1.8rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 16px;
  font-size: 1rem;
  color: #666;
  line-height: 1.4;
}
.tabs button {
  margin-right:8px;
  padding:10px 20px;
  background:var(--bg);
  color:var(--fg);
  border:1px solid var(--border);
  border-radius:6px;
  cursor:pointer;
  font-size:14px;
  font-weight:500;
  transition: all 0.2s ease;
}
.tabs button:hover {
  background:var(--hover-bg);
  border-color:var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color:#fff;
  box-shadow: var(--shadow);
}
main {
  padding:32px 20px;
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 60vh;
}
.tab { display:none; }
.tab.active { display:block; }
.panel {
  background:var(--panel-bg);
  border:1px solid var(--border);
  padding:24px;
  border-radius:12px;
  box-shadow: var(--shadow);
  margin-top:20px;
}
.canvas-row {
  display:flex;
  gap:24px;
  margin-top:24px;
  flex-wrap:wrap;
  justify-content: center;
}
.canvas-row > div {
  text-align: center;
}
.canvas-row h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: var(--fg);
}
canvas {
  image-rendering: pixelated;
  border:2px solid var(--border);
  background:#fff;
  border-radius:8px;
  box-shadow: var(--shadow);
  max-width: 100%;
  display: block;
  margin: 0 auto;
}
.controls {
  display:flex;
  gap:16px;
  align-items:center;
  margin:20px 0;
  flex-wrap:wrap;
}
.controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}
.file-grid {
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:16px;
  margin-bottom: 20px;
}
.file-grid label {
  font-weight: 500;
  display: block;
}
.footer {
  text-align:center;
  padding:32px 20px;
  border-top:1px solid var(--border);
  margin-top:60px;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  color: #666;
  font-size: 14px;
}
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  color: var(--accent-light);
  text-decoration: underline;
}
button {
  cursor:pointer;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}
button:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}
button:active {
  transform: translateY(0);
}
button[data-dl] {
  background: #28a745;
  margin-top: 12px;
}
button[data-dl]:hover {
  background: #2dbc4e;
}

input[type="file"] {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  width: 100%;
  font-size: 14px;
  margin-top: 4px;
}
input[type="file"]:hover {
  border-color: var(--accent);
}

input[type="number"],
input[type="range"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  font-size: 14px;
}
input[type="number"]:focus,
input[type="range"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

h2 {
  font-size: 1.4rem;
  margin: 0 0 16px;
  color: var(--fg);
}

h3 {
  font-size: 1.1rem;
  margin: 16px 0 8px;
  color: var(--fg);
}

ul {
  padding-left: 24px;
  line-height: 1.8;
}

li {
  margin-bottom: 8px;
}

section p {
  margin-bottom: 16px;
  color: #444;
  line-height: 1.8;
}

/* Help icon and tooltip styles */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e0e0e0;
  color: #666;
  font-size: 12px;
  font-weight: bold;
  cursor: help;
  margin-left: 6px;
  position: relative;
  transition: all 0.2s ease;
}

.help-icon:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.1);
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: normal;
  white-space: nowrap;
  min-width: 200px;
  max-width: 300px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  pointer-events: none;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #333;
}

.help-icon:hover .tooltip {
  opacity: 1;
  visibility: visible;
  bottom: calc(100% + 12px);
}

.label-with-help {
  display: inline-flex;
  align-items: center;
}

.file-label-with-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* Accordion styles */
.accordion {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.accordion-header {
  background: var(--panel-bg);
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
}

.accordion-header:hover {
  background: var(--hover-bg);
}

.accordion-header.active {
  background: var(--accent);
  color: white;
}

.accordion-icon {
  transition: transform 0.3s ease;
  font-size: 18px;
  font-weight: bold;
}

.accordion-header.active .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: white;
}

.accordion-content.active {
  max-height: 1000px;
}

.accordion-body {
  padding: 20px;
  border-top: 1px solid var(--border);
}

.accordion-body h4 {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 1rem;
}

.accordion-body p {
  margin-bottom: 12px;
  line-height: 1.6;
  color: #555;
}

.accordion-body ul {
  margin: 12px 0;
  padding-left: 20px;
}

.accordion-body li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.principle-example {
  background: #f8f9fa;
  border-left: 4px solid var(--accent);
  padding: 16px;
  margin: 16px 0;
  border-radius: 0 6px 6px 0;
}

.principle-example h5 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.pixel-demo {
  font-family: monospace;
  font-size: 18px;
  line-height: 1.2;
  background: white;
  padding: 8px;
  border-radius: 4px;
  margin: 8px 0;
}
