/* Surface Planner — Styles */
@import '../../../shared/styles/tokens.css';
@import '../../../shared/styles/topbar.css';
@import '../../../shared/styles/footer.css';

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* Layout */
.app {
  max-width: 80rem;
  margin: 0 auto;
  padding: var(--space-md);
  padding-left: max(var(--space-md), env(safe-area-inset-left));
  padding-right: max(var(--space-md), env(safe-area-inset-right));
  padding-bottom: max(var(--space-2xl), env(safe-area-inset-bottom));
}

/* Header */
.header {
  text-align: center;
  margin-bottom: var(--space-md);
}

.header__title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.header__subtitle {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  font-weight: 400;
}

@media (min-width: 480px) {
  .header__title { font-size: var(--font-size-3xl); }
  .header__subtitle { font-size: var(--font-size-lg); }
}

/* Step tabs */
.step-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
  border: 1px solid var(--color-border);
}

.step-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

.step-tab.active {
  background: var(--color-surface);
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 700;
}

.step-tab.active .step-number {
  background: var(--color-primary);
  color: white;
}

/* Main two-panel layout */
.main-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

@media (min-width: 768px) {
  .main-layout {
    flex-direction: row;
  }

  .canvas-panel {
    flex: 3;
    min-width: 0;
  }

  .controls-panel {
    flex: 2;
    min-width: 280px;
    max-width: 400px;
  }
}

/* Canvas area */
.canvas-wrapper {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.shape-toolbar {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  align-items: center;
}

#canvas-toolbar [hidden] {
  display: none !important;
}

.canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: rgba(255, 255, 255, 0.7);
  z-index: 20;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}
.canvas-loading[hidden] { display: none !important; }
.canvas-loading-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
  min-height: 2.25rem;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tool-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.tool-btn:hover:not(:disabled) {
  background: var(--color-surface);
  color: var(--color-text);
}

.tool-btn.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary);
  font-weight: 600;
}

.tool-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-btn kbd {
  font-family: var(--font-family);
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 2px;
  background: var(--color-border);
  color: var(--color-text-secondary);
  pointer-events: none;
}
.tool-btn.active kbd {
  background: var(--color-primary);
  color: #fff;
}

.tool-btn__label {
  font-size: var(--font-size-sm);
}

.tool-separator {
  width: 1px;
  background: var(--color-border);
  margin: var(--space-xs) 0;
  align-self: stretch;
}

/* Grid snap size dropdown */
.snap-size-select {
  width: auto;
  min-width: 4.5rem;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  min-height: 2.25rem;
  cursor: pointer;
}

#planner-canvas {
  width: 100%;
  height: 50vh;
  min-height: 300px;
  display: block;
  touch-action: none;
}

@media (min-width: 768px) {
  #planner-canvas {
    height: 65vh;
  }
}

/* Controls sidebar / below */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

/* List cards (scrollable) */
.material-list-card,
.shape-list-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.shape-accordion {
  flex: 1;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  min-height: 0;
  max-height: calc(50vh - 5rem);
}
/* Force scrollbar always visible on all platforms */
.shape-accordion::-webkit-scrollbar {
  width: 6px;
}
.shape-accordion::-webkit-scrollbar-track {
  background: var(--color-bg);
  border-radius: 3px;
}
.shape-accordion::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}
.shape-accordion::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}
/* Step 2 material list — match canvas height */
.material-list-card .shape-accordion {
  max-height: 50vh;
}
@media (min-width: 768px) {
  .shape-accordion {
    max-height: calc(65vh - 5rem);
  }
  .material-list-card .shape-accordion {
    max-height: 65vh;
  }
}

/* Group sections */
.group-section {
  border-bottom: 2px solid var(--color-border);
}
.group-section:last-of-type {
  border-bottom: none;
}
.group-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 600;
  user-select: none;
}
.group-header:hover {
  background: var(--color-border);
}
.active-group > .group-header {
  border-left: 3px solid var(--color-primary);
}
.group-chevron {
  font-size: 0.7rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}
