:root {
  --ink: #1a1d21;
  --paper: #f5f1eb;
  --bg: #f5f1eb;
  --text: #1a1d21;
  --accent: #c45c3e;
  --accent-light: #e8a090;
  --line: #2d353d;
  --line-light: #8b9aaa;
  --success: #3a7d5c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'DM Mono', monospace;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  background-image: 
    linear-gradient(rgba(45, 53, 61, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 53, 61, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

header {
  padding: 2rem 1.5rem;
  border-bottom: 2px solid var(--line);
  text-align: center;
}

h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 2.25rem;
  font-weight: 400;
  margin: 0 0 0.5rem 0;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0;
  font-size: 0.9rem;
  color: var(--line-light);
  letter-spacing: 0.1em;
}

.header-nav {
  display: none; /* links to other planners (wall, bed) hidden */
  margin-top: 1rem;
  font-size: 0.85rem;
}

.header-nav a {
  color: var(--accent);
  text-decoration: none;
}

.header-nav a:hover {
  text-decoration: underline;
}

main {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  min-height: calc(100vh - 140px);
}

@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}

.inputs-panel {
  padding: 1.5rem;
  background: white;
  border-right: 2px solid var(--line);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.04);
}

@media (max-width: 768px) {
  .inputs-panel {
    border-right: none;
    border-bottom: 2px solid var(--line);
  }
}

.inputs-panel h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.25rem;
  margin: 0 0 1.25rem 0;
  font-weight: 400;
}

.input-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--line);
}

.input-with-unit {
  position: relative;
}

.input-with-unit .unit {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.7rem;
  color: var(--line-light);
}

.input-with-unit input[type="number"] {
  padding-right: 2.25rem;
}

.input-group input[type="number"] {
  font-family: 'DM Mono', monospace;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-light);
  border-radius: 4px;
  background: var(--paper);
  width: 100%;
}

.input-group input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(196, 92, 62, 0.2);
}

.input-group select {
  font-family: 'DM Mono', monospace;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-light);
  border-radius: 4px;
  background: var(--paper);
  width: 100%;
  cursor: pointer;
}

.input-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.input-group .unit,
.input-group .hint {
  font-size: 0.7rem;
  color: var(--line-light);
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
}

.input-group-sheet {
  margin: 1.25rem 0;
  padding: 1rem;
  background: rgba(45, 53, 61, 0.04);
  border: 1px solid var(--line-light);
  border-radius: 6px;
}

.input-group-sheet .input-group {
  margin-bottom: 0.85rem;
}

.input-group-sheet .input-group:last-child {
  margin-bottom: 0;
}

.material-cost-est-inline {
  margin: 1rem 0 0 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.sheet-size-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sheet-size-inputs .input-with-unit {
  width: 5.5rem;
}

.sheet-size-inputs input {
  width: 100%;
}

.sheet-size-sep {
  font-size: 0.9rem;
  color: var(--line-light);
}

.price-input-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-light);
  border-radius: 4px;
  background: var(--paper);
}

.price-input-wrap .price-prefix {
  padding: 0.5rem 0.75rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.95rem;
  color: var(--line);
  border-right: 1px solid var(--line-light);
}

.price-input-wrap input {
  border: none;
  border-radius: 0 4px 4px 0;
  flex: 1;
}

.price-input-wrap input:focus {
  outline: none;
  box-shadow: none;
}

.price-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(196, 92, 62, 0.2);
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.btn-generate {
  margin-top: 1rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: background 0.2s, transform 0.1s;
}

.btn-generate:hover {
  background: #a84d32;
}

.btn-generate:active {
  transform: scale(0.98);
}

.input-errors {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fdf2f0;
  border: 1px solid var(--accent-light);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--ink);
}

.input-errors-title {
  margin: 0 0 0.35rem 0;
  font-weight: 500;
  color: var(--accent);
}

.input-errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.input-errors li {
  margin-bottom: 0.2rem;
}

.results-panel {
  padding: 1.5rem;
  overflow: auto;
}

.plan-view {
  width: 100%;
  max-width: none;
}

.plan-placeholder {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--line-light);
  font-size: 0.95rem;
}

.plan-output {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.plan-model-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.plan-model-row .plan-diagram {
  flex: 1;
  min-width: 0;
}

.plan-model-right {
  flex-shrink: 0;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}


.sheet-details-panel h3 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.1rem;
  margin: 0 0 1rem 0;
}

@media (max-width: 700px) {
  .plan-model-row {
    flex-direction: column;
  }
  .plan-model-right {
    width: 100%;
  }
}

