:root {
  color-scheme: dark;
  --bg: #070b14;
  --panel: #0f1524;
  --panel-2: #151d2f;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f7fb;
  --muted: #8f9bb3;
  --accent: #5c8dff;
  --accent-strong: #78a5ff;
  --danger: #ff7d85;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.24);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 22, 0.94);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  border: 1px solid rgba(122, 166, 255, 0.35);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(91, 140, 255, 0.2), rgba(91, 140, 255, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark svg {
  width: 29px;
  fill: none;
  stroke: #8bb0ff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.button,
.tool-button,
.view-button,
.icon-button {
  border: 0;
  cursor: pointer;
  transition: 0.18s ease;
}

.button {
  height: 40px;
  padding: 0 15px;
  border-radius: 11px;
  font-weight: 700;
  font-size: 13px;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  box-shadow: 0 10px 25px rgba(92, 141, 255, 0.24);
}

.button-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.button-ghost {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.button-ghost:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.workspace {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: #0c111e;
  scrollbar-width: thin;
  scrollbar-color: #29334a transparent;
}

.panel-section {
  padding: 15px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.038), rgba(255, 255, 255, 0.015));
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #dbe4f4;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.icon-button:hover:not(:disabled) {
  background: rgba(255, 125, 133, 0.12);
  color: var(--danger);
}

.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 11px;
  background: rgba(92, 141, 255, 0.15);
  color: #9cbbff;
  font-size: 12px;
  font-weight: 900;
}

.file-info {
  min-width: 0;
}

.file-info strong,
.file-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info strong {
  font-size: 13px;
}

.file-info span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.control-grid {
  display: grid;
  gap: 8px;
}

.two-columns {
  grid-template-columns: 1fr 1fr;
}

.tool-button,
.view-button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.tool-button:hover,
.view-button:hover,
.tool-button.active,
.view-button.active {
  border-color: rgba(92, 141, 255, 0.45);
  background: rgba(92, 141, 255, 0.13);
  color: #dce7ff;
}

.field-label {
  display: block;
  margin: 15px 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.color-control {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.color-control input[type="color"] {
  width: 35px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
}

.color-control input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-control input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 7px;
}

.color-control span {
  color: #cfd8e8;
  font-size: 11px;
  font-weight: 700;
}

.view-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.toggle-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  cursor: pointer;
  color: #cbd5e5;
  font-size: 12px;
}

.toggle-row + .toggle-row {
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.toggle-row input {
  position: absolute;
  top: 50%;
  right: 0;
  width: 34px;
  height: 19px;
  margin: 0;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
}

.toggle-row i {
  position: relative;
  flex: 0 0 34px;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: #283249;
  transition: 0.18s ease;
}

.toggle-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #a9b4c8;
  transition: 0.18s ease;
}

.toggle-row input:checked + i {
  background: rgba(92, 141, 255, 0.72);
}

.toggle-row input:checked + i::after {
  left: 18px;
  background: white;
}

.toggle-row input:focus-visible + i {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

.dimension-grid {
  display: grid;
  gap: 8px;
}

.dimension-grid > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.dimension-grid span {
  color: var(--muted);
  font-size: 10px;
}

.dimension-grid strong {
  color: #e7eef9;
  font-size: 11px;
}

.viewer-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(53, 75, 130, 0.15), transparent 42%),
    #0b1020;
}

.canvas-container {
  position: absolute;
  inset: 0;
}

.canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.drop-overlay,
.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  transition: 0.22s ease;
}

.drop-overlay {
  z-index: 5;
}

.drop-overlay.dragging {
  background: rgba(92, 141, 255, 0.08);
}

.drop-overlay.dragging .drop-card {
  transform: scale(1.015);
  border-color: rgba(92, 141, 255, 0.65);
  background: rgba(21, 29, 47, 0.92);
}

.drop-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.drop-card {
  width: min(500px, 100%);
  padding: 34px;
  border: 1px dashed rgba(153, 178, 230, 0.28);
  border-radius: 22px;
  background: rgba(15, 21, 36, 0.74);
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(14px);
  transition: 0.22s ease;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  background: rgba(92, 141, 255, 0.14);
}

.drop-icon svg {
  width: 37px;
  fill: none;
  stroke: #93b5ff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-card h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 27px);
  letter-spacing: -0.035em;
}

.drop-card > p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.format-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 18px;
}

.format-list span {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: #bac7dc;
  font-size: 10px;
  font-weight: 850;
}

.drop-card .privacy-note {
  margin-top: 20px;
  color: #6f7c94;
  font-size: 10px;
}

.loading-overlay {
  z-index: 8;
  gap: 12px;
  align-content: center;
  background: rgba(7, 11, 20, 0.72);
  backdrop-filter: blur(8px);
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #83a9ff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.loading-overlay strong {
  font-size: 13px;
}

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

