:root {
  --wfc-primary: #2563eb;
  --wfc-primary-dark: #1d4ed8;
  --wfc-primary-light: #3b82f6;
  --wfc-success: #10b981;
  --wfc-warning: #f59e0b;
  --wfc-danger: #ef4444;
  --wfc-neutral: #374151;
  --wfc-border: #e5e7eb;
  --wfc-bg-light: #f9fafb;
}

.theme-dark {
  --wfc-primary: #3b82f6;
  --wfc-primary-dark: #2563eb;
  --wfc-success: #34d399;
  --wfc-warning: #fbbf24;
  --wfc-border: rgba(255, 255, 255, 0.1);
  --wfc-bg-light: #1f2937;
}

.wfc-root {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.wfc-card {
  border: 1px solid var(--wfc-border);
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
}

.theme-dark .wfc-card {
  background: rgba(255, 255, 255, 0.02);
}

.wfc-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  min-height: 700px;
}

@media (max-width: 768px) {
  .wfc-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

.wfc-sidebar {
  padding: 2.5rem;
  background: rgba(255, 255, 255, 0.7);
  border-right: 1px solid var(--wfc-border);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .wfc-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--wfc-border);
  }
}

.theme-dark .wfc-sidebar {
  background: rgba(255, 255, 255, 0.03);
}

.wfc-main {
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  background: rgba(255, 255, 255, 0.3);
  overflow-y: auto;
}

.theme-dark .wfc-main {
  background: rgba(255, 255, 255, 0.01);
}

.wfc-field {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wfc-field-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b7280;
}

.theme-dark .wfc-field-label {
  color: #9ca3af;
}

.wfc-fraction-input {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  align-items: flex-end;
}

.wfc-fraction-column {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.wfc-fraction-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wfc-input-number {
  padding: 0.75rem;
  border: 2px solid var(--wfc-border);
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  background: white;
  cursor: text;
  transition: border-color 0.2s;
}

.theme-dark .wfc-input-number {
  background: rgba(255, 255, 255, 0.05);
  color: #f3f4f6;
}

.wfc-input-number:focus {
  outline: none;
  border-color: var(--wfc-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.wfc-fraction-slash {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--wfc-primary);
  text-align: center;
  line-height: 1;
}

/* Number Stepper Buttons */
.wfc-stepper-group {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.wfc-stepper-btn {
  flex: 1;
  padding: 0.4rem;
  border: 1px solid var(--wfc-border);
  border-radius: 4px;
  background: white;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.theme-dark .wfc-stepper-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #f3f4f6;
}

.wfc-stepper-btn:hover {
  border-color: var(--wfc-primary);
  background: rgba(37, 99, 235, 0.1);
}

.wfc-stepper-btn:active {
  background: var(--wfc-primary);
  color: white;
  border-color: var(--wfc-primary);
}

/* Quick Preset Buttons */
.wfc-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 0.5rem;
}

.wfc-preset-btn {
  padding: 0.5rem;
  border: 2px solid var(--wfc-border);
  border-radius: 8px;
  background: white;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.theme-dark .wfc-preset-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #f3f4f6;
}

.wfc-preset-btn:hover {
  border-color: var(--wfc-primary);
  background: rgba(37, 99, 235, 0.1);
}

.wfc-preset-btn.active {
  background: var(--wfc-primary);
  color: white;
  border-color: var(--wfc-primary);
}

/* Mode Toggle */
.wfc-mode-toggle {
  display: flex;
  gap: 0;
  border: 2px solid var(--wfc-border);
  border-radius: 8px;
  background: white;
}

.theme-dark .wfc-mode-toggle {
  background: rgba(255, 255, 255, 0.05);
}

.wfc-mode-btn {
  flex: 1;
  padding: 0.8rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  color: var(--wfc-neutral);
}

.theme-dark .wfc-mode-btn {
  color: #d1d5db;
}

.wfc-mode-btn:first-child {
  border-right: 2px solid var(--wfc-border);
}

.wfc-mode-btn.active {
  background: var(--wfc-primary);
  color: white;
}

/* Result Section */
.wfc-result-box {
  padding: 1.5rem;
  background: rgba(37, 99, 235, 0.05);
  border: 2px solid var(--wfc-primary);
  border-radius: 12px;
}

.theme-dark .wfc-result-box {
  background: rgba(37, 99, 235, 0.1);
}

.wfc-result-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--wfc-primary);
  margin-bottom: 1rem;
}

