:root {
  --bg: #f0efe8;
  --ink: #1c1c1a;
  --muted: #6b6b63;
  --pink: #c22a63;
  --green-dark: #234d3d;
  --green-btn: #7fa393;
  --green-btn-hover: #6f9384;
  --border: #d8d6cc;
  --card-bg: #ffffff;
  --note-bg: #eee6d3;
  --note-border: #c8862f;
}

* { box-sizing: border-box; }

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

.topbar {
  height: 6px;
  background: linear-gradient(90deg, var(--pink), #8a8f7a);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.kicker {
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--pink);
  font-weight: 700;
  margin: 0 0 8px;
}

h1 {
  font-size: 2.4rem;
  margin: 0 0 12px;
  font-weight: 800;
}

.subtitle {
  color: var(--muted);
  max-width: 640px;
  line-height: 1.5;
  margin: 0;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0 32px;
}

.layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

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

.shape-toggle {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.shape-btn {
  padding: 10px 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.shape-btn:hover { border-color: var(--green-dark); }

.shape-btn.active {
  background: var(--green-dark);
  color: #fff;
  border-color: var(--green-dark);
}

.shape-hint {
  margin: 10px 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.sample-guide-wrap {
  margin-bottom: 14px;
}

.sample-guide-toggle {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--green-dark);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.sample-guide-toggle:hover {
  border-color: var(--green-btn);
  background: #f5f7f2;
}

.sample-guide-panel {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.sample-guide-panel img {
  width: 100%;
  height: auto;
  display: block;
}

.dropzone {
  border: 2px dashed #b9b7ac;
  border-radius: 4px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  position: relative;
  background: #fafaf6;
  margin-bottom: 24px;
  transition: border-color .15s, background .15s;
}

.dropzone.dragover {
  border-color: var(--pink);
  background: #fff5f8;
}

.dropzone::before,
.dropzone::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--pink);
}
.dropzone::before { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.dropzone::after { bottom: -2px; right: -2px; border-left: none; border-top: none; }

.drop-filename {
  font-family: "Courier New", Courier, monospace;
  font-size: 1rem;
  margin: 0 0 6px;
}

.drop-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  position: relative;
  margin-bottom: 20px;
}

.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--pink);
}
.card::before { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.card::after { bottom: -2px; right: -2px; border-left: none; border-top: none; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

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

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.input-suffix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.input-suffix input {
  border: none;
  outline: none;
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
  font-family: "Courier New", Courier, monospace;
}

.input-suffix span {
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
  border-left: 1px solid var(--border);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.input-suffix--narrow { max-width: 220px; }

.field-checkbox { margin-bottom: 16px; }

.password-field-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.password-field-wrap input {
  border: none;
  outline: none;
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
  font-family: "Courier New", Courier, monospace;
}

.password-toggle-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 100%;
  padding: 8px;
  border: none;
  border-left: 1px solid var(--border);
  background: #f5f4ee;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.password-toggle-btn:hover {
  background: #ece9dc;
}

.row-inline {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.field--tiny {
  margin-bottom: 0;
  flex: 0 0 auto;
}

.input-suffix--tiny {
  width: 100px;
}

.field-checkbox--inline {
  margin-bottom: 0;
  padding-bottom: 10px; /* can chinh cho thang hang voi input phia tren nhan */
}

.paper-preset-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-size: 0.95rem;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}

.paper-preset-select:focus {
  outline: none;
  border-color: var(--green-dark);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.section-divider::before,
.section-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-label input { width: 16px; height: 16px; }

.btn-row {
  display: flex;
  gap: 12px;
}

.preview-btn {
  flex: 0 0 auto;
  padding: 16px 20px;
  border: 1px solid var(--green-dark);
  border-radius: 4px;
  background: #fff;
  color: var(--green-dark);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.preview-btn:hover:not(:disabled) { background: #f2f6f4; }
.preview-btn:disabled { opacity: 0.6; cursor: default; }

.submit-btn {
  flex: 1 1 auto;
  padding: 16px;
  border: none;
  border-radius: 4px;
  background: var(--green-btn);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.submit-btn:hover:not(:disabled) { background: var(--green-btn-hover); }

.submit-btn:disabled {
  opacity: 0.75;
  cursor: default;
}

.error-text {
  color: #b3261e;
  font-size: 0.9rem;
  margin-top: 10px;
  min-height: 1.2em;
}

.result-card h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-weight: 800;
}

.preview-card h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 800;
}

.preview-count {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.preview-svg-wrap {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafaf6;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#previewSvg {
  width: 100%;
  height: 100%;
}

#previewSvg .piece {
  fill: #dfeee7;
  stroke: var(--green-dark);
  stroke-width: 0.5;
}

#previewSvg .paper-outline {
  fill: #ffffff;
  stroke: #333;
  stroke-width: 1;
}

.result-status {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 0.95rem;
}

.cold-start-note {
  background: var(--note-bg);
  border-left: 4px solid var(--note-border);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: #4a4a3f;
  border-radius: 2px;
  margin-bottom: 12px;
}

.download-link {
  display: inline-block;
  padding: 10px 16px;
  background: var(--green-dark);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.9rem;
}

.backend-note {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: "Courier New", Courier, monospace;
  margin-top: 16px;
  word-break: break-all;
}

.access-code-card {
  border-color: var(--pink);
  margin-bottom: 20px;
}

.access-code-card .field label {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
}

.required-mark {
  color: var(--pink);
}

.access-code-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  font-family: "Courier New", Courier, monospace;
  box-sizing: border-box;
}

.access-code-card input:focus {
  outline: none;
  border-color: var(--pink);
}

.access-code-hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