.viewer-hint,
.status-pill {
  position: absolute;
  z-index: 4;
  border: 1px solid var(--border);
  background: rgba(10, 15, 27, 0.75);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.viewer-hint {
  left: 50%;
  bottom: 15px;
  display: flex;
  gap: 16px;
  padding: 9px 13px;
  transform: translateX(-50%);
  border-radius: 11px;
  color: #8d99ae;
  font-size: 10px;
  white-space: nowrap;
}

.status-pill {
  right: 14px;
  bottom: 14px;
  padding: 8px 11px;
  border-radius: 999px;
  color: #9aa7bd;
  font-size: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  top: 92px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 15px;
  transform: translateY(-10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.95);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  color: #e8edf7;
  font-size: 12px;
  transition: 0.22s ease;
}

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

.toast.error {
  border-color: rgba(255, 125, 133, 0.35);
  color: #ffd1d4;
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: 100%;
    overflow: visible;
    grid-template-rows: auto auto;
  }

  .topbar {
    align-items: flex-start;
    padding: 14px;
  }

  .brand p,
  .button-ghost {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 70vh);
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .panel-section {
    margin-bottom: 0;
  }

  .viewer-panel {
    min-height: 520px;
  }

  .viewer-hint {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 10px;
  }

  .brand-mark {
    display: none;
  }

  .brand h1 {
    font-size: 15px;
  }

  .button {
    padding: 0 11px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }
}

/* Seleção de componentes e modo de desenho técnico */
.technical-options {
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.022);
}

.range-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.range-heading strong {
  color: #dce7ff;
  font-size: 10px;
}

.technical-options input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.technical-options small {
  display: block;
  margin-top: 7px;
  color: #748198;
  font-size: 9px;
  line-height: 1.4;
}

.selection-section {
  position: relative;
  overflow: hidden;
}

.selection-section::after {
  content: "";
  position: absolute;
  right: -32px;
  bottom: -48px;
  width: 105px;
  height: 105px;
  border-radius: 50%;
  background: rgba(255, 148, 50, 0.07);
  pointer-events: none;
}

.selection-clear {
  position: relative;
  z-index: 1;
  padding: 4px 7px;
  border: 1px solid rgba(255, 159, 67, 0.22);
  border-radius: 7px;
  background: rgba(255, 159, 67, 0.08);
  color: #ffbd7b;
  font-size: 9px;
  font-weight: 800;
  cursor: pointer;
}

.selection-clear:hover:not(:disabled) {
  border-color: rgba(255, 159, 67, 0.45);
  background: rgba(255, 159, 67, 0.14);
}

.selection-card {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.selection-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  flex: 0 0 39px;
  border: 1px solid rgba(255, 159, 67, 0.22);
  border-radius: 11px;
  background: rgba(255, 159, 67, 0.10);
  color: #ffad5d;
  font-size: 18px;
}

.selection-info {
  min-width: 0;
}

.selection-info strong,
.selection-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selection-info strong {
  color: #f2f5fb;
  font-size: 12px;
  white-space: nowrap;
}

.selection-info span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.canvas-container canvas {
  cursor: grab;
}

.canvas-container canvas:active {
  cursor: grabbing;
}


/* Contornos técnicos v2 */
.technical-title {
  margin-bottom: 10px;
  color: #dce7ff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.technical-control-gap {
  margin-top: 13px;
}

.technical-options input[type="range"]:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.technical-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  margin-top: 9px;
  color: #aab6ca;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.technical-toggle-row + .technical-toggle-row {
  margin-top: 2px;
}

.technical-toggle-row input {
  position: static;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Motor de contornos CAD V3 */
.version-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  padding: 2px 6px;
  border: 1px solid rgba(92, 141, 255, 0.28);
  border-radius: 999px;
  background: rgba(92, 141, 255, 0.11);
  color: #9ebcff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.technical-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.technical-title-row .technical-title {
  margin-bottom: 2px;
}

.technical-title-row small {
  margin-top: 0;
  max-width: 130px;
}

.preset-select {
  min-width: 104px;
  max-width: 120px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  outline: none;
  background: #121a2b;
  color: #dce7ff;
  font: inherit;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.preset-select:focus-visible {
  border-color: rgba(92, 141, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(92, 141, 255, 0.16);
}


/* Modo técnico automático: não há controles manuais de contorno. */
.mode-note {
  margin: 12px 2px 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* Lista da seleção múltipla */
.selection-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
  max-height: 150px;
  margin-top: 11px;
  overflow-y: auto;
  padding-right: 2px;
}

.selection-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 29px;
  padding: 5px 6px 5px 9px;
  border: 1px solid rgba(255, 159, 67, 0.16);
  border-radius: 8px;
  background: rgba(255, 159, 67, 0.055);
}

.selection-list-item span {
  min-width: 0;
  overflow: hidden;
  color: #e5e9f1;
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-list-item button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 159, 67, 0.12);
  color: #ffc087;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.selection-list-item button:hover {
  background: rgba(255, 159, 67, 0.23);
  color: white;
}