.wfc-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(37, 99, 235, 0.2);
}

.wfc-result-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.wfc-result-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
}

.theme-dark .wfc-result-label {
  color: #d1d5db;
}

.wfc-result-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--wfc-primary);
}

.wfc-visual-scale {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--wfc-bg-light);
  border-radius: 12px;
  border: 1px dashed var(--wfc-border);
}

.theme-dark .wfc-visual-scale {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.2);
}

.wfc-scale-ruler {
  position: relative;
  height: 40px;
  background: white;
  border: 1px solid var(--wfc-border);
  border-radius: 4px;
  margin-bottom: 1rem;
}

.theme-dark .wfc-scale-ruler {
  background: rgba(255, 255, 255, 0.05);
}

.wfc-scale-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 50%;
  background: var(--wfc-neutral);
}

.wfc-scale-indicator {
  position: absolute;
  top: 50%;
  height: 20px;
  background: var(--wfc-primary);
  border-radius: 2px;
  opacity: 0.8;
}

/* Fastener Match Cards */
.wfc-match-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.wfc-match-card {
  padding: 1rem;
  border: 2px solid var(--wfc-border);
  border-radius: 12px;
  background: white;
}

.theme-dark .wfc-match-card {
  background: rgba(255, 255, 255, 0.05);
}

.wfc-match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.wfc-match-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--wfc-neutral);
}

.theme-dark .wfc-match-name {
  color: #f3f4f6;
}

.wfc-match-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  background: var(--wfc-primary);
  color: white;
}

.wfc-match-badge.tight {
  background: var(--wfc-success);
}

.wfc-match-badge.loose {
  background: var(--wfc-warning);
  color: #000;
}

.theme-dark .wfc-match-badge.loose {
  color: #1f2937;
}

.wfc-match-details {
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.5;
}

.theme-dark .wfc-match-details {
  color: #d1d5db;
}

/* Buttons */
.wfc-button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.wfc-button {
  padding: 0.9rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.wfc-button-primary {
  background: var(--wfc-primary);
  color: white;
}

.wfc-button-primary:hover {
  background: var(--wfc-primary-dark);
}

.wfc-button-secondary {
  background: white;
  color: var(--wfc-primary);
  border: 2px solid var(--wfc-primary);
}

.theme-dark .wfc-button-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: #3b82f6;
}

.wfc-button-secondary:hover {
  background: rgba(37, 99, 235, 0.1);
}

/* History */
.wfc-history {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--wfc-border);
}

.wfc-history-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b7280;
  margin-bottom: 1rem;
}

.wfc-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.wfc-history-item {
  padding: 0.75rem;
  background: var(--wfc-bg-light);
  border-radius: 8px;
  border: 1px solid var(--wfc-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.theme-dark .wfc-history-item {
  background: rgba(255, 255, 255, 0.05);
}

.wfc-history-item-fraction {
  font-weight: 600;
  color: var(--wfc-primary);
}

.wfc-history-remove {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 600;
}

.wfc-history-remove:hover {
  color: var(--wfc-danger);
}

/* Accessibility & Touch */
@media (hover: none) and (pointer: coarse) {
  .wfc-button,
  .wfc-preset-btn,
  .wfc-stepper-btn,
  .wfc-input-number {
    min-height: 48px;
    font-size: 1rem;
  }

  .wfc-grid {
    min-height: auto;
  }

  .wfc-sidebar,
  .wfc-main {
    padding: 1.5rem;
  }
}

/* Utilities */
.wfc-hidden {
  display: none;
}

.wfc-text-center {
  text-align: center;
}

.wfc-text-mono {
  font-size: 0.9rem;
}
