@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Newsreader:wght@400;600&display=swap");

:root {
  --bg: #0f1117;
  --surface: #181a20;
  --surface-alt: #1f2229;
  --text: #e2e4e9;
  --muted: #7a7f8a;
  --border: #2a2d35;
  --accent: #34d399;
  --accent-dark: #2cc48a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-alt: #eef0f4;
  --text: #1a1c23;
  --muted: #6b7080;
  --border: #d8dbe3;
  --accent: #10b981;
  --accent-dark: #059669;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.site-header {
  padding: 0 8vw 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.logo {
  font-family: "Newsreader", "Times New Roman", serif;
  font-size: 28px;
  letter-spacing: 0.6px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  display: inline;
}

.logo-img {
  width: auto;
  height: 48px;
  object-fit: contain;
}

.site-header .logo-img {
  height: 75px;
}

.site-header .logo-text {
  display: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 auto;
}

.nav a {
  text-decoration: none;
  color: var(--text);
  padding: 6px 2px;
  position: relative;
  transition: color 0.2s ease;
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.25s ease;
}

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

.nav a:hover::after {
  width: 100%;
}

.mode-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  padding: 0;
}

.mode-btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.mode-btn:hover .toggle-icon {
  transform: rotate(20deg);
}

.tagline {
  max-width: 520px;
  font-size: 16px;
  color: var(--muted);
}

main {
  flex: 1;
  padding: 0 8vw 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Page content styles */
.page-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 0;
}

.page-content h1 {
  font-size: 32px;
  margin: 0 0 16px;
  color: var(--text);
}

.page-content h2 {
  font-size: 22px;
  margin: 28px 0 12px;
  color: var(--text);
}

.page-content h3 {
  font-size: 18px;
  margin: 0 0 8px;
  color: var(--text);
}

.page-content p {
  line-height: 1.7;
  color: var(--muted);
  margin: 0 0 12px;
}

.page-content ul {
  color: var(--muted);
  line-height: 1.7;
  padding-left: 20px;
  margin: 0 0 16px;
}

.page-content a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

.page-content a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* Steps (How It Works) */
.steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.step-card h3 {
  margin-bottom: 8px;
}

.step-card p,
.step-card ul {
  color: var(--muted);
  line-height: 1.7;
}

/* FAQ items */
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.faq-item h3 {
  color: var(--accent);
  margin-bottom: 6px;
}

.faq-item p {
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

/* Contact form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.contact-form textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 16px;
  font-family: inherit;
  background: var(--surface-alt);
  color: var(--text);
  resize: vertical;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

.contact-form .add-btn {
  align-self: flex-start;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  animation: fadeInUp 0.5s ease;
}

.summary-card h2 {
  margin: 0 0 6px;
}

.summary-card p {
  margin: 0;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 16px;
}

.summary-item {
  background: var(--surface-alt);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform 0.2s ease, border 0.2s ease;
}

.summary-item:hover {
  transform: translateY(-2px);
  border-color: var(--border);
}

.summary-item span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.summary-item strong {
  font-size: 20px;
}

.subject-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.subject-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeInUp 0.45s ease;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  cursor: grab;
}

.subject-card:active {
  cursor: grabbing;
}

.subject-card input,
.subject-card button,
.subject-card textarea {
  cursor: initial;
}

.subject-card input[type="text"],
.subject-card input[type="number"] {
  cursor: text;
}

.subject-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.09);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.collapse-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
  transition: max-width 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.subject-card.collapsed .collapse-preview {
  max-width: 250px;
  opacity: 1;
}

.drag-handle {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 18px;
  cursor: grab;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
}

.drag-handle:hover {
  color: var(--accent);
  background: var(--surface-alt);
}

.drag-handle:active {
  cursor: grabbing;
}

/* Drag handle doubles as collapse toggle (tap = collapse, hold = drag) */
.drag-handle.active-collapse {
  color: var(--accent);
}

/* Card body collapse animation */
.card-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  opacity: 1;
}

