:root {
  --blue:       #2563EB;
  --blue-dark:  #1D4ED8;
  --blue-light: #EFF6FF;
  --gray-50:    #F8FAFC;
  --gray-100:   #F1F5F9;
  --gray-200:   #E2E8F0;
  --gray-400:   #94A3B8;
  --gray-600:   #475569;
  --gray-900:   #0F172A;
  --red:        #EF4444;
  --red-bg:     #FEF2F2;
  --red-border: #FECACA;
  --radius:     8px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--gray-50);
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--gray-900);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
}

.logo svg { color: var(--blue); }

.accent { color: var(--blue); }

.header-sub {
  color: var(--gray-400);
  font-size: 12px;
  padding-left: 20px;
  border-left: 1px solid var(--gray-200);
}

/* ── Main layout ─────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Left panel ──────────────────────────────────────────────────────────── */

.panel-left {
  background: white;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.form-section {
  padding: 24px 20px 0;
}

.form-section h2 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 16px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: color .12s, border-color .12s;
}

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

.tab:hover:not(.active) {
  color: var(--gray-900);
}

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Textarea */
textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 11px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--gray-900);
  outline: none;
  transition: border-color .12s;
  background: white;
}

textarea:focus { border-color: var(--blue); }
textarea::placeholder { color: var(--gray-400); }

/* Upload zone */
.upload-zone {
  display: block;
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  min-height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-zone:hover,
.upload-zone.dragging {
  border-color: var(--blue);
  background: var(--blue-light);
}

#upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--gray-600);
  pointer-events: none;
}

#upload-placeholder svg { color: var(--gray-400); }

.upload-hint {
  font-size: 11px;
  color: var(--gray-400);
}

#img-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 6px;
  object-fit: contain;
}

/* Button */
.btn-primary {
  width: 100%;
  margin-top: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
  font-family: inherit;
}

.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

/* Spinner */
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

.hidden { display: none !important; }

/* Error */
.error-msg {
  margin: 0 20px 16px;
  padding: 11px 14px;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

/* Steps list */
.pasos-section {
  padding: 0 20px 28px;
  flex: 1;
}

.pasos-section h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}

.pasos-lista {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pasos-lista li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--gray-600);
  padding: 9px 12px;
  background: var(--gray-50);
  border-radius: 6px;
  border-left: 3px solid var(--gray-200);
  transition: background .12s, border-color .12s;
}

.pasos-lista li .paso-num {
  font-weight: 700;
  color: var(--blue);
  flex-shrink: 0;
  min-width: 16px;
  font-size: 12px;
}

/* ── Right panel: GeoGebra ───────────────────────────────────────────────── */

.panel-right {
  background: var(--gray-100);
  overflow: hidden;
  display: flex;
}

#applet-wrap {
  flex: 1;
  position: relative;
  display: flex;
}

.applet-overlay {
  position: absolute;
  inset: 0;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--gray-600);
  font-size: 13px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

#ggb-container {
  width: 100%;
  height: 100%;
}

/* iframe injected by GeoGebra */
#ggb-container iframe,
#ggb-container > div {
  width: 100% !important;
  height: 100% !important;
}

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

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    overflow: visible;
  }

  .panel-right {
    min-height: 55vw;
  }

  .header-sub { display: none; }
}
