:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --major-bg: #eef2ff;
  --major-text: #3730a3;
  --general-bg: #fef3c7;
  --general-text: #92400e;
  --radius: 16px;
}

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

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

.page {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-bar {
  display: inline-flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  align-self: center;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-btn.active {
  background: var(--accent);
  color: #ffffff;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-panel[hidden] {
  display: none;
}

.bento-full {
  grid-column: span 4;
}

.input-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: #fafafa;
}

.field input:focus {
  outline: 2px solid var(--accent);
  background: var(--surface);
}

.target-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.target-highlight {
  background: var(--accent-soft);
  border-color: #bfdbfe;
}

.target-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.target-highlight .target-value {
  color: var(--accent);
}

.target-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.section-heading h2 {
  font-size: 1rem;
  font-weight: 700;
}

.reset-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.grade-row {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.grade-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.grade-pill {
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.grade-pill:hover {
  border-color: #cbd5e1;
  color: var(--text);
}

.grade-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.score-136 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mini-input {
  width: 92px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  background: #f9fafb;
  color: var(--text);
}

.mini-input:focus {
  outline: 2px solid var(--accent);
  background: var(--surface);
}

.ck-needed {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

/* Bento Grid */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.bento-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.bento-hero {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.bento-hero h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.hero-sub {
  margin-top: 4px;
  font-size: 0.92rem;
  color: var(--muted);
}

.bento-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-label {
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.bento-period {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.period-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
}

.bento-location {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.location-text {
  font-size: 0.86rem;
  color: #374151;
}

/* Minimal List */
.exam-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exam-item {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.exam-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.05);
}

.exam-when {
  min-width: 84px;
  padding: 8px 10px;
  background: var(--accent-soft);
  border-radius: 12px;
  text-align: center;
  flex-shrink: 0;
}

.exam-day {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.exam-weekday {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
}

.exam-time {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.exam-body {
  flex: 1;
  min-width: 0;
}

.exam-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.exam-title {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-major {
  background: var(--major-bg);
  color: var(--major-text);
}

.pill-general {
  background: var(--general-bg);
  color: var(--general-text);
}

.exam-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.86rem;
  color: #4b5563;
  margin-bottom: 6px;
}

.exam-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

/* Mobile */
@media (max-width: 640px) {
  body {
    padding: 12px 10px 28px;
  }

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

  .bento-hero,
  .bento-period,
  .bento-location,
  .bento-full {
    grid-column: span 2;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .grade-row {
    flex-direction: row;
    align-items: center;
  }

  .bento-card {
    padding: 14px;
  }

  .exam-item {
    flex-direction: column;
    gap: 10px;
    padding: 14px;
  }

  .exam-when {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    text-align: left;
  }

  .exam-weekday {
    margin-top: 0;
    font-size: 0.82rem;
  }

  .exam-time {
    margin-top: 0;
    font-size: 0.9rem;
  }

  .exam-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}
