/* Clean Light workspace — plain CSS, based on DESIGN.md. */
:root {
  color-scheme: light;
  --font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bg-main: #F6F9FC;
  --bg-card: #FFFFFF;
  --border-subtle: #E3E8EE;
  --text-primary: #0D253D;
  --text-secondary: #64748D;
  --text-muted: #94A3B8;
  --primary: #0075DE;
  --primary-hover: #005BAB;
  --success: #1AAE39;
  --warning: #DD5B00;
  --danger: #E11D48;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-main);
  line-height: 1.4;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(0, 117, 222, .3);
  outline-offset: 4px;
}

code,
.check-item,
#label-assignment-id,
.local-file-name {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.topbar {
  min-height: 80px;
  padding: 16px 40px;
  background: white;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 50;
}

.topbar-left,
.topbar-right,
.assignment-meta-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left {
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #EDF5FD;
  display: grid;
  place-items: center;
  color: var(--primary);
}

.brand-icon svg {
  width: 23px;
  height: 23px;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.025em;
}

.brand-badge {
  color: var(--text-secondary);
  font-size: 12px;
}

.divider {
  display: none;
}

.workspace-label {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-label::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 5px 10px;
  background: white;
  color: var(--text-secondary);
  font-size: 12px;
  max-width: 100%;
}

.badge-tag.primary {
  color: var(--primary);
  background: #EDF5FD;
  border-color: #D4E7FA;
}

.badge-tag.success {
  color: #16822E;
  background: #F0FAF2;
  border-color: #D7EEDD;
}

#label-template-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
}

.btn,
.dropzone-browse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  transition: background .15s, border-color .15s;
}

.btn-secondary {
  background: white;
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: #F6F5F4;
}

.btn-primary,
.dropzone-browse-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover,
.dropzone-browse-btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.main-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

.dropzone-container {
  width: min(1040px, calc(100% - 48px));
  margin: auto;
  padding: 12px 0;
}

.hero-header {
  margin-bottom: 12px;
  text-align: center;
}

.hero-title {
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -.015em;
  margin: 0;
  text-align: center;
}

.upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: stretch;
}

.upload-panel,
.guide-panel {
  background: white;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 20px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2,
.guide-panel h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.file-type {
  color: var(--text-secondary);
  font-size: 11px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px 7px;
}

.dropzone-card {
  border: 1px dashed #BACBDB;
  border-radius: 8px;
  padding: 16px 14px;
  text-align: center;
  background: #FBFDFF;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.dropzone-card:hover,
.dropzone-card:focus-within,
.dropzone-card.dragover {
  border-color: var(--primary);
  background: #F0F7FE;
}

.dropzone-icon-wrap {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--primary);
  background: white;
  margin: 0 auto 8px;
}

.dropzone-icon-wrap svg {
  width: 22px;
  height: 22px;
}

.dropzone-prompt {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.dropzone-hint {
  color: var(--text-secondary);
  font-size: 12px;
  margin: 0 auto 10px;
  max-width: 380px;
  line-height: 1.35;
}

.package-label {
  color: var(--text-secondary);
  font-size: 11px;
  margin: 10px 0 6px;
}

.package-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-secondary);
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 3px 6px;
}

.check-item svg {
  width: 11px;
  height: 11px;
  color: var(--text-secondary);
}

.guide-panel {
  display: flex;
  flex-direction: column;
}

.guide-panel ol {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  counter-reset: guide;
  display: grid;
  gap: 10px;
}

.guide-panel li {
  position: relative;
  padding-left: 30px;
  counter-increment: guide;
}

.guide-panel li::before {
  content: counter(guide, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font: 10px ui-monospace, monospace;
  color: var(--text-secondary);
}

.guide-panel strong {
  font-size: 12px;
  font-weight: 600;
}

.guide-panel p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.privacy-note {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
}

.privacy-note strong {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.privacy-note p {
  margin: 2px 0 0;
  font-size: 10.5px;
  line-height: 1.3;
}

.workspace-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 8px 0 0;
}

#local-assignments-section {
  margin-top: 32px;
}

#local-assignments-count {
  color: var(--text-secondary);
  font-size: 12px;
}

#local-assignments-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.local-assignment-card {
  background: white;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.local-assignment-card:hover {
  border-color: var(--primary);
}

.local-file-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.local-file-name {
  font-weight: 600;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.local-file-meta {
  color: var(--text-secondary);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

body.has-active-form {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.has-active-form .topbar {
  flex-shrink: 0;
}

.has-active-form .workspace-label {
  display: none;
}

.has-active-form .main-viewport {
  flex: 1;
  overflow: hidden;
}

#viewer-stage {
  display: none;
  height: 100%;
  background: white;
  overflow: hidden;
}

#viewer-stage.active {
  display: flex;
  flex-direction: column;
}

#form-root,
#fasih-form {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#fasih-form [data-expanded].tw\:backdrop-blur-sm,
#fasih-form .tw\:absolute.tw\:inset-0.tw\:z-50 {
  position: absolute !important;
  inset: 0 !important;
  z-index: 50 !important;
}

#fasih-form .tw\:border\! {
  max-height: 85vh !important;
}

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(246, 249, 252, .94);
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(440px, calc(100% - 32px));
}

.toast {
  padding: 16px 20px;
  border-radius: 8px;
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 25px -5px rgba(13, 37, 61, .08), 0 4px 10px -3px rgba(13, 37, 61, .04);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s, transform .2s;
  overflow-wrap: anywhere;
}

.toast svg {
  flex-shrink: 0;
}

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

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.error svg {
  color: var(--danger);
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.success svg {
  color: var(--success);
}

@media (max-width: 900px) {
  .topbar {
    padding: 16px 24px;
    flex-wrap: wrap;
  }

  .dropzone-container {
    width: calc(100% - 48px);
    margin-top: 32px;
  }

  .upload-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .guide-panel ol {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 16px;
  }

  .workspace-label {
    display: none;
  }

  .dropzone-container {
    width: calc(100% - 32px);
    margin-top: 24px;
  }

  .hero-title {
    font-size: 28px;
  }

  .hero-subtitle {
    font-size: 14px;
  }

  .upload-panel,
  .guide-panel {
    padding: 20px;
  }

  .dropzone-card {
    padding: 28px 12px;
  }

  .dropzone-prompt {
    font-size: 16px;
  }

  .dropzone-browse-btn {
    width: 100%;
    padding: 8px;
    font-size: 13px;
  }

  .guide-panel ol {
    grid-template-columns: 1fr;
  }

  .workspace-footer {
    flex-direction: column;
    gap: 6px;
  }

  .assignment-meta-bar {
    gap: 6px;
  }

  .section-heading {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    transition: none !important;
    animation-duration: 2s !important;
    scroll-behavior: auto !important;
  }
}

@media print {

  .topbar,
  .dropzone-container,
  .toast-container,
  .loading-overlay {
    display: none !important;
  }

  body.has-active-form,
  body.has-active-form .main-viewport,
  #viewer-stage,
  #form-root,
  #fasih-form {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    background: white;
  }
}