/* ============================================================
   GEOMETRIA LOMLOE - Global Styles
   Author: IES Geometry Project
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
  /* Colors */
  --color-bg:         #f8f9fa;
  --color-surface:    #ffffff;
  --color-border:     #e2e8f0;
  --color-text:       #1e293b;
  --color-text-muted: #64748b;

  --color-primary:    #2563eb;
  --color-primary-dk: #1d4ed8;
  --color-secondary:  #059669;

  /* Bloc colors */
  --color-plana:      #3b82f6;
  --color-espacial:   #8b5cf6;
  --color-analitica:  #f59e0b;
  --color-transform:  #10b981;

  /* Status */
  --color-success:    #22c55e;
  --color-warning:    #f59e0b;
  --color-error:      #ef4444;

  /* Sizes */
  --header-h:    56px;
  --sidebar-w:   260px;
  --panel-w:     280px;
  --radius:      8px;
  --radius-lg:   12px;

  /* Typography */
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:   'Courier New', Courier, monospace;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.12);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.16);

  /* Transitions */
  --transition:  0.18s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; flex-shrink: 0; }

/* ---- Utility ---- */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding: 0 16px;
}
.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 6px;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}
.menu-toggle:hover { background: var(--color-border); }

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.brand-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}
.brand-subtitle {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.header-nav { flex: 1; overflow: hidden; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  overflow: hidden;
}
.breadcrumb li { white-space: nowrap; }
.breadcrumb li:not(:last-child)::after { content: '›'; margin-left: 4px; color: var(--color-border); }
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb li:last-child { color: var(--color-text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lang-selector { display: flex; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 20px; padding: 2px; }
.lang-btn {
  background: none;
  border: none;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: all var(--transition);
  letter-spacing: 0.04em;
}
.lang-btn.active {
  background: var(--color-primary);
  color: #fff;
}
.lang-btn:hover:not(.active) { background: var(--color-border); color: var(--color-text); }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  margin-top: var(--header-h);
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease, border-color 0.25s ease, transform var(--transition);
}
.sidebar.collapsed {
  width: 0;
  border-right-color: transparent;
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.sidebar-search {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-search input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition);
}
.sidebar-search input:focus { border-color: var(--color-primary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* Bloc groups */
.nav-bloc { margin-bottom: 4px; }
.nav-bloc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  border-radius: 0;
}
.nav-bloc-header:hover { background: var(--color-bg); }
.nav-bloc-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.nav-bloc-name {
  font-size: 0.8125rem;
  font-weight: 600;
  flex: 1;
}
.nav-bloc-chevron {
  color: var(--color-text-muted);
  transition: transform var(--transition);
}
.nav-bloc.open .nav-bloc-chevron { transform: rotate(90deg); }

.nav-modules { display: none; padding-left: 8px; }
.nav-bloc.open .nav-modules { display: block; }
.nav-module-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-module-btn:hover { background: var(--color-bg); color: var(--color-text); }
.nav-module-btn.active { background: color-mix(in srgb, var(--color-primary) 10%, transparent); color: var(--color-primary); font-weight: 500; }
.nav-module-tag {
  margin-left: auto;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   MAIN
   ============================================================ */
.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
.home-screen {
  height: 100%;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.home-hero { text-align: center; padding: 16px 0; }
.home-hero h1 { font-size: 1.75rem; font-weight: 700; color: var(--color-text); margin-bottom: 8px; }
.home-hero p { font-size: 1rem; color: var(--color-text-muted); max-width: 480px; margin: 0 auto; }

.bloc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.bloc-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  border-top: 4px solid var(--bloc-color, var(--color-primary));
  box-shadow: var(--shadow-sm);
}
.bloc-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.bloc-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bloc-color, var(--color-primary)) 12%, transparent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  color: var(--bloc-color, var(--color-primary));
}
.bloc-card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.bloc-card p { font-size: 0.8125rem; color: var(--color-text-muted); margin-bottom: 12px; line-height: 1.4; }
.bloc-card-count { font-size: 0.75rem; color: var(--bloc-color, var(--color-primary)); font-weight: 600; }

.home-info {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.info-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ============================================================
   MODULE SCREEN
   ============================================================ */
.module-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.module-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.module-title-area { flex: 1; min-width: 0; }
.module-title {
  font-size: 1.125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-cursos { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.curs-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--bloc-color, var(--color-primary)) 15%, transparent);
  color: var(--bloc-color, var(--color-primary));
}

.module-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.btn-icon {
  background: none;
  border: 1px solid var(--color-border);
  padding: 6px;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-text); border-color: var(--color-text-muted); }
.btn-icon.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.module-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ============================================================
   CANVAS
   ============================================================ */
.canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #fff;
  cursor: crosshair;
  min-height: 300px;
}
.canvas-area canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.canvas-area canvas:focus { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.canvas-overlay {
  position: absolute;
  top: 8px; left: 8px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---- 3D drag handles ---- */
.handle-3d {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  touch-action: none;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  transform: translate(-50%, -50%);
  z-index: 20;
  pointer-events: all;
  transition: box-shadow 0.1s, transform 0.1s;
  background: var(--handle-color, #f59e0b);
  /* Prevent canvas orbit while dragging handle */
}
.handle-3d:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  transform: translate(-50%, -50%) scale(1.12);
}
.handle-3d.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.18);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.handle-3d .handle-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  pointer-events: none;
}

