* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 12px;
  min-height: 100vh;
  font-family: 'Baloo 2', 'Nunito', 'Comic Sans MS', Arial, sans-serif;
  background: linear-gradient(180deg, #f5f2ff 0%, #e8f3ff 35%, #fff9f3 100%);
  color: #443a78;
}

.app-card {
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  background: #fff;
  border-radius: 28px;
  padding: 10px 20px 10px;
  box-shadow: 0 30px 60px rgba(90, 82, 137, 0.15);
  border: 4px solid #6f7ce6;
  min-height: calc(100vh - 24px);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 50px;
  border-radius: 60px;
  background: linear-gradient(90deg, #fce7fb, #edf2ff);
  border: 2px solid #6f7ce6;
  padding: 0px 16px;
  margin-bottom: 12px;
  max-height: 80px;
}

.header-icon {
  font-size: 22px;
}

.btn-back {
  margin-right: auto;
  padding: 2px 20px;
  border-radius: 24px;
  border: 2px solid #6f7ce6;
  background: #eef0ff;
  color: #4c4f8f;
  font-size: 15px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(111, 124, 230, 0.2);
}

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.header-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.header-text h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 2px;
  color: #4353c3;
}

.subtitle {
  margin: 0;
  font-size: 14px;
  color: #6c7ad6;
  text-align: center;
}

.canvas-section {
      border-radius: 20px;
    border: 3px solid #6f7ce6;
    padding: 5px 14px 5px;
    background: #f9f9ff;
    margin-bottom: 0px;
}

.canvas-stage {
  display: flex;
  gap: 16px;
  align-items: stretch;
  min-height: clamp(420px, 70vh, 640px);
}

.canvas-pane {
  flex: 1;
  min-width: 260px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.canvas-pane h2 {
  margin: 0;
  font-size: 22px;
  color: #4c4f8f;
}

.canvas-pane.drawing-pane,
.canvas-pane.preview-pane {
  height: 100%;
}

.canvas-wrapper {
  flex: 1 1 auto;
  border-radius: 20px;
  border: 2px solid #5c6bc6;
  background: #fff;
  overflow: hidden;
  position: relative;
}

.drawing-pane .canvas-wrapper {
  min-height: 240px;
}

.preview-pane .canvas-wrapper {
  background: #fef9ff;
  border-color: #b19cff;
}

.drawing-controls {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.drawing-controls .full-width {
  grid-column: 1 / -1;
}

.control-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.control-actions .control-card {
  height: 100%;
}

.drawing-controls .control-card {
  width: 100%;
}

.predictions-grid {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.prediction-item {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 4px;
  min-height: 0;
}

.prediction-label {
  font-size: 16px;
  font-weight: 600;
  color: #6c6fad;
  min-width: 52px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  /* border-right: 2px solid #b19cff; */
  padding: 0 4px;
}

.prediction-item .canvas-wrapper {
  flex: 1 1 auto;
  height: 240px !important;
  border-color: #b19cff;
  background: #fef9ff;
  /* border-left: none; */
  border-radius: 10px;
}

#sketch,
#predictionCanvas1,
#predictionCanvas2,
#predictionCanvas3 {
  width: 100%;
  height: 100%;
  display: block;
}

#sketch canvas,
#predictionCanvas1,
#predictionCanvas2,
#predictionCanvas3 {
  width: 100% !important;
  height: 100% !important;
}

.preview-tip {
  margin: 0;
  font-size: 16px;
  color: #6c6fad;
  text-align: center;
}

.control-card {
  flex: 1;
  min-width: 200px;
  background: #f7f7ff;
  border: 3px solid #cad2ff;
  border-radius: 20px;
  padding: 5px 18px;
  box-shadow: inset 0 0 0 2px #fff;
}

.control-card label {
  display: block;
  font-size: 14px;
  margin-bottom: 8px;
  color: #4c4f8f;
}

.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  border-radius: 999px;
  background: #dfe3ff;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #6f7ce6;
  border: 3px solid white;
  box-shadow: 0 4px 8px rgba(111, 124, 230, 0.3);
}

.slider-value {
  min-width: 36px;
  text-align: right;
  font-size: 18px;
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(30px, 1fr));
  gap: 8px;
}

.color-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #4d4d8d;
  background: white;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.color-dot.active {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(111, 124, 230, 0.35);
}

.dot-black { background: #1f1b37; }
.dot-brown { background: #8b5a2b; }
.dot-red { background: #ff6b6b; }
.dot-orange { background: #ffa048; }
.dot-yellow { background: #ffd54f; }
.dot-green { background: #00c48c; }
.dot-lightgreen { background: #b2ff66; }
.dot-cyan { background: #4ed6e6; }
.dot-lightblue { background: #aee7ff; }
.dot-blue { background: #4a6cff; }
.dot-purple { background: #b084f1; }
.dot-pink { background: #ff8ad8; }
.dot-gray { background: #c7c9d9; }
.dot-white { background: #fff; }

.btn-eraser {
  min-width: 140px;
  border: none;
  border-radius: 20px;
  background: #ff8ad8;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(255, 138, 216, 0.3);
  align-self: stretch;
}

.btn-clear {
  min-width: 140px;
  border: none;
  border-radius: 20px;
  background: #6f7ce6;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(111, 124, 230, 0.3);
  align-self: stretch;
}

.model-card select {
  flex: 1;
  border: 3px solid #6f7ce6;
  border-radius: 18px;
  padding: 10px 16px;
  font-size: 14px;
  background: white;
  color: #42436f;
}

.model-card select option {
  color: #42436f;
}

.model-bar {
  display: flex;
  align-items: center;
}

.temperature-card .slider-value {
  font-weight: 700;
  color: #4850a8;
}

@media (max-width: 1100px) {
  .control-actions {
    grid-template-columns: 1fr;
  }

  .btn-eraser {
    width: 100%;
  }

  .drawing-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .canvas-stage {
    flex-direction: column;
    min-height: auto;
  }

  .canvas-wrapper {
    height: 360px;
  }

  .drawing-controls .control-card {
    min-width: auto;
  }
}

@media (max-width: 768px) {
  .app-card {
    padding: 10px;
  }

  .model-bar {
    flex-direction: column;
  }

  .model-card select,
  .btn-random {
    width: 100%;
  }
}
