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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
  color: #eee;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

#app {
  text-align: center;
}

.header-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  position: relative;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  color: #fff;
}

.github-link {
  color: #fff;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  text-decoration: none;
  opacity: 0.8;
}

.github-link:hover {
  opacity: 1;
  color: #667eea;
  transform: scale(1.1);
}

.github-link svg {
  width: 28px;
  height: 28px;
}

#controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

button {
  padding: 10px 10px;
  background: #4a5568;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s ease;
}

button:hover {
  background: #5a6578;
}

button:active {
  background: #3a4558;
}

label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

input[type="range"] {
  width: 100px;
  cursor: pointer;
}

input[type="color"] {
  width: 50px;
  height: 30px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#canvas-container {
  display: inline-block;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border-radius: 5px;
  overflow: hidden;
}

#drawing-tools {
  display: flex;
  gap: 5px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
}

#edit-tools {
  display: flex;
  gap: 5px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
}

.tool-btn {
  padding: 8px 10px;
  background: #4a5568;
  color: white;
  border: 2px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.tool-btn:hover {
  background: #5a6578;
}

.tool-btn.active {
  background: #667eea;
  border-color: #5568d3;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

/* ========================================
   ICONS
   ======================================== */

.feather {
  width: 20px;
  height: 20px;
}

.icon {
  width: 15px;
  height: 15px;
  vertical-align: middle;
  filter: brightness(0) invert(1);
  /* Makes the icon white */
}

.fill-icon {
  opacity: 0.7;
  position: relative;
}

.fill-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg,
      transparent,
      transparent 2px,
      currentColor 2px,
      currentColor 3px);
  opacity: 0.3;
  pointer-events: none;
}

.tool-btn.active .fill-icon::after {
  opacity: 0.5;
}

/* ========================================
   HELP MODAL
   ======================================== */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.8);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  margin: 3% auto;
  padding: 30px;
  border: 2px solid #667eea;
  border-radius: 15px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 50px rgba(102, 126, 234, 0.3);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h2 {
  color: #fff;
  margin-bottom: 25px;
  font-size: 2rem;
  text-align: center;
  border-bottom: 2px solid #667eea;
  padding-bottom: 15px;
}

.modal-content h3 {
  color: #667eea;
  margin-top: 25px;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.help-section {
  margin-bottom: 20px;
}

.help-section ul {
  list-style: none;
  padding-left: 0;
}

.help-section li {
  padding: 8px 0;
  padding-left: 20px;
  position: relative;
  line-height: 1.6;
}

.help-section li:before {
  content: "▹";
  position: absolute;
  left: 0;
  color: #667eea;
  font-weight: bold;
}

.help-section strong {
  color: #a5b4fc;
}

.help-section p {
  margin-bottom: 10px;
  line-height: 1.6;
}

.help-tip {
  margin-top: 30px;
  padding: 15px;
  background: rgba(102, 126, 234, 0.1);
  border-left: 4px solid #667eea;
  border-radius: 5px;
  line-height: 1.6;
}

.close {
  color: #aaa;
  float: right;
  font-size: 32px;
  font-weight: bold;
  line-height: 20px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.close:hover,
.close:focus {
  color: #667eea;
}

/* Scrollbar styling for modal */
.modal-content::-webkit-scrollbar {
  width: 10px;
}

.modal-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: #5568d3;
}

/* Gap ratio controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
}

.control-label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.radio-group {
  display: flex;
  gap: 15px;
  align-items: center;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 14px;
}

.radio-label input[type="radio"] {
  cursor: pointer;
}

#customGapControl {
  margin-top: 8px;
}

#customGapControl.hidden {
  display: none;
}

#gapRatioValue {
  display: inline-block;
  min-width: 40px;
  font-weight: 500;
  color: #667eea;
}

/* ========================================
   AUTHENTIC SASHIKO MODE (Phase 1.1)
   ======================================== */

.settings-btn {
  background: rgba(102, 126, 234, 0.15);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

.settings-btn:hover {
  background: rgba(102, 126, 234, 0.25);
  border-color: #667eea;
  transform: translateY(-1px);
}

.settings-btn .icon {
  width: 18px;
  height: 18px;
  filter: invert(1);
}

.help-text {
  font-size: 0.85em;
  opacity: 0.7;
  font-style: italic;
  margin: 4px 0;
  line-height: 1.4;
}

.modal-intro {
  font-size: 1em;
  line-height: 1.6;
  opacity: 0.9;
  margin-bottom: 10px;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}

.slider-control input[type="range"] {
  flex: 1;
}

.param-info {
  font-size: 0.85em;
  opacity: 0.7;
  margin: 4px 0;
  font-style: italic;
  color: #aaa;
}

.param-detail {
  font-size: 0.9em;
  line-height: 1.5;
  opacity: 0.8;
  margin-top: 8px;
}

.value-display {
  display: inline-block;
  min-width: 80px;
  font-weight: 600;
  color: #667eea;
  background: rgba(102, 126, 234, 0.15);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.95em;
  text-align: center;
}

.auto-params-list {
  margin-top: 12px;
}

.auto-params-list li {
  margin-bottom: 12px;
  line-height: 1.6;
}

.param-note {
  display: block;
  font-size: 0.85em;
  opacity: 0.6;
  font-style: italic;
  margin-top: 4px;
  padding-left: 20px;
}

.verification-list {
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  opacity: 0.85;
  line-height: 1.8;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 4px;
  margin-top: 10px;
}