.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.tiny-btn {
  padding: 10px 14px;
  font-size: 0.85rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.badge.soft {
  background: var(--surface-subtle);
}

.toast {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--status-bg);
  border: 1px solid var(--status-border);
}

.view {
  display: none;
  gap: 18px;
  padding: 0;
}

.view.active {
  display: grid;
}

.grid {
  display: grid;
}

.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sheet-workspace-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 10px 0;
  margin-bottom: 10px;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
}

.sheet-tab {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 11px 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.sheet-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.student-tab-panel { display: none; }
.student-tab-panel.active { display: block; }
.student-workspace-tabs { margin-bottom: 18px; }
.student-entry-panel { display: none; }
.student-entry-panel.active { display: block; }
.student-entry-tabs { position: static; padding: 0; margin: 4px 0 0; background: transparent; }

.sheet-builder-grid {
  grid-template-columns: minmax(320px, 0.85fr) minmax(500px, 1.15fr);
  align-items: start;
}

.sheet-builder-grid > article:last-child {
  position: sticky;
  top: 76px;
}

.preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 9px;
}

.preview-section-title { grid-column: 1 / -1; }

@media (max-width: 1100px) {
  .sheet-builder-grid { grid-template-columns: minmax(0, 1fr); }
  .sheet-builder-grid > article:last-child { position: static; }
}

.tight {
  gap: 10px;
}

.spaced {
  gap: 18px;
}

.spaced-top {
  margin-top: 18px;
}

.pad {
  padding: 20px;
}

.stat {
  padding: 20px;
}

.stat strong {
  display: block;
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 4px 0;
}

.cards-grid,
.results-list,
.list,
.activity-list {
  display: grid;
  gap: 12px;
}

.card-row,
.result-row,
.list-row,
.activity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
}

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

.form-preview {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.preview-page {
  border-radius: 20px;
  background: var(--preview-bg);
  color: var(--preview-text);
  padding: 18px;
  min-height: 520px;
  box-shadow: inset 0 0 0 1px rgba(20, 28, 40, 0.06);
}

.preview-empty {
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  color: rgba(26, 36, 50, 0.72);
}

.preview-empty strong { color: var(--preview-text); }

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.preview-heading { flex: 1; }
.preview-logo { width: 46px; height: 46px; object-fit: contain; }

.preview-grid {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.preview-identity {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 0.78rem;
}

.preview-identity th {
  width: 12%;
  text-align: left;
  padding: 6px 8px 6px 0;
}

.preview-identity td {
  width: 38%;
  height: 26px;
  border-bottom: 1px solid var(--line-strong);
}

.preview-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
}

.preview-section-title {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(20, 32, 44, 0.08);
  font-size: 0.78rem;
  font-weight: 700;
}

.preview-answer-line {
  min-height: 22px;
  border-bottom: 1px solid rgba(20, 32, 44, 0.42);
}

.section-editor {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.section-editor-row {
  display: block;
  padding: 0 14px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-subtle);
}

.section-editor-row:not([open]) { padding-bottom: 0; }
.section-editor-content { display: grid; gap: 12px; padding-top: 12px; }

.section-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.section-editor-head::-webkit-details-marker { display: none; }
.section-editor-head > span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.section-range, .section-format { color: var(--muted); font-size: 0.82rem; }
.inline-actions { display: flex; align-items: center; gap: 8px; }
.logo-uploader { display: grid; gap: 8px; }

.section-choices > span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.section-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control-bg-soft);
}

.choice-chip input {
  width: 14px;
  height: 14px;
}

.section-editor-error {
  color: var(--danger);
}

.bubble-set {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.bubble {
  width: 27px;
  height: 27px;
  border-radius: 999px;
  border: 1.5px solid var(--preview-bubble-border);
  display: inline-grid;
  place-items: center;
  font-size: 0.7rem;
  background: var(--preview-bubble-bg);
}

.bubble.filled {
  background: var(--preview-bubble-fill);
  border-color: #7a5c0a;
}

.summary-box {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.summary-item {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
}

.camera-frame {
  position: relative;
  min-height: 340px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px dashed var(--camera-border);
  background: var(--camera-bg);
}

.camera-frame video,
.scan-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-frame video {
  min-height: 340px;
  background: rgba(0, 0, 0, 0.28);
}

.scan-preview {
  margin-top: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.auth-screen .card {
  min-height: 0;
}

.preview-row {
  grid-template-columns: 28px 1fr;
}

.bubble-set {
  gap: 6px;
}

.auth-head {
  align-items: flex-start;
}

.print-area {
  display: none;
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  .auth-screen,
  .sidebar,
  .topbar,
  .view:not([data-view-panel="forms"]),
  .nav-btn,
  .toast,
  .btn,
  .camera-actions,
  #scanForm,
  #resultsList,
  .hero-copy,
  #authScreen {
    display: none !important;
  }

  .app-screen {
    display: block !important;
    width: 100%;
  }

  #appScreen {
    padding: 0;
  }

  #printArea {
    display: block;
  }
}

