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

:root {
  --bg:         #F4F1EC;
  --surface:    #FDFBF8;
  --border:     #DDD8CE;
  --text:       #1A1714;
  --muted:      #7A746A;
  --accent:     #2D6A4F;
  --accent-lt:  #D6EEE2;
  --danger:     #A63428;
  --shadow-sm:  0 1px 6px rgba(26,23,20,0.07);
  --shadow-md:  0 4px 20px rgba(26,23,20,0.10);
  --shadow-lg:  0 10px 40px rgba(26,23,20,0.14);
  --r:          6px;

  --ff-mono:  ui-monospace, Menlo, Consolas, 'Courier New', monospace;
  --ff-serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;

  --header-h:    50px;
  --exportbar-h: 54px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 13px;
  line-height: 1.5;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header__brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.header__icon {
  width: 32px;
  height: 32px;
  margin-right: 12px;
}

.header__brand h1 {
  font-family: var(--ff-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header__tag {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 18px 32px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.panel { padding: 12px 0; }

.panel__title {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}

.divider { height: 1px; background: var(--border); flex-shrink: 0; }

.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }

label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

.label-val { font-size: 10.5px; color: var(--text); font-weight: 500; }

textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 6px 9px;
  font-family: var(--ff-mono);
  font-size: 12.5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
textarea { resize: none; min-height: 54px; }
textarea:focus, select:focus { border-color: var(--accent); }

.select-wrap { position: relative; }
.select-wrap::after {
  content: '↓';
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
  font-size: 10px;
}
.select-wrap.flex1 { flex: 1; }
select { appearance: none; -webkit-appearance: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  display: block;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 0.12s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.3); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none; cursor: pointer;
}

.style-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }

.style-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 6px 3px;
  font-family: var(--ff-mono);
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.12s;
  letter-spacing: 0.02em;
}
.style-btn:hover:not(.active) { border-color: var(--muted); color: var(--text); }
.style-btn.active {
  background: var(--accent-lt);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.color-row { display: flex; gap: 8px; align-items: flex-start; }

.color-swatch {
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  font-size: 9.5px; color: var(--muted);
}

input[type="color"] {
  width: 38px; height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 2px 3px;
  background: var(--bg);
  cursor: pointer; outline: none;
}

.gradient-toggle-area { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.toggle-row { display: flex; align-items: center; gap: 7px; }

.toggle {
  position: relative;
  display: inline-block;
  width: 32px; height: 17px;
  cursor: pointer; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 17px;
  transition: background 0.18s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.18s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::before { transform: translateX(15px); }

.toggle-label { font-size: 10.5px; color: var(--muted); }

.gradient-extra { display: flex; gap: 7px; align-items: center; }

.upload-zone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: var(--r);
  padding: 11px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--muted);
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-lt); }
.upload-zone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%; padding: 0;
}
.upload-zone__icon { font-size: 18px; margin-bottom: 3px; }
.upload-zone__text { font-size: 10.5px; }

.logo-info {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-top: 7px;
}

.logo-filename {
  font-size: 10.5px; color: var(--accent);
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 190px;
}

.clear-btn {
  font-family: var(--ff-mono);
  font-size: 10.5px; color: var(--danger);
  background: none; border: none; cursor: pointer;
  flex-shrink: 0;
}
.clear-btn:hover { text-decoration: underline; }

.hidden { display: none !important; }

.preview {
  display: grid;
  grid-template-rows: 1fr var(--exportbar-h);
  overflow: hidden;
  background: var(--bg);
}

.qr-viewport {
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.qr-viewport::-webkit-scrollbar { width: 5px; height: 5px; }
.qr-viewport::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.qr-card {
  background: white;
  padding: 22px;
  border-radius: 10px;
  box-shadow: var(--shadow-md), 0 0 0 1px var(--border);
  flex-shrink: 0;
  transition: box-shadow 0.25s;
}
.qr-card:hover { box-shadow: var(--shadow-lg), 0 0 0 1px var(--border); }

#qrCanvas {
  width: 100%;
  height: 100%;
  line-height: 0;
}

#qrCanvas canvas {
  display: block;
  width:  100% !important;
  height: 100% !important;
}

.export-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: var(--exportbar-h);
  flex-shrink: 0;
}

.fmt-tabs {
  display: flex; gap: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 3px;
}

.fmt-tab {
  font-family: var(--ff-mono);
  font-size: 10.5px;
  padding: 4px 12px;
  border: none; border-radius: 4px;
  background: transparent; color: var(--muted);
  cursor: pointer; letter-spacing: 0.04em;
  transition: all 0.12s;
}
.fmt-tab.active { background: var(--text); color: white; }
.fmt-tab:hover:not(.active) { color: var(--text); }

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

.btn {
  font-family: var(--ff-mono);
  font-size: 11.5px;
  padding: 7px 16px;
  border-radius: var(--r);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
}
.btn--primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn--primary:hover { background: #235c42; }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

.zoom-badge {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.03em;
  opacity: 0;
  transition: opacity 0.2s;
}
.zoom-badge.visible { opacity: 1; }

@media (max-width: 680px) {
  html, body { overflow: auto; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) auto 1fr;
    height: auto;
  }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 55vh; }
  .preview { min-height: 50vh; }
}
