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

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: "Courier New", Courier, monospace;
  background: #ffffff;
  color: #000000;
  display: flex;
}

/* ---- Sidebar ---- */

#sidebar {
  width: 280px;
  height: 100vh;
  flex-shrink: 0;
  border-right: 1px solid #000000;
  padding: 20px 16px;
  overflow-y: auto;
  background: #ffffff;
  z-index: 100;
  transition:
    margin-left 0.25s ease,
    opacity 0.25s ease;
}

#sidebar.collapsed {
  margin-left: -280px;
  opacity: 0;
  pointer-events: none;
}

/* ---- Sidebar toggle ---- */

#sidebarToggle {
  position: fixed;
  top: 12px;
  left: 264px;
  z-index: 200;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 16px;
  line-height: 22px;
  text-align: center;
  font-family: "Courier New", Courier, monospace;
  background: #ffffff;
  color: #000000;
  border: 1px solid #000000;
  cursor: pointer;
  transition: left 0.25s ease;
}

#sidebarToggle:hover {
  background: #000000;
  color: #ffffff;
}

#sidebar.collapsed ~ #canvas-container #sidebarToggle,
body:has(#sidebar.collapsed) #sidebarToggle {
  left: 12px;
}

#sidebar h1 {
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #000000;
  font-family: "Courier New", Courier, monospace;
}

.section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0e0e0;
}

.section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
  color: #888888;
}

/* ---- Text input ---- */

#wordInput {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  font-family: "Courier New", Courier, monospace;
  border: 1px solid #000000;
  outline: none;
  text-transform: uppercase;
  background: #ffffff;
  color: #000000;
}

#wordInput:focus {
  box-shadow: 0 0 0 1px #000000;
}

.char-info {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  font-size: 10px;
  color: #999999;
}

.char-warning {
  display: none;
  font-size: 11px;
  color: #cc0000;
  margin-top: 4px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.char-warning.visible {
  display: block;
}

/* ---- Buttons ---- */

.button-group {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#generateBtn,
#surpriseBtn,
#exportGifBtn {
  width: 100%;
  padding: 8px 16px;
  font-size: 12px;
  font-family: "Courier New", Courier, monospace;
  background: #000000;
  color: #ffffff;
  border: 1px solid #000000;
  cursor: pointer;
  text-transform: lowercase;
  letter-spacing: 0.5px;
}

#generateBtn:hover,
#surpriseBtn:hover,
#exportGifBtn:hover {
  background: #ffffff;
  color: #000000;
}

#generateBtn:active,
#surpriseBtn:active,
#exportGifBtn:active {
  background: #000000;
  color: #ffffff;
}

#generateBtn:disabled,
#surpriseBtn:disabled,
#exportGifBtn:disabled {
  background: #cccccc;
  color: #666666;
  cursor: not-allowed;
  border-color: #cccccc;
}

/* ---- Selects ---- */

select {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  font-family: "Courier New", Courier, monospace;
  border: 1px solid #000000;
  outline: none;
  background: #ffffff;
  color: #000000;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  padding-right: 28px;
}

select:focus {
  box-shadow: 0 0 0 1px #000000;
}

/* ---- Transform controls ---- */

.transform-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.transform-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888888;
  width: 36px;
  flex-shrink: 0;
}

.transform-row input[type="range"] {
  flex: 1;
  height: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: #000000;
  outline: none;
  cursor: pointer;
}

.transform-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  background: #000000;
  border-radius: 0;
  cursor: pointer;
}

.transform-num {
  width: 48px;
  padding: 3px 4px;
  font-size: 11px;
  font-family: "Courier New", Courier, monospace;
  border: 1px solid #000000;
  outline: none;
  text-align: right;
  background: #ffffff;
  color: #000000;
}

.transform-num:focus {
  box-shadow: 0 0 0 1px #000000;
}

.transform-presets {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.preset-btn {
  flex: 1;
  min-width: 0;
  padding: 5px 0;
  font-size: 10px;
  font-family: "Courier New", Courier, monospace;
  background: #ffffff;
  color: #000000;
  border: 1px solid #000000;
  cursor: pointer;
  text-transform: lowercase;
  letter-spacing: 0.3px;
}

.preset-btn:hover {
  background: #000000;
  color: #ffffff;
}

/* ---- Spin toggle ---- */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.toggle-label {
  display: inline;
  margin-bottom: 0;
}

#spinToggle {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 16px;
  background: #dddddd;
  border: 1px solid #000000;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

#spinToggle::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  background: #000000;
  border-radius: 50%;
  transition: left 0.2s ease;
}

#spinToggle:checked {
  background: #000000;
}

#spinToggle:checked::after {
  left: 17px;
  background: #ffffff;
}

/* ---- Controls info ---- */

.controls-section {
  font-size: 10px;
  line-height: 1.7;
  color: #888888;
}

.controls-section p {
  margin-bottom: 8px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.shortcut-row span {
  font-size: 10px;
  color: #888888;
  margin-right: 6px;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  font-size: 10px;
  font-family: "Courier New", Courier, monospace;
  font-weight: bold;
  color: #000000;
  background: #f5f5f5;
  border: 1px solid #cccccc;
  border-radius: 4px;
  box-shadow: 0 1px 0 #bbbbbb;
  text-align: center;
  line-height: 1.4;
}

/* ---- Bottom bar ---- */

.bottom-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  background: #ffffff;
  border: 1px solid #000000;
  font-family: "Courier New", Courier, monospace;
  font-size: 10px;
  color: #888888;
  white-space: nowrap;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.bottom-bar.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.bottom-bar span {
  margin-right: 2px;
}

.bottom-bar-hint {
  color: #888888;
  margin-right: 10px;
}

.bottom-bar-sep {
  width: 1px;
  height: 14px;
  background: #dddddd;
  margin: 0 6px;
}

.bottom-bar-close {
  background: none;
  border: none;
  font-size: 14px;
  line-height: 1;
  color: #999999;
  cursor: pointer;
  padding: 0 4px 0 0;
  margin-right: 6px;
  font-family: "Courier New", Courier, monospace;
}

.bottom-bar-close:hover {
  color: #000000;
}

/* ---- Canvas ---- */

#canvas-container {
  flex: 1;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

canvas {
  display: block;
}