/* ============================================================
   COORDINATE INPUT POPUP
   ============================================================ */

.coord-popup {
  position: fixed;
  z-index: 9999;
  top: calc(50% - 8px);
  left: 50%;
  transform: translate(-50%, -100%);
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 12px 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: coord-popup-in 0.12s ease;
}
@keyframes coord-popup-in {
  from { opacity: 0; transform: translate(-50%, -100%) scale(0.88); }
  to   { opacity: 1; transform: translate(-50%, -100%) scale(1); }
}
@keyframes ann-popup-in {
  from { opacity: 0; transform: translate(-50%, 0) scale(0.88); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.coord-popup-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.coord-popup-row {
  display: flex;
  gap: 8px;
}
.coord-popup-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.coord-popup-field span {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
}
.coord-popup-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #f1f5f9;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 6px;
  text-align: center;
  outline: none;
  box-sizing: border-box;
  -moz-appearance: textfield;
}
.coord-popup-input::-webkit-outer-spin-button,
.coord-popup-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.coord-popup-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.35);
}
.coord-popup-btns {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 2px;
}
.coord-popup-ok,
.coord-popup-cancel {
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 10px;
  transition: background 0.15s;
}
.coord-popup-ok {
  background: #2563eb;
  color: #fff;
}
.coord-popup-ok:hover { background: #1d4ed8; }
.coord-popup-cancel {
  background: #334155;
  color: #94a3b8;
}
.coord-popup-cancel:hover { background: #475569; }

/* ============================================================
   ANNOTATIONS
   ============================================================ */

/* Toolbar badge */
.btn-ann-toggle { position: relative; }
.ann-count {
  position: absolute;
  top: 2px; right: 2px;
  background: #f59e0b;
  color: #1e293b;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
  line-height: 1;
}
.btn-ann-toggle.has-anns { color: #f59e0b; }

/* Annotation input popup */
.ann-popup {
  position: fixed;
  z-index: 9999;
  top: calc(50% + 8px);
  left: 50%;
  transform: translate(-50%, 0);
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: ann-popup-in 0.12s ease;
}
.ann-popup-text {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #f1f5f9;
  font-size: 13px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 8px 10px;
  resize: none;
  outline: none;
  line-height: 1.5;
}
.ann-popup-text:focus { border-color: #2563eb; }
.ann-popup-colors {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ann-color-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.ann-color-dot.active {
  border-color: #fff;
  transform: scale(1.2);
}
.ann-popup-btns {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.ann-popup-ok {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ann-popup-ok:hover { background: #1d4ed8; }
.ann-popup-cancel {
  background: #334155;
  color: #94a3b8;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ann-popup-cancel:hover { background: #475569; }

/* Annotations side panel */
.ann-panel {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 100;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 200px;
  max-width: 280px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: coord-popup-in 0.12s ease;
}
.ann-panel-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ann-panel-clear {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.ann-panel-clear:hover { background: rgba(239,68,68,0.15); }
.ann-panel-empty {
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
}
.ann-panel-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
}
.ann-panel-text {
  flex: 1;
  font-size: 12px;
  color: #e2e8f0;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.ann-panel-del {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
}
.ann-panel-del:hover { color: #ef4444; }

/* ============================================================
   INFO PANEL
   ============================================================ */
.info-panel {
  width: var(--panel-w);
  flex-shrink: 0;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.info-panel::-webkit-scrollbar { width: 4px; }
.info-panel::-webkit-scrollbar-thumb { background: var(--color-border); }

.panel-section {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
}
.panel-section:last-child { border-bottom: none; }
.panel-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

/* Controls */
.controls-container { display: flex; flex-direction: column; gap: 8px; }
.control-row { display: flex; flex-direction: column; gap: 3px; }
.control-label { font-size: 0.8125rem; font-weight: 500; color: var(--color-text); display: flex; justify-content: space-between; }
.control-value { font-size: 0.75rem; color: var(--color-primary); font-weight: 600; font-family: var(--font-mono); }
.control-slider {
  width: 100%;
  height: 6px;
  accent-color: var(--color-primary);
  cursor: pointer;
  touch-action: none;
}
/* Larger thumb for touch/stylus */
.control-slider::-webkit-slider-thumb { width: 20px; height: 20px; }
.control-slider::-moz-range-thumb     { width: 20px; height: 20px; }
.dim-label-3d {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 0.875rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #000 !important;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 0 4px #fff, 0 0 8px #fff, 0 0 2px #fff;
  z-index: 5;
}
.control-select-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.control-select {
  width: 100%;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.8rem;
  cursor: pointer;
}
.control-select:focus {
  outline: none;
  border-color: var(--color-primary);
}
.control-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.toggle-switch {
  position: relative;
  width: 34px; height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(14px); }
.toggle-switch input:focus + .toggle-slider { outline: 2px solid var(--color-primary); outline-offset: 1px; }

/* Formulas */
.formulas-container { display: flex; flex-direction: column; gap: 6px; }
.formula-item {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--color-text);
  line-height: 1.5;
  border-left: 3px solid var(--color-primary);
}
.formula-label { font-size: 0.6875rem; font-family: var(--font-sans); color: var(--color-text-muted); margin-bottom: 2px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* Properties */
.properties-container { display: flex; flex-direction: column; gap: 4px; }
.property-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--color-bg);
  font-size: 0.8125rem;
}
.property-row:last-child { border-bottom: none; }
.property-name { color: var(--color-text-muted); }
.property-value { font-family: var(--font-mono); font-weight: 600; color: var(--color-text); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dk); border-color: var(--color-primary-dk); }
.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: color-mix(in srgb, var(--color-primary) 8%, transparent); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-danger { background: var(--color-error); color: #fff; }

/* ============================================================
   EXERCISE OVERLAY
   ============================================================ */
.exercise-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.exercise-panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}
.exercise-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.exercise-header h3 { font-size: 1rem; font-weight: 600; flex: 1; }
.exercise-counter { font-size: 0.75rem; color: var(--color-text-muted); background: var(--color-bg); padding: 2px 8px; border-radius: 12px; }
.exercise-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.exercise-statement { font-size: 0.9375rem; line-height: 1.5; }
.exercise-input { display: flex; gap: 8px; }
.exercise-input input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color var(--transition);
}
.exercise-input input:focus { border-color: var(--color-primary); }
.exercise-feedback {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
}
.exercise-feedback.correct { background: color-mix(in srgb, var(--color-success) 12%, transparent); color: color-mix(in srgb, var(--color-success) 80%, #000); border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent); }
.exercise-feedback.close { background: color-mix(in srgb, var(--color-warning) 12%, transparent); color: color-mix(in srgb, var(--color-warning) 80%, #000); border: 1px solid color-mix(in srgb, var(--color-warning) 30%, transparent); }
.exercise-feedback.incorrect { background: color-mix(in srgb, var(--color-error) 12%, transparent); color: color-mix(in srgb, var(--color-error) 80%, #000); border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent); }

.exercise-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.exercise-footer > div:first-of-type { display: flex; gap: 8px; flex-wrap: wrap; }
.hint-text {
  padding: 8px 10px;
  background: color-mix(in srgb, var(--color-warning) 10%, transparent);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--color-text);
  border-left: 3px solid var(--color-warning);
  line-height: 1.4;
}

/* ============================================================
   STEP PANEL
   ============================================================ */
.step-panel {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  min-width: 320px;
  max-width: 480px;
  z-index: 40;
}
.step-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.step-header h4 { font-size: 0.875rem; font-weight: 600; }
.step-counter { font-size: 0.75rem; background: var(--color-bg); padding: 2px 8px; border-radius: 12px; color: var(--color-text-muted); }
.step-description { font-size: 0.875rem; line-height: 1.5; color: var(--color-text); margin-bottom: 10px; }
.step-controls { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--color-text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  pointer-events: auto;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   RESPONSIVE: TABLET (768-1024px)
   ============================================================ */
@media (max-width: 1024px) {
  :root { --panel-w: 240px; }
  .brand-subtitle { display: none; }
}

@media (max-width: 900px) {
  .module-body { flex-direction: column; }
  .info-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border);
    flex-direction: row;
    flex-wrap: wrap;
    max-height: 220px;
    overflow-y: auto;
  }
  .panel-section { flex: 1; min-width: 180px; border-right: 1px solid var(--color-border); border-bottom: none; }
  .canvas-area { min-height: 350px; }
}

/* ============================================================
   RESPONSIVE: MOBILE (<768px)
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }

  .menu-toggle { display: flex; }
  .brand-subtitle { display: none; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100dvh - var(--header-h));
    z-index: 90;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .app-main { width: 100%; }

  .module-header { padding: 8px 12px; }
  .module-title { font-size: 1rem; }
  .module-toolbar { gap: 2px; }

  .home-hero h1 { font-size: 1.375rem; }
  .bloc-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .home-screen { padding: 20px 16px; }

  .info-panel {
    max-height: 200px;
  }

  .exercise-overlay { align-items: flex-end; padding: 0; }
  .exercise-panel { max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

  .step-panel {
    bottom: 0; left: 0; right: 0;
    transform: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    min-width: unset;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .bloc-grid { grid-template-columns: 1fr; }
  .home-info { flex-direction: column; }
}

/* ============================================================
   FOCUS VISIBLE
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================================
   CANVAS-SPECIFIC CURSORS
   ============================================================ */
.canvas-area.dragging { cursor: grabbing; }
.canvas-area.grab { cursor: grab; }
.canvas-area.hovering-point { cursor: move; }