.group-name-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  padding: 0 4px;
  line-height: 1.3;
  border-radius: 2px;
  min-width: 0;
  min-height: 0 !important;
  width: auto;
  box-shadow: none !important;
}
.group-name-input:focus {
  background: var(--color-surface);
  outline: 1px solid var(--color-primary);
  box-shadow: none !important;
}
.group-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-text-muted);
  padding: 0 var(--space-xs);
  line-height: 1;
  border-radius: var(--radius-sm);
}
.group-delete-btn:hover {
  color: var(--color-danger);
  background: rgba(220, 38, 38, 0.08);
}
.group-body {
  padding-left: var(--space-sm);
}
.group-body.collapsed {
  display: none;
}
.group-body.drag-over {
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
}
.group-empty-hint {
  padding: var(--space-xs) var(--space-sm);
}
.add-group-btn {
  width: 100%;
  margin-top: var(--space-xs);
}

/* Shape accordion */
.shape-accordion-item {
  border-bottom: 1px solid var(--color-border);
}
.shape-accordion-item:last-child {
  border-bottom: none;
}

.shape-accordion-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: var(--font-size-sm);
}
.shape-accordion-header:hover {
  background: var(--color-bg);
}
.shape-accordion-item.open > .shape-accordion-header {
  background: var(--color-primary-light);
}

.shape-list-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.shape-list-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.shape-list-icon.include { color: var(--color-primary); }
.shape-list-icon.exclude { color: var(--color-danger); }

.shape-accordion-label {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shape-accordion-area {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.shape-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  padding: 0 var(--space-xs);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.shape-delete-btn:hover {
  color: var(--color-danger);
  background: rgba(220, 38, 38, 0.08);
}

/* Material header two-line layout */
.mat-header-content {
  flex: 1;
  min-width: 0;
}
.mat-header-top {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.mat-header-top .shape-accordion-label {
  flex: 1;
}
.mat-header-shapes {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
}
.mat-shape-chip {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  white-space: nowrap;
}
.mat-no-shapes {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.shape-accordion-body {
  padding: var(--space-sm) var(--space-md) var(--space-md);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* Exclude toggle */
.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  cursor: pointer;
  padding: var(--space-xs) 0;
  margin-bottom: var(--space-sm);
}
.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-danger);
}

/* Legacy (unused) */
.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Shape properties */
.form-group {
  margin-bottom: var(--space-sm);
}

.form-row {
  display: flex;
  gap: var(--space-sm);
}

.form-row .form-group {
  flex: 1;
}

label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: max(var(--font-size-base), 16px);
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-surface);
  min-height: var(--touch-target);
  transition: border-color var(--transition-fast);
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  padding-right: var(--space-xl);
}

@media (pointer: coarse) {
  select {
    appearance: auto;
    background-image: none;
    padding-right: var(--space-md);
  }
}

/* Material type toggle */
.material-type-toggle {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
}

.material-type-btn {
  flex: 1;
  padding: var(--space-sm) var(--space-xs);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: var(--touch-target);
  text-align: center;
}

.material-type-btn.active {
  background: var(--color-surface);
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Primary action button */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary);
  color: white;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  min-height: var(--touch-target);
  transition: all var(--transition-fast);
  margin-top: var(--space-md);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs, 0.75rem);
  min-height: auto;
}

/* Delete button */
.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  min-height: var(--touch-target);
  transition: all var(--transition-fast);
}

.btn-danger:hover {
  background: var(--color-danger);
  color: white;
}

/* Area summary */
.area-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.area-summary-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.area-summary-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-primary);
}

/* Result summary bar */
.result-summary-bar {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.result-summary-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
}
.result-summary-label {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-text-secondary);
}
.result-summary-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-primary);
}

/* Result view toggle */
.result-view-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.result-view-btn {
  padding: 0.25rem 0.5rem;
  font-size: var(--font-size-xs, 0.75rem);
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-family);
  transition: background 0.15s, color 0.15s;
}
.result-view-btn + .result-view-btn {
  border-left: 1px solid var(--color-border);
}
.result-view-btn.active {
  background: var(--color-primary);
  color: #fff;
}
.results-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.results-card .shape-accordion {
  max-height: calc(50vh - 5rem);
}
@media (min-width: 768px) {
  .results-card .shape-accordion {
    max-height: calc(65vh - 5rem);
  }
}

