* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background-color: #121926;
}

/* TOP HEADER BAR */
#top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background-color: #0f172a;
  display: flex;
  align-items: center;
  padding: 0 10px;
  z-index: 100;
  border-bottom: 1px solid #1e293b;
}

.header-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.header-btn:hover {
  background-color: #1e293b;
}

#file-input {
  display: none;
}

/* SIDEBAR DỌC */
#sidebar {
  position: absolute;
  top: 50px;
  left: 0;
  width: 60px;
  height: calc(100% - 50px);
  background-color: #0f172a;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
  gap: 10px;
  z-index: 90;
  transition: transform 0.3s ease;
  border-right: 1px solid #1e293b;
}

#sidebar.sidebar-hidden {
  transform: translateX(-100%);
}

.sidebar-btn {
  width: 44px;
  height: 44px;
  background-color: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
  border-radius: 4px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}


.sidebar-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: #1e293b;
}

.sidebar-btn:not(:disabled):hover {
  background-color: #334155;
  color: #ffffff;
}

/* VIEWPORT & CANVAS */
#viewport {
  position: absolute;
  top: 50px;
  left: 0;
  width: 100%;
  height: calc(100% - 50px);
}

#canvas-container {
  width: 100%;
  height: 100%;
}

/* BẢNG CHỌN MÀU OVERLAY */
.dialog-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.dialog-overlay.active {
  display: flex;
}

.ps-dialog {
  background: #ffffff;
  padding: 15px;
  border-radius: 8px;
  width: 260px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.ps-picker-area {
  display: flex;
  gap: 10px;
  height: 150px;
  margin-bottom: 12px;
}

#sat-val-box {
  flex: 1;
  position: relative;
  background-color: red;
  cursor: crosshair;
}

.sat-val-white {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #fff, rgba(255,255,255,0));
}

.sat-val-black {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #000, rgba(0,0,0,0));
}

#sat-val-cursor {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#hue-bar {
  width: 20px;
  position: relative;
  background: linear-gradient(to bottom, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
  cursor: pointer;
}

#hue-cursor {
  position: absolute;
  width: 100%;
  height: 4px;
  background: #fff;
  border: 1px solid #000;
  transform: translateY(-50%);
  pointer-events: none;
}

.ps-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.ps-preview-box {
  width: 40px;
  height: 30px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.ps-hex-group {
  display: flex;
  align-items: center;
  border: 1px solid #ccc;
  padding: 4px 8px;
  border-radius: 4px;
  flex: 1;
}

#val-hex {
  border: none;
  outline: none;
  width: 100%;
  margin-left: 4px;
  font-weight: bold;
}

.ps-action-btns {
  display: flex;
  gap: 8px;
}

.ps-btn {
  flex: 1;
  padding: 6px;
  border: 1px solid #ccc;
  background: #f1f5f9;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.ps-btn:hover {
  background: #e2e8f0;
}