/* Alchemist design system: tokens, base elements and shared components.
   A bright, accessible learning environment. Layout is mobile-first. */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --surface-3: #e3e9f2;
  --text: #121a2b;
  --muted: #4f5d75;
  --border: #d5dde8;
  --brand: #0f766e;
  --brand-strong: #0b5c56;
  --brand-soft: #dcf3ef;
  --on-brand: #ffffff;
  --accent: #6d28d9;
  --link: #0b6b64;
  --ok: #15803d;
  --ok-soft: #e3f5e8;
  --warn: #9a4a07;
  --warn-soft: #fdf0dc;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 6px 20px rgb(15 23 42 / 6%);
  --shadow-lg: 0 10px 40px rgb(15 23 42 / 12%);
  --stage: radial-gradient(circle at 50% 35%, #ffffff 0%, #e9eef6 70%, #dfe6f0 100%);
  --bond: #8b93a3;
  --radius: 14px;
  --radius-sm: 10px;
  --font:
    system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', Ubuntu, Cantarell, 'Helvetica Neue', Arial,
    sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', 'Cascadia Code', 'Roboto Mono', Menlo, Consolas, monospace;
  --container: 1200px;
  --gutter: 16px;
  --lv-sd: #1f7a3a;
  --lv-sd-bg: #e1f4e6;
  --lv-smp: #0b6285;
  --lv-smp-bg: #dff1f9;
  --lv-sma: #5b2bb5;
  --lv-sma-bg: #ece5fb;
  --lv-kuliah: #a3245f;
  --lv-kuliah-bg: #fbe4ef;
  color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main {
  flex: 1;
  outline: none;
  padding-bottom: 3rem;
}
h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 1.4em 0 0.5em;
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(1.7rem, 4vw + 0.6rem, 2.6rem);
  margin-top: 0.4em;
}
h2 {
  font-size: clamp(1.3rem, 1.6vw + 0.8rem, 1.7rem);
}
h3 {
  font-size: 1.15rem;
}
.h-small {
  font-size: 1.05rem;
  margin: 0 0 0.6em;
}
p {
  margin: 0 0 0.9em;
}
a {
  color: var(--link);
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration-thickness: 2px;
}
img,
svg,
canvas {
  max-width: 100%;
}
img {
  height: auto;
}
code,
.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}
code.wrap {
  word-break: break-all;
}
small,
.small {
  font-size: 0.86rem;
}
.muted {
  color: var(--muted);
}
.center {
  text-align: center;
}
.pre {
  white-space: pre-wrap;
}
hr {
  border: 0;
  border-top: 1px solid var(--border);
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
::selection {
  background: var(--brand-soft);
}
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  transform: translateY(-200%);
  z-index: 100;
  background: var(--brand);
  color: var(--on-brand);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.skip-link:focus {
  transform: none;
}
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container.narrow {
  max-width: 820px;
}
@media (min-width: 720px) {
  :root {
    --gutter: 24px;
  }
}

/* ---------- Buttons & form controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.1s;
}
.btn:hover {
  border-color: var(--brand);
  background: var(--surface-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: var(--on-brand);
}
.btn-danger {
  color: var(--danger);
  border-color: currentColor;
}
.btn-small {
  min-height: 36px;
  padding: 0.25rem 0.8rem;
  font-size: 0.9rem;
}
.btn.is-done {
  color: var(--ok);
  border-color: currentColor;
}
.btn[aria-pressed='true'] {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
}
.icon-btn[aria-pressed='true'] {
  background: var(--brand-soft);
  color: var(--brand-strong);
}
input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  min-height: 44px;
  width: 100%;
  max-width: 100%;
}
textarea {
  min-height: 6rem;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
}
input[type='range'] {
  padding: 0;
  border: 0;
  accent-color: var(--brand);
  background: transparent;
}
input[type='checkbox'],
input[type='radio'] {
  width: 1.2rem;
  height: 1.2rem;
  min-height: 0;
  accent-color: var(--brand);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
  min-width: 0;
}
.field > label,
.field > span,
legend {
  font-weight: 600;
  font-size: 0.93rem;
}
.field output {
  font-weight: 700;
  color: var(--brand-strong);
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 0.8rem;
  min-width: 0;
}
.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.filters .field {
  margin: 0;
  flex: 1 1 160px;
}
.filters .field-grow {
  flex: 3 1 260px;
}

/* ---------- Segmented control, chips, badges ---------- */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  max-width: 100%;
}
.seg-btn {
  min-height: 40px;
  padding: 0.35rem 0.85rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn[aria-pressed='true'] {
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: var(--shadow);
}
.seg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0.2rem 0.75rem;
  margin: 0.15rem 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  text-decoration: none;
  cursor: pointer;
}
a.chip:hover,
button.chip:hover {
  border-color: var(--accent, var(--brand));
}
.chip[aria-pressed='true'] {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.chip-lg {
  min-height: 44px;
  font-size: 0.95rem;
}
.chip-class {
  border-left: 4px solid var(--accent, var(--brand));
}
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.5;
}
.badge-sd {
  color: var(--lv-sd);
  background: var(--lv-sd-bg);
}
.badge-smp {
  color: var(--lv-smp);
  background: var(--lv-smp-bg);
}
.badge-sma {
  color: var(--lv-sma);
  background: var(--lv-sma-bg);
}
.badge-kuliah {
  color: var(--lv-kuliah);
  background: var(--lv-kuliah-bg);
}
.badge-live {
  color: var(--brand-strong);
  background: var(--brand-soft);
}
.dot {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 1px solid rgb(0 0 0 / 15%);
  vertical-align: -0.1em;
  margin-right: 0.3rem;
  flex: none;
}

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
a.card {
  color: inherit;
  text-decoration: none;
  transition:
    transform 0.15s,
    border-color 0.15s;
}
a.card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}
.grid {
  display: grid;
  gap: 1rem;
}
.grid-2,
.grid-3,
.grid-4 {
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .grid-2,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 980px) {
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.grid-cards {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}
.grid-classes {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
}
.card-title {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0.2rem 0 0.35rem;
  line-height: 1.3;
}
.card-text {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}
.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.section-head h2 {
  margin-bottom: 0.3rem;
}
.link-more {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  min-height: 44px;
}

/* Molecule card */
.mol-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.card-link {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.card-link:hover .card-title {
  color: var(--link);
  text-decoration: underline;
}
.card-media {
  aspect-ratio: 3 / 2;
  background: var(--surface);
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-structure {
  width: auto;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  padding: 0.4rem;
  background: #fff;
  border-radius: 8px;
}
.img-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #7a869a;
  background: var(--surface-2);
}
.card-body {
  padding: 0.8rem 1rem 0.4rem;
  flex: 1;
}
.mol-card .card-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem 0.6rem 1rem;
}
.card-save {
  margin-left: auto;
}
.formula {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--brand-strong);
  margin: 0 0 0.1rem;
  font-size: 0.95rem;
}
.formula-lg {
  font-size: 1.3rem;
}
.formula sub,
.equation sub {
  font-size: 0.72em;
}
.coef {
  margin-right: 0.1em;
}

