:root {
  --ink: #1c2230;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #8a9683;
  --accent-dark: #56684d;
  --bg: #f2f2f3;
  --panel-bg: #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; }

h1, h2 {
  font-family: "Playfair Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 500;
  color: var(--accent-dark);
}

body {
  margin: 0;
  font-family: "Playfair Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  padding: 20px 24px 8px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.app-body {
  display: flex;
  flex: 1;
  gap: 20px;
  padding: 12px 24px 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.controls {
  flex: 0 0 380px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.panel.hidden { display: none; }

.panel h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-dark);
  margin: 16px 0 10px;
}

.panel h2:first-child { margin-top: 0; }

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 4px;
  color: var(--ink);
}

.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.88rem;
  background: #fff;
  color: var(--ink);
}

.field input[type="range"] {
  width: 100%;
}

.slider-with-number {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-with-number input[type="range"] {
  flex: 1;
  min-width: 0;
}

.slider-with-number input[type="number"] {
  width: 62px;
  flex: none;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fff;
  color: var(--ink);
}

.field input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.field.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field.checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

output {
  font-size: 0.8rem;
  color: var(--muted);
}

.file-label {
  display: inline-block;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px dashed var(--accent);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--accent-dark);
}

#photoInput { margin-top: 6px; width: 100%; font-size: 0.8rem; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-row span:last-child {
  font-size: 0.85rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex: none;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: background 0.15s;
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.lines-table-head {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr 0.9fr 0.6fr 0.9fr 20px;
  gap: 6px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 0 2px 4px;
}

.line-row {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr 0.9fr 0.6fr 0.9fr 20px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.line-row input[type="text"],
.line-row input[type="number"],
.line-row select {
  width: 100%;
  padding: 5px 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 0.76rem;
  background: #fff;
  color: var(--ink);
}

.line-row input[type="color"] {
  width: 100%;
  height: 26px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

.line-row input[type="range"] {
  width: 100%;
}

.line-delete {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  line-height: 1;
}

.line-delete:hover {
  color: #d33;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.btn {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

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

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

.btn.secondary {
  background: #e1e5df;
  color: var(--ink);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.btn.secondary:hover { background: #e6e9ef; }

.preview-wrap {
  flex: 1 1 480px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-header {
  align-self: stretch;
  margin-bottom: 12px;
}

.preview-header h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-dark);
  margin: 0 0 4px;
}

#pageInfo {
  display: block;
  font-family: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--muted);
}

.field input[type="range"] {
  width: 100%;
  accent-color: #56684d;
}

.canvas-shell {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
}

#sheetCanvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  background: #fff;
  touch-action: none;
}

.app-footer {
  text-align: center;
  padding: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 760px) {
  .controls {
    flex: 1 1 100%;
    max-width: none;
  }
}