@media (max-width: 1120px) {
  .app-screen.active {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-screen,
  .cols-2,
  .cols-3 {
    grid-template-columns: 1fr;
  }

  .auth-screen {
    padding-top: 16px;
  }

  .topbar,
  .pad,
  .stat,
  .auth-card,
  .sidebar {
    padding: 18px;
  }

  .topbar-meta {
    width: 100%;
  }

  .topbar-meta .btn {
    flex: 1 1 auto;
  }

  .auth-head {
    gap: 10px;
    align-items: stretch;
  }
}

@media (min-width: 821px) and (max-width: 1180px) {
  .auth-screen {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .hero-copy {
    max-width: 860px;
  }

  .auth-card {
    margin-left: 0;
    width: min(100%, 560px);
  }
}

/* Focus the login screen on the sign-in form. */
.auth-screen {
  display: grid;
  grid-template-columns: minmax(0, 440px);
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 30px;
  margin: 0;
  border-radius: 26px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0 auto 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  font-size: 1.25rem;
}

.auth-brand img {
  display: block;
  width: min(300px, 72vw);
  height: auto;
  object-fit: contain;
}

.auth-brand .brand-byline {
  margin-top: -2px;
  font-size: .74rem;
}

.auth-head {
  align-items: center;
  margin-bottom: 22px;
}

.auth-head h2 {
  font-size: 1.8rem;
  line-height: 1.1;
}

.auth-head .muted {
  margin: 7px 0 0;
}

.auth-card .stack {
  gap: 16px;
}

.auth-card input:not([type="hidden"]) {
  min-height: 50px;
  border-radius: 13px;
}

.auth-card .btn-primary {
  min-height: 50px;
  border-radius: 13px;
}

.auth-card .google-login-btn {
  min-height: 48px;
  border-radius: 13px;
}

@media (max-width: 520px) {
  .auth-screen {
    padding: 16px;
  }

  .auth-card {
    padding: 24px;
  }
}

.sheet-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, var(--surface), var(--surface-subtle));
  box-shadow: 0 5px 18px rgba(27, 41, 58, 0.045);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.sheet-card:hover { border-color: rgba(220, 155, 35, 0.48); box-shadow: 0 10px 26px rgba(27, 41, 58, 0.08); transform: translateY(-1px); }
.sheet-card-copy { min-width: 0; flex: 1; }
.sheet-card-title-row { display: flex; align-items: center; gap: 11px; margin-bottom: 7px; }
.sheet-card-mark { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; color: #9c6710; background: rgba(244, 185, 66, 0.16); border-radius: 11px; }
.sheet-card-mark svg { width: 19px; height: 19px; }
.sheet-card-title { font-size: 1rem; line-height: 1.35; overflow-wrap: anywhere; }
.sheet-card-meta, .sheet-card-sections { margin-left: 47px; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.sheet-card-meta { font-weight: 650; color: var(--text); }
.sheet-card-meta span { padding: 0 3px; color: var(--muted); }
.sheet-card-sections { margin-top: 2px; }
.sheet-card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0 47px; }
.sheet-tag { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); font-size: 0.74rem; font-weight: 650; }
.sheet-tag svg { width: 13px; height: 13px; }
.sheet-tag.is-ready { color: #315c8d; background: rgba(112, 158, 214, 0.12); border-color: rgba(78, 128, 190, 0.24); }
.sheet-card-template { color: var(--muted); font-size: 0.75rem; }
.sheet-card-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.sheet-action { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 0.84rem; font-weight: 700; box-shadow: 0 2px 5px rgba(27, 41, 58, 0.04); }
.sheet-action svg { width: 16px; height: 16px; }
.sheet-action:hover { border-color: rgba(220, 155, 35, 0.6); background: rgba(244, 185, 66, 0.08); }
.sheet-action-print { color: #7b5107; background: rgba(244, 185, 66, 0.14); border-color: rgba(220, 155, 35, 0.28); }
.sheet-action-delete { color: #a43b3b; }
.sheet-action-delete:hover { color: #8d2020; background: rgba(210, 75, 75, 0.08); border-color: rgba(210, 75, 75, 0.32); }
@media (max-width: 760px) {
  .sheet-card { align-items: stretch; flex-direction: column; gap: 16px; padding: 16px; }
  .sheet-card-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sheet-action { padding: 0 8px; }
}

.preview-toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }
.preview-print-btn { display: inline-flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 15px; border-radius: 12px; color: #fff; background: linear-gradient(135deg, #263d56, #345c78); box-shadow: 0 5px 14px rgba(38, 61, 86, 0.18); font-size: 0.84rem; font-weight: 700; }
.preview-print-btn:hover { background: linear-gradient(135deg, #1f334a, #2c506b); transform: translateY(-1px); }
.preview-print-btn svg { width: 17px; height: 17px; }
@media (max-width: 760px) { .preview-toolbar { width: 100%; justify-content: space-between; } .preview-print-btn { flex: 1; justify-content: center; } }

.sheet-preview-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 22px; background: rgba(18, 29, 43, 0.64); backdrop-filter: blur(5px); }
.sheet-preview-dialog { display: flex; flex-direction: column; width: min(980px, 96vw); height: min(94vh, 1180px); overflow: hidden; border: 1px solid rgba(255,255,255,.7); border-radius: 22px; background: var(--surface); box-shadow: 0 28px 90px rgba(8, 20, 34, .28); }
.sheet-preview-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.sheet-preview-header .card-kicker { margin: 0 0 3px; }
.sheet-preview-header h2 { margin: 0; font-size: 1.12rem; overflow-wrap: anywhere; }
.sheet-preview-header p:last-child { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.sheet-preview-close { width: 40px; height: 40px; flex: 0 0 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.sheet-preview-frame { display: block; width: 100%; flex: 1; min-height: 0; border: 0; background: #e9edf2; }
.sheet-preview-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 13px 20px; border-top: 1px solid var(--line); }
.sheet-preview-dismiss { min-height: 42px; padding: 0 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.sheet-card-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 520px; }
@media (max-width: 760px) { .sheet-preview-overlay { padding: 8px; } .sheet-preview-dialog { width: 100%; height: 96vh; border-radius: 16px; } .sheet-preview-header { padding: 14px; } .sheet-preview-footer { padding: 10px 12px; } .sheet-card-actions { max-width: none; grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.logo-library-label { margin-top: 10px; }

#liveScanOverlay { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }
.live-scan-hint { position: absolute; z-index: 3; top: 12px; left: 12px; right: 12px; width: fit-content; max-width: calc(100% - 24px); padding: 8px 12px; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; color: #fff; background: rgba(12,25,40,.82); font-size: .78rem; font-weight: 800; text-shadow: 0 1px 2px #000; pointer-events: none; }
.camera-fullscreen { position:fixed; inset:0; z-index:5000; display:grid; grid-template-rows:auto minmax(0,1fr) auto; gap:10px; padding:calc(env(safe-area-inset-top) + 10px) 12px calc(env(safe-area-inset-bottom) + 10px); color:#fff; background:#071421; }
.camera-fullscreen.hidden { display:none; }
.camera-fullscreen-head,.camera-fullscreen-foot { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.camera-fullscreen-head strong { font-size:1rem; letter-spacing:.04em; }
.camera-fullscreen-foot { justify-content:center; min-height:34px; color:rgba(255,255,255,.8); font-size:.82rem; text-align:center; }
.camera-fullscreen-foot:empty::before { content:"Halakan kamera ke seluruh helaian untuk mula mengesan."; }
.camera-fullscreen-foot .live-scan-hint { position:static; z-index:auto; width:auto; max-width:100%; padding:0; border:0; border-radius:0; color:inherit; background:transparent; font-size:.92rem; text-align:center; text-shadow:none; }
.camera-fullscreen-frame-host { min-height:0; overflow:hidden; }
.camera-fullscreen-frame-host .camera-frame { width:100%; height:100%; min-height:0; border:0; border-radius:14px; }
.camera-fullscreen-frame-host .camera-frame video { width:100%; height:100%; min-height:0; object-fit:contain; }
body.camera-fullscreen-active { overflow:hidden; }
@media (orientation: landscape) { .camera-fullscreen { grid-template-columns:minmax(0,1fr); } .camera-fullscreen-frame-host .camera-frame { max-height:calc(100dvh - 118px); } }