.hidden {
  display: none !important;
}

.plan-output.hidden {
  display: none !important;
}

.plan-diagram {
  background: white;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.spec-problems {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fdf2f0;
  border: 1px solid var(--accent-light);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--ink);
}

.spec-problems-title {
  margin: 0 0 0.35rem 0;
  font-weight: 500;
  color: var(--accent);
}

.spec-problems ul {
  margin: 0;
  padding-left: 1.25rem;
}

.spec-problems li {
  margin-bottom: 0.2rem;
}

.diagram-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.diagram-toolbar-group {
  display: flex;
  gap: 2px;
}

.diagram-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.1rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.diagram-btn:hover {
  background: #e8e6e3;
  border-color: #999;
}

.diagram-btn:active {
  background: #ddd;
}

.diagram-toolbar-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.diagram-toolbar-checkbox input {
  cursor: pointer;
}

.diagram-canvas-wrapper {
  width: 100%;
  min-width: 320px;
  height: 680px;
  position: relative;
  background: #fafafa;
  border-radius: 4px;
}

.diagram-canvas-wrapper canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.diagram-canvas-wrapper canvas:active {
  cursor: grabbing;
}

.framing-diagram {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
}

.framing-svg {
  display: block;
  width: 100%;
  height: auto;
}

.framing-summary-content p {
  margin: 0.25rem 0;
  font-size: 0.95rem;
}

.diagram-dimensions {
  margin: 1rem 0 0 0;
  font-size: 0.85rem;
  color: var(--line);
  text-align: center;
}

.cut-list-panel {
  background: white;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.cut-list-panel h3 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.1rem;
  margin: 0 0 1rem 0;
  font-weight: 400;
}

.cut-list-paywall {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, rgba(196, 92, 62, 0.08) 0%, rgba(196, 92, 62, 0.04) 100%);
  border: 1px solid var(--accent-light);
  border-radius: 6px;
  text-align: center;
}

.cut-list-paywall p {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  color: var(--line);
}

.btn-unlock {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-unlock:hover {
  background: #a84d32;
}

.cut-list {
  font-size: 0.85rem;
}

.cut-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--line-light);
}

.cut-piece-draw {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cut-piece-svg {
  color: var(--line);
  flex-shrink: 0;
}

.cut-item:last-child {
  border-bottom: none;
}

.cut-item .qty {
  font-weight: 500;
  color: var(--accent);
}

.cut-item .dimensions {
  font-family: 'DM Mono', monospace;
}

.cut-item .description {
  color: var(--line);
}

.material-cost {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line-light);
}

.material-cost-block {
  font-size: 0.9rem;
  color: var(--line);
}

.material-cost-block .material-summary {
  margin: 0 0 0.25rem 0;
}

.material-cost-block .material-thickness-suggestion {
  margin: 0.25rem 0 0 0;
  font-size: 0.85rem;
  color: var(--line);
}

.material-cost-block .material-cost-est {
  margin: 0;
  color: var(--ink);
}

.material-cost-block .material-note {
  margin: 0.5rem 0 0 0;
  font-size: 0.8rem;
  color: var(--line);
  font-style: italic;
}

.material-cost-block .material-error {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--ink);
  background: rgba(196, 92, 62, 0.12);
  border-left: 4px solid var(--accent);
  border-radius: 0 4px 4px 0;
}

.cutting-diagram {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line-light);
}

.cutting-diagram h4 {
  font-family: 'Instrument Serif', serif;
  font-size: 1rem;
  margin: 0 0 1rem 0;
  font-weight: 400;
}

.cutting-sheets {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.cut-sheet-svg {
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cut-sheet-svg rect[stroke] {
  stroke: var(--accent);
}

.cut-diagram-label {
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  fill: var(--ink);
}

.joinery-specs {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--line-light);
}

.joinery-specs-block h4 {
  font-family: 'Instrument Serif', serif;
  font-size: 1rem;
  margin: 0 0 0.75rem 0;
  font-weight: 400;
}

.joinery-specs-block .joinery-desc {
  font-size: 0.85rem;
  color: var(--line);
  margin: 0 0 0.75rem 0;
}

.joinery-specs-block .joinery-list {
  font-size: 0.85rem;
  margin: 0 0 0.5rem 0;
  padding-left: 1.25rem;
}

.joinery-specs-block .joinery-list li {
  margin-bottom: 0.25rem;
}

.joinery-specs-block .joinery-note {
  font-size: 0.8rem;
  color: var(--line);
  font-style: italic;
  margin: 0.5rem 0 0 0;
}