.subject-card.collapsed .card-body {
  max-height: 0;
  opacity: 0;
  gap: 0;
}

.subject-card.collapsed {
  gap: 0;
}

/* Drag and drop states */
.subject-card.dragging {
  opacity: 0.5;
  transform: scale(0.98);
}

.subject-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35);
}

/* Action buttons row */
.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pdf-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: none;
}

.pdf-btn:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 14px 30px rgba(52, 211, 153, 0.2);
}

.subject-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  flex: 1;
}

.subject-title span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.subject-title input {
  font-size: 20px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--surface-alt);
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  min-width: 0;
}

.field input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 16px;
  background: var(--surface-alt);
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.field input:focus,
.subject-title input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

.output {
  background: var(--surface-alt);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.output-item span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 4px;
}

.output-item strong {
  font-size: 18px;
}

.note {
  font-size: 13px;
  color: var(--muted);
}

.close-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
}

.close-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.remove-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.add-btn {
  border: none;
  background: var(--accent);
  color: var(--bg);
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 14px 30px rgba(52, 211, 153, 0.2);
}

.add-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(52, 211, 153, 0.3);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 8vw 24px;
  font-size: 13px;
  color: var(--muted);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.footer-brand .logo-img {
  height: 65px;
  margin-bottom: 10px;
}

.footer-brand p {
  margin: 0;
  line-height: 1.6;
  color: var(--muted);
  max-width: 280px;
  text-align: center;
}

.footer-col h4 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-col a {
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s ease;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-bottom-links {
  display: flex;
  gap: 20px;
}

.footer-bottom-links a {
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s ease;
}

.footer-bottom-links a:hover {
  color: var(--accent);
}

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

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .output {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

@media (max-width: 680px) {
  .site-header,
  main,
  .site-footer {
    padding-left: 6vw;
    padding-right: 6vw;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-brand .logo-img {
    height: 55px;
  }

  .logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
    font-size: 14px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
  }

  .remove-btn {
    display: none;
  }

  .close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .subject-card {
    position: relative;
    padding: 14px 14px;
    gap: 12px;
    border-radius: 14px;
  }

  .subject-card.collapsed {
    gap: 0;
  }

  .card-header {
    padding-right: 32px;
  }

  .card-body {
    gap: 12px;
  }

  .subject-title {
    min-width: 0;
    gap: 4px;
  }

  .drag-handle {
    font-size: 16px;
    padding: 2px 4px;
  }

  .collapse-preview {
    display: none;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons .add-btn,
  .action-buttons .pdf-btn {
    width: 100%;
    text-align: center;
  }

  .subject-title input {
    font-size: 16px;
    padding: 6px 10px;
  }

  .input-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .field {
    gap: 4px;
    font-size: 11px;
    min-width: 0;
  }

  .field input {
    padding: 6px 8px;
    font-size: 13px;
  }

  .output {
    padding: 10px;
    gap: 8px;
    border-radius: 12px;
  }

  .output-item span {
    font-size: 10px;
    margin-bottom: 2px;
  }

  .output-item strong {
    font-size: 15px;
  }

  .note {
    font-size: 11px;
  }

  .summary-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-grid {
    width: 100%;
    grid-template-columns: repeat(2, minmax(100px, 1fr));
  }

  .output {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .add-btn {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .nav {
    gap: 10px;
    font-size: 12px;
  }

  .site-header .logo-img {
    height: 52px;
  }

  .footer-brand .logo-img {
    height: 48px;
  }

  .mode-btn {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
}

@media (max-width: 400px) {
  .brand-row {
    gap: 6px;
  }

  .nav {
    gap: 6px;
    font-size: 11px;
  }

  .site-header .logo-img {
    height: 45px;
  }

  .footer-brand .logo-img {
    height: 37px;
  }

  .mode-btn {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
}

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