:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e2e8f0;
  --border-focus: #4f46e5;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --manual-bg: #fffbeb;
  --manual-border: #f59e0b;
  --success: #059669;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 48px;
}

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.brand p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Main Layout */
.container {
  max-width: 1280px;
  margin: 24px auto 0;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1.14fr 0.86fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .container {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.highlight-card {
  border-top: 4px solid var(--primary);
}

.card + .card {
  margin-top: 18px;
}

.section-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text);
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  margin-right: 8px;
}

.stage-tag {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
}

.sub-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

/* Kotak Input Manual (Muncul saat opsi Manual dipilih) */
.manual-box {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--manual-bg);
  border: 1.5px dashed var(--manual-border);
  animation: fadeIn 0.2s ease;
}

.manual-box.show {
  display: block;
}

.manual-box label {
  color: #92400e;
  font-size: 0.82rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Generator Type Selector (4 Cards: 3 Preset + 1 Manual) */
.gen-type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .gen-type-grid {
    grid-template-columns: 1fr;
  }
}

.gen-type-card {
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.gen-type-card:hover {
  border-color: #a5b4fc;
  background: #fff;
}

.gen-type-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.14);
}

.gen-type-card.is-manual {
  border-style: dashed;
}

.gen-type-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  margin-bottom: 6px;
}

.gen-type-card.active .gen-type-badge {
  background: var(--primary);
  color: #fff;
}

.gen-type-card strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 2px;
}

.gen-type-card span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Jenjang Selector (5 Kolom: SD, SMP, SMA, SMK, Lainnya) */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

@media (max-width: 680px) {
  .stage-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 440px) {
  .stage-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stage-btn {
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.stage-btn:hover {
  border-color: #a5b4fc;
  background: #fff;
}

.stage-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

.stage-btn.is-manual {
  border-style: dashed;
}

.stage-btn strong {
  display: block;
  font-size: 0.92rem;
  color: var(--text);
}

.stage-btn span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stage-btn.active strong {
  color: var(--primary);
}

/* Kelas / Fase Pills */
.grade-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.grade-pill {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 13px;
  border-radius: 99px;
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.grade-pill:hover {
  border-color: #a5b4fc;
  background: var(--surface-soft);
}

.grade-pill.is-manual {
  border-style: dashed;
  color: #92400e;
  border-color: #fbbf24;
  background: #fffbeb;
}

.grade-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  border-style: solid;
}

.info-box {
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  color: #312e81;
}

/* Subject Grid */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

@media (max-width: 720px) {
  .subject-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 440px) {
  .subject-grid {
    grid-template-columns: 1fr;
  }
}

.subject-card {
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 10px 11px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: all 0.15s ease;
}

.subject-card:hover {
  border-color: #a5b4fc;
  background: #fff;
}

.subject-card.is-manual {
  border-style: dashed;
  background: #fffbeb;
}

.subject-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  border-style: solid;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

.subject-code {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.7rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.subject-card.is-manual .subject-code {
  background: #fde68a;
  color: #92400e;
}

.subject-card.active .subject-code {
  background: var(--primary);
  color: #fff;
}

.subject-info strong {
  display: block;
  font-size: 0.83rem;
  color: var(--text);
  line-height: 1.25;
}

.subject-info span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
  line-height: 1.2;
}

/* Form Controls */
.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 4px;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

textarea {
  resize: vertical;
  min-height: 74px;
}

/* Option Cards */
.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 600px) {
  .option-grid {
    grid-template-columns: 1fr;
  }
}

.option-card {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--surface-soft);
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.option-card:hover {
  border-color: #a5b4fc;
  background: #fff;
}

.option-card.is-manual {
  border-style: dashed;
  background: #fffbeb;
}

.option-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  border-style: solid;
}

.option-card input {
  margin-top: 3px;
  accent-color: var(--primary);
  cursor: pointer;
}

.option-card strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 2px;
}

.option-card span {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Toggles */
.toggle-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 600px) {
  .toggle-list {
    grid-template-columns: 1fr;
  }
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  font-weight: 500;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.toggle-item input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--surface-soft);
  border-color: #cbd5e1;
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-soft:hover {
  background: #e0e7ff;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
}

/* Right Panel */
.preview-col {
  position: sticky;
  top: 84px;
}

.char-count {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}

.active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #c7d2fe;
}

.chip-dark {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}

/* Precision Meter */
.meter-wrap {
  margin-bottom: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.meter-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.25s ease, background-color 0.25s ease;
}

.meter-tip {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* Mode Switcher */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--surface-soft);
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.iter-tabs {
  display: none;
  gap: 6px;
  margin-bottom: 10px;
}

.iter-tabs.show {
  display: flex;
}

.iter-tab {
  flex: 1;
  padding: 7px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-muted);
  cursor: pointer;
}

.iter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Output Box */
.prompt-output {
  width: 100%;
  min-height: 320px;
  max-height: 430px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.81rem;
  line-height: 1.55;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 14px;
  resize: vertical;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.action-row .btn-primary {
  flex: 1;
}

.guide-steps {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  display: grid;
  gap: 6px;
}

/* History List */
.history-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
}

.history-meta strong {
  display: block;
  color: var(--text);
}

.history-meta span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.history-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 100;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}
