:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --text: #1F1F1F;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --accent: #2563EB;
  --accent-dark: #1D4ED8;
  --verdict-correct: #16A34A;
  --verdict-questionable: #D97706;
  --verdict-mistake: #DC2626;
  --suit-dark: #1F1F1F;
  --suit-red: #DC2626;
  --radius: 12px;
  --transition: 180ms ease;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--accent); }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}
.app-header h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.app-header h1 i { color: var(--accent); margin-right: 8px; }
.app-subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 15px;
}

.main-area {
  padding: 24px 24px 40px;
  max-width: 1440px;
  margin: 0 auto;
}

/* ---- form column (~45%) ---- */
.form-col { }
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
@media (min-width: 992px) {
  .sticky-form {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }
}

.form-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.form-section:first-child { padding-top: 0; }
.form-section:last-child { border-bottom: none; }

.section-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text);
}
.section-title i { color: var(--accent); margin-right: 6px; }

.field-group { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field-label .opt { font-weight: 400; }

.form-control, .form-select {
  border-color: var(--border);
  color: var(--text);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}
.form-control.field-invalid, .form-select.field-invalid {
  border-color: var(--verdict-mistake);
}

.error-msg {
  display: none;
  color: var(--verdict-mistake);
  font-size: 13px;
  font-weight: 500;
  margin-top: 6px;
}
.error-msg.show { display: block; }

/* ---- card slots ---- */
.card-slots { display: flex; gap: 10px; flex-wrap: wrap; }
.card-slot {
  width: 56px;
  height: 78px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  background: var(--bg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}
.card-slot:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-slot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-slot.filled {
  border-style: solid;
  border-color: var(--border);
  background: var(--surface);
}
.card-slot.slot-invalid { border-color: var(--verdict-mistake); }
.card-slot img { width: 40px; height: 56px; }
.card-slot .rank-suit { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 600; }
.card-slot .suit-dark { color: var(--suit-dark); }
.card-slot .suit-red { color: var(--suit-red); }

@media (max-width: 767.98px) {
  .card-slot { width: 64px; height: 88px; }
}

/* ---- card picker popover ---- */
.card-picker {
  position: absolute;
  z-index: 1050;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(31, 31, 31, 0.18);
  padding: 10px;
  width: 336px;
}
.card-picker-suit-row { display: flex; gap: 4px; margin-bottom: 4px; }
.card-picker-cell {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 0;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.card-picker-cell:hover, .card-picker-cell:focus-visible { background: #EAF1FE; border-color: var(--accent); }
.card-picker-cell.suit-dark { color: var(--suit-dark); }
.card-picker-cell.suit-red { color: var(--suit-red); }
.card-picker-cell.taken { opacity: 0.35; cursor: not-allowed; }

/* ---- action button groups ---- */
.action-group { display: flex; flex-wrap: wrap; gap: 8px; }
.action-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px !important;
  padding: 7px 14px;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.action-btn:hover { border-color: var(--accent); }
.action-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.size-input { max-width: 180px; }
.action-group.group-invalid {
  border: 1px solid var(--verdict-mistake);
  border-radius: 10px;
  padding: 6px;
}

.street-section.street-disabled { opacity: 0.45; }
.street-section.street-disabled .action-btn,
.street-section.street-disabled .card-slot,
.street-section.street-disabled input {
  pointer-events: none;
}

/* ---- submit button ---- */
.btn-analyze {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}
.btn-analyze:hover:not(:disabled) { background: var(--accent-dark); }
.btn-analyze:disabled { opacity: 0.75; }

/* ---- analysis column (~55%) ---- */
.analysis-panel {
  background: transparent;
}
.empty-welcome {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.empty-text { color: var(--text-secondary); margin: 8px 0 0; }
.demo-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.demo-label i { color: var(--accent); margin-right: 4px; }

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(31,31,31,0.04);
  transition: box-shadow var(--transition), transform var(--transition);
  opacity: 0;
  animation: step-fade-in 320ms ease forwards;
}
.step-card:hover { box-shadow: 0 8px 20px rgba(31,31,31,0.1); transform: translateY(-2px); }

@keyframes step-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-card.verdict-correct { border-left-color: var(--verdict-correct); }
.step-card.verdict-questionable { border-left-color: var(--verdict-questionable); }
.step-card.verdict-mistake { border-left-color: var(--verdict-mistake); }
.demo-card { animation: none; opacity: 1; }

.step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.street-tag {
  font-size: 16px;
  font-weight: 600;
}
.verdict-badge {
  font-size: 13px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
}
.verdict-badge.verdict-correct { background: var(--verdict-correct); }
.verdict-badge.verdict-questionable { background: var(--verdict-questionable); }
.verdict-badge.verdict-mistake { background: var(--verdict-mistake); }

.step-context, .step-action { color: var(--text-secondary); font-size: 14px; margin-bottom: 6px; }
.step-explanation { font-size: 15px; margin-bottom: 8px; }
.step-recommendation {
  font-size: 14px;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
}
.step-recommendation i { color: var(--accent); margin-right: 6px; }

.summary-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 8px;
}
.summary-block h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 12px 0 8px;
}
.summary-block h3:first-child { margin-top: 0; }
.summary-block h3 i { color: var(--accent); margin-right: 6px; }
.summary-block ul { margin: 0; padding-left: 20px; }
.summary-block li { margin-bottom: 6px; }

/* ---- toast ---- */
.app-toast {
  position: sticky;
  top: 8px;
  z-index: 20;
  background: #FEF2F2;
  border: 1px solid var(--verdict-mistake);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-toast i { color: var(--verdict-mistake); }
.btn-retry {
  margin-left: auto;
  background: var(--verdict-mistake);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 13px;
}
.btn-close-toast {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
}

.app-footer {
  border-top: 1px solid var(--border);
  padding: 14px 0;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

/* ---- responsive < 768px ---- */
@media (max-width: 767.98px) {
  .main-area { padding: 16px 16px 32px; }
  .sticky-form { position: static; max-height: none; }
}
