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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #121214;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

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

/* Sidebar styling */
#sidebar {
  width: 290px;
  min-width: 290px;
  height: 100vh;
  background: #1a1b1e;
  border-right: 1px solid #2e3036;
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.35);
}

#sidebar::-webkit-scrollbar {
  width: 6px;
}
#sidebar::-webkit-scrollbar-track {
  background: #1a1b1e;
}
#sidebar::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}

.header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f8fafc;
}

.header .subtitle {
  font-size: 0.76rem;
  color: #94a3b8;
  margin-top: 2px;
}

.divider {
  border: 0;
  height: 1px;
  background: #2e3036;
  margin: 2px 0;
}

/* Control groups */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  font-weight: 500;
  color: #cbd5e1;
}

.val-text {
  font-family: "SF Mono", Menlo, Consolas, Monaco, monospace;
  font-size: 0.76rem;
  color: #38bdf8;
  font-weight: 600;
}

/* Select dropdown styling */
select {
  width: 100%;
  padding: 6px 8px;
  background: #27272a;
  color: #f1f5f9;
  border: 1px solid #3f3f46;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

select:hover {
  border-color: #52525b;
  background: #2f2f33;
}

select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

select option {
  background: #1a1b1e;
  color: #f1f5f9;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: #334155;
  outline: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

input[type="range"]:hover {
  background: #475569;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 5px rgba(56, 189, 248, 0.5);
  cursor: pointer;
  border: 2px solid #0f172a;
  transition: transform 0.1s ease, background 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #7dd3fc;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 5px rgba(56, 189, 248, 0.5);
  cursor: pointer;
  border: 2px solid #0f172a;
}

/* Info Card */
.info-card {
  background: #111215;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-row strong {
  font-family: "SF Mono", Menlo, Consolas, Monaco, monospace;
  color: #e2e8f0;
}

/* Button Group */
.btn-group {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
}

#copyUrlBtn {
  padding: 8px 12px;
  background: #0284c7;
  color: #f0f9ff;
  border: 1px solid #0369a1;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

#copyUrlBtn:hover {
  background: #0369a1;
  border-color: #075985;
}

#copyUrlBtn:active {
  background: #0c4a6e;
  transform: scale(0.98);
}

#copyUrlBtn.copied {
  background: #15803d;
  border-color: #166534;
  color: #ffffff;
}

#resetBtn {
  padding: 8px 12px;
  background: #27272a;
  color: #cbd5e1;
  border: 1px solid #3f3f46;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#resetBtn:hover {
  background: #3f3f46;
  border-color: #52525b;
}

#resetBtn:active {
  background: #18181b;
}

/* Canvas viewport */
#canvasContainer {
  flex: 1;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background-color: #000;
}

#gratingCanvas {
  display: block;
  width: 100%;
  height: 100%;
}
