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

body {
  min-height: 100vh;
  background: #f5f5f7;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue',
    Arial, sans-serif;
  padding: 16px;
}

button {
  border: 0;
  outline: 0;
  font-family: inherit;
}

/* ===== Container ===== */
.container {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.container h2.title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1d1d1f;
  margin-bottom: 28px;
  letter-spacing: -0.02em;
}

/* ===== Result Area ===== */
.result {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

.result__viewbox {
  width: 100%;
  padding: 16px;
  background: #f5f5f7;
  border-radius: 12px;
  color: #1d1d1f;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 1.05rem;
  text-align: center;
  min-height: 56px;
  line-height: 1.5;
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: all;
  cursor: pointer;
}

.copy-feedback {
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: #1d1d1f;
  background: #e8e8ed;
  padding: 3px 10px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  white-space: nowrap;
}

.copy-feedback.show {
  opacity: 1;
}

/* ===== Field Title ===== */
.field-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

/* ===== Length Slider ===== */
.range__slider {
  position: relative;
  padding: 20px 16px 20px;
  background: #f5f5f7;
  border-radius: 12px;
  margin: 20px 0 24px;
}

.range__slider .length__title {
  font-size: 0.85rem;
  color: #1d1d1f;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.range__slider .length__title::after {
  content: attr(data-length);
  font-weight: 600;
  color: #1d1d1f;
  margin-left: 2px;
}

#slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #d2d2d7;
  outline: none;
  margin-top: 14px;
  cursor: pointer;
}

#slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1d1d1f;
  cursor: pointer;
  transition: all 150ms ease;
}

#slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

#slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #1d1d1f;
  cursor: pointer;
}

/* ===== Settings / Toggles ===== */
.settings {
  position: relative;
  margin-bottom: 24px;
}

.settings .setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid #e8e8ed;
}

.settings .setting:last-child {
  border-bottom: none;
}

.settings .setting label {
  font-size: 0.9rem;
  color: #1d1d1f;
  cursor: pointer;
  user-select: none;
}

/* Hidden native checkbox */
.settings .setting input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Label takes full width, acts as row */
.settings .setting input[type="checkbox"] + label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* Track */
.settings .setting input[type="checkbox"] + label::after {
  content: "";
  width: 44px;
  height: 24px;
  background: #e8e8ed;
  border-radius: 12px;
  transition: background 200ms ease;
  flex-shrink: 0;
}

/* Thumb */
.settings .setting input[type="checkbox"] + label::before {
  content: "";
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  transition: right 200ms ease;
  z-index: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Checked: track dark */
.settings .setting input[type="checkbox"]:checked + label::after {
  background: #1d1d1f;
}

/* Checked: thumb slides right */
.settings .setting input[type="checkbox"]:checked + label::before {
  right: 4px;
}

/* ===== Generate Button ===== */
.btn.generate {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: #1d1d1f;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: none;
  cursor: pointer;
  transition: all 200ms ease;
}

.btn.generate:hover {
  background: #2d2d2f;
}

.btn.generate:active {
  transform: scale(0.98);
  background: #3d3d3f;
}

/* ===== History ===== */
.history {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
}

.history-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: #86868b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 150ms ease;
}

.history-btn:hover {
  background: #f5f5f7;
  color: #1d1d1f;
}

.history-panel {
  position: absolute;
  top: 40px;
  right: 0;
  width: 260px;
  max-height: 300px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid #e8e8ed;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 200ms ease;
}

.history-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #1d1d1f;
  border-bottom: 1px solid #e8e8ed;
}

.history-clear {
  font-size: 0.7rem;
  color: #86868b;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.history-clear:hover {
  color: #1d1d1f;
  background: #f5f5f7;
}

.history-list {
  list-style: none;
  padding: 6px 0;
  max-height: 220px;
  overflow-y: auto;
}

.history-list li {
  padding: 8px 16px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 0.8rem;
  color: #1d1d1f;
  cursor: pointer;
  transition: background 150ms ease;
  word-break: break-all;
}

.history-list li:hover {
  background: #f5f5f7;
}

.history-list li:active {
  background: #e8e8ed;
}

.history-empty {
  color: #86868b !important;
  cursor: default !important;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif !important;
  text-align: center;
  padding: 20px 16px !important;
}

.history-list li.history-empty:hover {
  background: transparent !important;
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  .container {
    padding: 28px 20px;
    border-radius: 16px;
  }

  .container h2.title {
    font-size: 1.3rem;
    margin-bottom: 24px;
  }

  .result__viewbox {
    font-size: 0.95rem;
    padding: 14px;
  }

  .range__slider {
    padding: 16px 14px 16px;
  }

  .btn.generate {
    padding: 13px;
  }
}