/* Class card */
.class-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border-top: 5px solid var(--accent);
}
.class-icon {
  color: var(--accent);
}
.class-name {
  font-weight: 700;
}
.class-general {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.9rem;
}
.class-count {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Topic / lab cards */
.topic-card,
.lab-card,
.place-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: relative;
}
.topic-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.topic-num {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  font-weight: 800;
  color: var(--muted);
}
.topic-meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  margin-top: 0.3rem;
}

/* ---------- Notices, states, toasts ---------- */
.notice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  margin: 0.8rem 0;
}
.notice > svg {
  flex: none;
  margin-top: 0.2rem;
}
.notice p:last-child,
.notice div > :last-child {
  margin-bottom: 0;
}
.notice-warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}
.warn {
  color: var(--warn);
  font-weight: 600;
}
.ok {
  color: var(--ok);
  font-weight: 600;
}
.state-loading,
.state-empty,
.state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}
.state-title {
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.state-error {
  color: var(--warn);
}
.spinner {
  width: 2.2rem;
  height: 2.2rem;
  border: 3px solid var(--surface-3);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.page-state {
  padding-block: 4rem;
  text-align: center;
}
.toast-region {
  position: fixed;
  inset: auto 1rem 1rem auto;
  z-index: 60;
  max-width: min(92vw, 420px);
}
.toast {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  background: var(--text);
  color: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
}
.toast .btn {
  color: var(--text);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}
.data-table th,
.data-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.data-table th[scope='row'] {
  width: 40%;
  color: var(--muted);
  font-weight: 600;
}
.data-table td p {
  margin: 0 0 0.3rem;
}
.data-table caption {
  text-align: left;
  font-weight: 700;
  padding-bottom: 0.4rem;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  border-bottom: 1px solid var(--border);
  margin: 1rem 0;
}
.tab {
  min-height: 44px;
  padding: 0.4rem 1rem;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected='true'] {
  color: var(--brand-strong);
  border-bottom-color: var(--brand);
}

/* ---------- Legend ---------- */
.legend {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  font-size: 0.86rem;
}
.legend li {
  display: inline-flex;
  align-items: center;
}

/* ---------- Icons ---------- */
.icon {
  flex: none;
  vertical-align: middle;
}

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