/* Result group sections */
.result-group-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  overflow: hidden;
}
.result-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  font-weight: 600;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
}
.result-group-header:hover {
  background: var(--color-border);
}
.result-group-chevron {
  font-size: 0.7rem;
  flex-shrink: 0;
}
.result-group-name {
  flex: 1;
}
.result-group-cost {
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 700;
  color: #166534;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.result-group-cost:empty {
  display: none;
}

/* Result items spacing */
.result-config-group {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}
.result-config-group:last-child {
  border-bottom: none;
}
.result-config-header {
  margin-bottom: var(--space-sm);
}
.results-grid {
  margin-bottom: var(--space-sm);
}
.result-spacers,
.result-package-info,
.result-price {
  margin-top: var(--space-xs);
}

/* Step 2: Material config cards */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.card-header .card-title {
  margin-bottom: 0;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.material-config-card {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  margin-bottom: var(--space-sm);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.material-config-card:last-child {
  margin-bottom: 0;
}

.material-config-card--active {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.material-config-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.material-config-badge {
  font-size: var(--font-size-xs, 0.7rem);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.material-config-badge--tile   { background: #e2e8f0; color: #334155; }
.material-config-badge--paint  { background: #ccfbf1; color: #0d9488; }
.material-config-badge--wallpaper { background: #fef3c7; color: #92400e; }

.material-config-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.material-config-spec {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-text-muted);
  line-height: 1.3;
}

.material-config-no-shapes-hint {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: var(--space-xs);
}

.material-config-actions {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  flex-shrink: 0;
}

.edit-config-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.edit-config-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.edit-config-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.result-config-group {
  margin-bottom: var(--space-lg, 1.5rem);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.result-config-group:last-child {
  border-bottom: none;
}

.result-config-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.result-config-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.result-total {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

.price-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.price-input-row input {
  flex: 1;
  min-width: 0;
}

.price-mode-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.price-mode-btn,
.mat-price-mode-btn {
  padding: 0.35rem 0.6rem;
  font-size: var(--font-size-xs, 0.75rem);
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-family);
}

.price-mode-btn + .price-mode-btn,
.mat-price-mode-btn + .mat-price-mode-btn {
  border-left: 1px solid var(--color-border);
}

.price-mode-btn.active,
.mat-price-mode-btn.active {
  background: var(--color-primary, #0d9488);
  color: #fff;
}

.result-spacers {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

.result-spacers strong {
  color: var(--color-text);
}

.result-package-info {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-warning, #d97706);
}

.result-price {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-primary, #0d9488);
}

.result-price strong {
  color: var(--color-text);
}

.result-grand-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary, #0d9488);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 700;
}

.result-grand-total__label {
  font-size: var(--font-size-base);
}

.result-grand-total__value {
  font-size: var(--font-size-lg, 1.125rem);
}

.material-config-shapes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--color-border);
}

.shape-chip {
  display: inline-flex;
  align-items: center;
  font-size: var(--font-size-xs, 0.7rem);
  padding: 2px 8px;
  background: rgba(13, 148, 136, 0.1);
  color: var(--color-primary);
  border-radius: 99px;
  font-weight: 500;
}

.assign-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  margin-top: var(--space-sm);
}

.assign-btn:hover,
.assign-btn.active {
  background: var(--color-primary);
  color: white;
}

.delete-config-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.delete-config-btn:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
  background: var(--color-danger-light);
}

.delete-config-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.assign-active-hint {
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  background: rgba(13, 148, 136, 0.08);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  margin-top: var(--space-xs);
  font-weight: 500;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  min-height: var(--touch-target);
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--color-bg);
  border-color: var(--color-text-secondary);
}

.form-row-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.form-row-actions .btn-primary,
.form-row-actions .btn-secondary {
  flex: 1;
  margin-top: 0;
}

/* Step 2: Shape list with checkboxes (kept for compatibility) */
.step2-shape-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: var(--font-size-sm);
}

.step2-shape-item:hover {
  background: var(--color-bg);
}

.step2-shape-checkbox {
  width: auto;
  min-height: auto;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}

.step2-shape-label {
  flex: 1;
  font-weight: 500;
}

/* Material badge */
.material-badge {
  font-size: var(--font-size-xs, 0.7rem);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  font-weight: 500;
}

.material-badge--tile {
  background: #e2e8f0;
  color: #334155;
}

.material-badge--paint {
  background: #ccfbf1;
  color: #0d9488;
}

.material-badge--wallpaper {
  background: #fef3c7;
  color: #92400e;
}

.material-badge--none {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

/* Results */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.result-item {
  text-align: center;
  padding: var(--space-sm);
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.result-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.result-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
}

.result-value.highlight {
  color: var(--color-primary);
}

.result-value.warning {
  color: var(--color-warning);
}

/* Results section title */
.results-section-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
  margin-top: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.results-section-title:first-child {
  margin-top: 0;
}

/* Per-shape result group */
.result-shape-group {
  margin-bottom: var(--space-md);
}

.result-shape-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  padding-left: var(--space-xs);
}

/* Grid drag hint */
.grid-drag-hint {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-warning-light);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  text-align: center;
  margin-bottom: var(--space-sm);
}

/* Hint text */
.hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding: var(--space-md);
  text-align: center;
}

