:root {
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --ink: #1c2330;
  --muted: #5b6472;
  --line: #d7dde7;
  --panel: #ffffff;
  --accent: #1f9f66;
  --accent-hover: #167d50;
  --action: #2a5ee8;
  --action-hover: #1f48b7;
  --shadow: 0 18px 40px rgba(28, 35, 48, 0.11);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
}

.page-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 22px;
  background: #fff;
  animation: fade-slide 380ms ease-out;
}

.topbar h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  margin-top: 16px;
  display: grid;
  gap: 16px;
}

@media (min-width: 880px) {
  .workspace {
    grid-template-columns: 390px minmax(0, 1fr);
    align-items: start;
  }
}

.settings-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 14px;
  animation: fade-slide 430ms ease-out;
}

.settings-panel h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
}

.setting-group {
  display: grid;
  gap: 7px;
}

.setting-group label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.3px;
}

.setting-group input[type="text"],
.setting-group select,
.setting-group textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.setting-group input[type="text"]:focus,
.setting-group select:focus,
.setting-group textarea:focus {
  border-color: #8ab4ff;
  box-shadow: 0 0 0 4px rgba(64, 128, 255, 0.14);
}

.setting-group textarea {
  resize: vertical;
  min-height: 200px;
  line-height: 1.4;
}

.font-size-stepper {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 34px 42px;
  gap: 8px;
  align-items: center;
}

.font-step-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  height: 42px;
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.font-step-btn:hover {
  background: #f4f7ff;
}

.font-step-btn:focus-visible {
  outline: none;
  border-color: #8ab4ff;
  box-shadow: 0 0 0 4px rgba(64, 128, 255, 0.14);
}

.font-size-stepper input[type="number"] {
  text-align: center;
}

.font-step-unit {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.setting-group.two-col {
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) and (max-width: 879px) {
  .setting-group.two-col {
    grid-template-columns: 1fr 1fr;
  }
}

.setting-group.inline {
  display: block;
}

.setting-group.inline label {
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
}

.status-message {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--muted);
}

.btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 130ms ease, background-color 130ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--action);
  color: #fff;
  box-shadow: 0 10px 20px rgba(42, 94, 232, 0.26);
}

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

.btn-success {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(31, 159, 102, 0.28);
}

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

.preview-area {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: auto;
  min-height: 640px;
}

.paper-scale-wrapper {
  position: relative;
  margin: 0 auto;
}

.paper {
  width: 210mm;
  max-width: 210mm;
  min-height: 297mm;
  padding: 16mm 12mm 12mm;
  background: #fff;
  border: 1px solid #1f29371f;
  box-shadow: 0 10px 22px rgba(28, 35, 48, 0.13);
  display: flex;
  flex-direction: column;
  position: relative;
  transform-origin: top left;
  animation: paper-in 360ms ease-out;
}

.paper h2 {
  margin: 0;
  text-align: center;
  font-size: 13mm;
  line-height: 1.15;
  font-weight: 800;
  padding-top: 0;
  padding-bottom: 3mm;
}

.matching-box {
  margin-top: 2mm;
  border: 0.55mm solid #666;
  min-height: 88mm;
  display: grid;
  grid-template-columns: 1fr 0 1fr;
  position: relative;
}

.matching-divider {
  width: 0;
  border-left: 0.55mm dotted #777;
  height: 100%;
}

.matching-column {
  padding: 6mm 9mm;
  display: grid;
  align-content: start;
  gap: 4mm;
}

.match-item {
  font-size: 7.4mm;
  line-height: 1.1;
  word-break: break-word;
}

.paper-footer {
  margin-top: auto;
  padding-top: 4mm;
  border-top: 0.55mm solid #777;
  text-align: center;
  font-size: 4.6mm;
}

@media (max-width: 760px) {
  .page-shell {
    padding: 10px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .settings-panel {
    padding: 16px;
  }
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes paper-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
