:root {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #10182f;
  background: #f6f7fb;
  line-height: 1.5;
  font-size: 16px;
}

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

body {
  margin: 0;
  padding: 0;
  background: inherit;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero {
  padding: 2rem;
  background: white;
  border-radius: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  box-shadow: 0 10px 45px rgba(16, 24, 47, 0.08);
}

.hero h1 {
  margin: 0.35rem 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  color: #4f5a78;
  margin: 0;
}

.hero-actions {
  margin-left: auto;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.primary-link {
  background: #2463eb;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
}

.primary-link:hover {
  background: #184fc5;
}

.note {
  color: #4f5a78;
  font-size: 0.85rem;
}

.panel {
  background: white;
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.panel h2 {
  margin: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
  color: #1f2a44;
}

.field input,
.field select {
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #d6d9e4;
}

.field input:focus,
.field select:focus,
.text-input:focus,
.number-input:focus {
  outline: 2px solid #2463eb;
  border-color: #2463eb;
}

.input-with-unit {
  display: flex;
  align-items: center;
  background: #f1f4fe;
  border-radius: 10px;
}

.input-with-unit input {
  border: none;
  flex: 1;
  background: transparent;
}

.input-with-unit .unit {
  padding: 0 0.75rem;
  color: #4f5a78;
  font-weight: 600;
}

.rows-headings {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(120px, 0.9fr)) 40px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7d899f;
  margin-bottom: 0.35rem;
}

.rows-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-row {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(120px, 0.9fr)) 40px;
  gap: 0.5rem;
  align-items: center;
}

.text-input,
.number-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #d6d9e4;
  font-size: 0.95rem;
}

.ghost-btn {
  border: 1px dashed #9aa5bc;
  background: transparent;
  border-radius: 12px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.ghost-btn:hover {
  border-color: #2463eb;
  color: #2463eb;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: #c13d3d;
  line-height: 1;
}

#kerf-input {
  max-width: 100px;
}

.kerf {
  max-width: 150px;
}

.unit {
  margin-left: auto;
  margin-right: 4px;
}

.two-d-only {
  min-width: 260px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.primary-btn {
  padding: 0.85rem 1.75rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(120deg, #2563eb, #7c3aed);
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 15px 35px rgba(37, 99, 235, 0.4);
}

.primary-btn:hover {
  opacity: 0.9;
}

.secondary-btn {
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  border: 1px solid #d6d9e4;
  background: white;
  font-weight: 600;
  cursor: pointer;
  transition: border 0.2s, color 0.2s;
}

.secondary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-btn:hover:not(:disabled) {
  border-color: #2563eb;
  color: #2563eb;
}

.hint {
  margin: 0;
  color: #5a647c;
  font-size: 0.9rem;
}

.results-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.results-summary {
  background: #f7f9ff;
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid #e0e6ff;
  color: #1f2a44;
}

.results-summary strong {
  font-size: 1.15rem;
}

.results-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.result-card {
  border: 1px solid #e3e7f2;
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: #fff;
}

.result-card h3 {
  margin: 0;
  font-size: 1rem;
  color: #111b2f;
}

.result-card ul {
  margin: 0.35rem 0 0 1.05rem;
  padding: 0;
  color: #4f5a78;
}

.layout-preview {
  border: 1px solid #e0e6ff;
  border-radius: 10px;
  padding: 0.5rem;
  background: #f8f9ff;
}

.layout-canvas {
  width: 100%;
  height: auto;
  max-width: 320px;
  display: block;
  margin: 0.35rem auto 0;
}

.badge {
  display: inline-flex;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #ecf2ff;
  color: #1d4ed8;
  font-weight: 600;
}

.warning {
  color: #b45309;
  font-weight: 600;
}

#form-message {
  margin-top: 1rem;
  font-weight: 600;
  color: #b91c1c;
}

.hidden {
  display: none !important;
}

.input-row.error input {
  border-color: #f97316;
  background: #fff7ed;
}

@media (max-width: 860px) {
  .rows-headings,
  .input-row {
    grid-template-columns: 1fr;
  }

  .rows-headings span:not(:first-child),
  .two-d-label {
    display: none;
  }

  .hero {
    flex-direction: column;
    text-align: center;
  }

  .hero-actions {
    margin-left: 0;
    text-align: center;
  }
}