/* Print-only sections (hidden on screen) */
.print-only {
  display: none !important;
}

/* Print styles */
@media print {
  @page { size: A4; margin: 1.2cm; }

  body { background: white; font-size: 8pt; line-height: 1.4; }
  .app { max-width: none; padding: 0; }

  /* Hide screen-only elements */
  .main-layout,
  .step-tabs,
  .footer,
  .topbar,
  .header,
  #print-btn,
  .result-view-toggle,
  .canvas-loading { display: none !important; }

  /* Collapse any spacing from hidden elements */
  .app { margin: 0; padding: 0; gap: 0; overflow: visible; }

  /* Show print sections */
  .print-only { display: block !important; margin: 0; padding: 0; }

  .print-page {
    page-break-before: always;
    break-before: page;
  }
  .print-page:first-child {
    page-break-before: auto;
    break-before: auto;
  }

  /* Print logo on each page */
  .print-logo {
    height: 1.2rem;
    width: auto;
    margin-bottom: 0.3cm;
    display: block;
  }

  /* Canvas page — full first page */
  .print-canvas-page {
    display: flex;
    flex-direction: column;
  }
  .print-canvas-page .print-logo {
    flex-shrink: 0;
  }
  #print-canvas {
    flex: 1;
    width: 100%;
    max-height: calc(100vh - 2cm);
    object-fit: contain;
    border: 1px solid #ddd;
  }

  /* Section titles */
  .print-section-title {
    font-size: 14pt;
    font-weight: 700;
    margin-bottom: 0.5cm;
    padding-bottom: 0.2cm;
    border-bottom: 2px solid #334155;
  }

  /* Simplified result tables for print */
  .print-result-group {
    margin-bottom: 0.4cm;
    break-inside: avoid;
  }
  .print-group-header {
    font-weight: 700;
    font-size: 10pt;
    padding: 0.1cm 0;
    border-bottom: 1px solid #ccc;
    margin-bottom: 0.2cm;
    display: flex;
    justify-content: space-between;
  }
  .print-group-cost {
    color: #166534;
    font-weight: 700;
  }
  .print-config {
    margin-bottom: 0.3cm;
    padding-left: 0.2cm;
  }
  .print-config-header {
    font-weight: 600;
    font-size: 9pt;
    margin-bottom: 0.1cm;
  }
  .print-config-badge {
    font-size: 7pt;
    padding: 1px 4px;
    border: 1px solid #ccc;
    border-radius: 2px;
    margin-right: 0.2cm;
  }
  .print-config-details {
    font-size: 8pt;
    color: #334155;
  }
  .print-config-details span {
    margin-right: 0.4cm;
  }
  .print-price {
    font-weight: 700;
  }
  .print-summary {
    margin-top: 0.3cm;
    padding-top: 0.2cm;
    border-top: 2px solid #334155;
    font-size: 10pt;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
  }
}
