/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #f6f1eb;
  --color-surface: #fffdf9;
  --color-text: #2a2520;
  --color-text-muted: #8c7e72;
  --color-primary: #1e3a2f;
  --color-primary-light: #2d5a47;
  --color-primary-hover: #15291f;
  --color-accent: #c7522a;
  --color-accent-light: #e8734a;
  --color-danger: #b83232;
  --color-border: #ddd5cb;
  --color-border-light: #e9e3db;
  --color-notice-bg: #fef8ee;
  --color-notice-border: #e8d5b8;
  --color-sage: #e8ede6;
  --color-sage-dark: #cdd8c8;
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 740px;
  --font-display: "Lora", Georgia, "Times New Roman", serif;
  --font-body: "Outfit", -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow-sm: 0 1px 3px rgba(42, 37, 32, 0.06);
  --shadow-md: 0 4px 12px rgba(42, 37, 32, 0.08);
  --shadow-lg: 0 8px 30px rgba(42, 37, 32, 0.1);
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  padding: 0;
  min-height: 100vh;
  position: relative;
}

/* Subtle paper grain texture */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.3;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* === Layout === */
header, main, footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* === Header === */
header {
  text-align: center;
  padding-top: 3.5rem;
  padding-bottom: 2.5rem;
  position: relative;
}

.header-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary-light);
  background: var(--color-sage);
  padding: 0.3rem 0.85rem;
  border-radius: 20px;
  margin-bottom: 1rem;
  animation: fadeDown 0.6s ease-out both;
}

header h1 {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--color-primary);
  animation: fadeDown 0.6s ease-out 0.1s both;
}

header h1 .accent {
  color: var(--color-accent);
}

.intro-card {
  max-width: var(--max-width);
  margin: 1.25rem auto 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 1.35rem 1.6rem;
  text-align: left;
  box-shadow: var(--shadow-sm);
  animation: fadeDown 0.6s ease-out 0.2s both;
}

.intro-card p {
  font-family: var(--font-body);
  color: var(--color-text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 0;
}

.intro-card p + p {
  margin-top: 0.5rem;
}

/* === Footer === */
footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--color-border-light);
  color: var(--color-text-muted);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.65;
}

/* === Steps === */
.step {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.step-header {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.step-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.step-desc {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin-top: 0.2rem;
  line-height: 1.45;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.optional {
  color: var(--color-text-muted);
  font-weight: 400;
  font-family: var(--font-body);
  font-size: 0.82rem;
}

/* === Entrance animations === */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.anim-step {
  animation: fadeUp 0.5s ease-out both;
}

.anim-step:nth-child(2) { animation-delay: 0.05s; }
.anim-step:nth-child(3) { animation-delay: 0.1s; }
.anim-step:nth-child(4) { animation-delay: 0.15s; }
.anim-step:nth-child(5) { animation-delay: 0.2s; }
.anim-step:nth-child(6) { animation-delay: 0.25s; }
.anim-step:nth-child(7) { animation-delay: 0.3s; }
.anim-step:nth-child(8) { animation-delay: 0.35s; }

/* === Notice === */
.notice {
  display: flex;
  gap: 0.85rem;
  background: var(--color-notice-bg);
  border: 1px solid var(--color-notice-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.5s ease-out both;
}

.notice-icon {
  flex-shrink: 0;
  color: var(--color-accent);
  margin-top: 0.1rem;
}

.notice-content strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  color: var(--color-text);
}

.notice-content p {
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.notice a {
  color: var(--color-accent);
  font-weight: 500;
}

.notice a:hover {
  color: var(--color-accent-light);
}

/* === Provider picker === */
/* === Inputs === */
input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all 0.2s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 47, 0.08);
}

input::placeholder, textarea::placeholder {
  color: var(--color-border);
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.input-group input {
  flex: 1;
}

.input-group button {
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
}

.input-group button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* === File upload === */
.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  background: linear-gradient(180deg, rgba(232, 237, 230, 0.15) 0%, transparent 100%);
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--color-primary);
  background: linear-gradient(180deg, var(--color-sage) 0%, transparent 100%);
  box-shadow: var(--shadow-sm);
}

.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  transition: color 0.2s, transform 0.2s;
}

.upload-area:hover .upload-icon {
  color: var(--color-primary);
  transform: translateY(-2px);
}

.upload-area p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.file-label {
  color: var(--color-accent);
  cursor: pointer;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(199, 82, 42, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

.file-label:hover {
  text-decoration-color: var(--color-accent);
}

/* === Row limit notice === */
.row-limit-notice {
  margin-top: 1rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.84rem;
  color: var(--color-accent);
  background: rgba(199, 82, 42, 0.06);
  border: 1px solid rgba(199, 82, 42, 0.2);
  border-radius: var(--radius-sm);
  line-height: 1.45;
}

/* === Column picker === */
#column-picker {
  margin-top: 1.25rem;
}

#column-picker label {
  font-weight: 500;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 0.4rem;
}

#column-select {
  max-width: 300px;
}

.preview-label {
  font-weight: 500;
  margin-top: 0.85rem;
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
  color: var(--color-text) !important;
}

#data-preview {
  background: var(--color-bg);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  font-size: 0.84rem;
  max-height: 160px;
  overflow-y: auto;
}

#data-preview .preview-item {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-muted);
}

#data-preview .preview-item:last-child {
  border-bottom: none;
}

/* === Tips disclosure === */
.tips-disclosure {
  margin-top: 1.25rem;
  margin-bottom: 0;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
}

.tips-disclosure summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  list-style: none;
  transition: color 0.15s;
}

.tips-disclosure summary::-webkit-details-marker {
  display: none;
}

.tips-disclosure summary::after {
  content: "";
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--color-text-muted);
  transition: transform 0.2s;
}

.tips-disclosure[open] summary::after {
  transform: rotate(180deg);
}

.tips-disclosure summary:hover {
  color: var(--color-text);
}

.tips-disclosure[open] summary {
  border-bottom: 1px solid var(--color-border-light);
}

.tips-content {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tip {
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  padding-left: 0.75rem;
  border-left: 2px solid var(--color-sage-dark);
}

.tip strong {
  color: var(--color-text);
  font-weight: 600;
}

/* === Categories === */
.category-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.category-row .cat-name {
  flex: 1;
}

.category-row .cat-desc {
  flex: 2;
}

.remove-cat {
  padding: 0.4rem 0.65rem;
  border: 1.5px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-text-muted);
  transition: all 0.15s ease;
}

.remove-cat:hover {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: rgba(184, 50, 50, 0.04);
}

.option-group {
  margin-top: 0.85rem;
  font-size: 0.9rem;
}

.option-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
}

.option-group input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-primary);
}

/* === Buttons === */
.btn-primary, .btn-secondary, .btn-danger {
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(30, 58, 47, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 14px rgba(30, 58, 47, 0.25);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(30, 58, 47, 0.2);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: none;
  border: 1.5px solid var(--color-border);
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  padding: 0.55rem 1.1rem;
  font-weight: 500;
}

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

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  box-shadow: 0 2px 8px rgba(184, 50, 50, 0.2);
}

.btn-danger:hover {
  background: #9b2626;
}

/* === Classify controls === */
.model-picker {
  flex: 1;
  min-width: 200px;
}

.model-picker label {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--color-text-muted);
}

.model-picker select {
  width: 100%;
}

.classify-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

/* === Progress === */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--color-bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 1.25rem;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: 3px;
  transition: width 0.4s ease;
}

#progress-text {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  margin-top: 0.45rem;
}

.error-message {
  color: var(--color-accent);
}

.iterate-nudge {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border-light);
}

/* === Results === */
#results-summary {
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

#results-table-container {
  overflow-x: auto;
  margin-bottom: 1.25rem;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
}

#results-table-container table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

#results-table-container th,
#results-table-container td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--color-border-light);
}

#results-table-container th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: var(--color-bg);
  position: sticky;
  top: 0;
}

#results-table-container tr:last-child td {
  border-bottom: none;
}

#results-table-container td {
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
}

#results-table-container tr:hover td {
  background: rgba(232, 237, 230, 0.3);
}

/* === Prompt preview === */
.prompt-preview-step {
  padding: 0;
}

.prompt-preview-step summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 500;
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s;
  list-style: none;
}

.prompt-preview-step summary::-webkit-details-marker {
  display: none;
}

.prompt-preview-step summary::after {
  content: "";
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--color-text-muted);
  transition: transform 0.2s;
}

.prompt-preview-step[open] summary::after {
  transform: rotate(180deg);
}

.prompt-preview-step summary:hover {
  color: var(--color-text);
}

.prompt-preview-step[open] summary {
  border-bottom: 1px solid var(--color-border-light);
}

#prompt-preview-text {
  margin: 1rem 1.75rem 1.25rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  font-size: 0.78rem;
  font-family: "SF Mono", "Fira Code", "Fira Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 350px;
  overflow-y: auto;
  line-height: 1.6;
  color: var(--color-text-muted);
}

/* === Utilities === */
.hidden {
  display: none !important;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--color-accent-light);
  text-decoration: underline;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* === Responsive === */
@media (max-width: 600px) {
  header {
    padding-top: 2.5rem;
    padding-bottom: 2rem;
  }

  header h1 {
    font-size: 2.2rem;
  }

  .step {
    padding: 1.25rem;
  }

  .category-row {
    flex-direction: column;
  }

  .category-row .cat-name,
  .category-row .cat-desc {
    flex: auto;
  }

  .input-group {
    flex-direction: column;
  }

  .classify-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .classify-controls .btn-primary {
    justify-content: center;
  }
}
