@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
/* to optimise and clean the code period */
:root {
  --bg: #f9f8f5;
  --surface: #f3f2ee;
  --surface-alt: #eceae5;
  --border: #e0deda;
  --border-strong: #c4c2bc;
  --text: #111111;
  --text-muted: #666660;
  --text-subtle: #aaa9a2;
  --btn-bg: #eceae5;
  --btn-hover: #e2e0da;
  --input-bg: #f0eeea;
  --active-bg: #111111;
  --active-text: #f9f8f5;
  --accent: #1a7a4a;
  --radius: 4px;
  --radius-sm: 3px;
}

[data-theme="dark"] {
  --bg: #111111;
  --surface: #1a1a1a;
  --surface-alt: #1e1e1e;
  --border: #2a2a2a;
  --border-strong: #404040;
  --text: #d8d8d5;
  --text-muted: #888884;
  --text-subtle: #555552;
  --btn-bg: #222222;
  --btn-hover: #2c2c2c;
  --input-bg: #1e1e1e;
  --active-bg: #d8d8d5;
  --active-text: #111111;
  --accent: #3dc87a;
}

html {
  font-size: 14px;
}

body {
  font-family: 'Google Sans Flex', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

site-header,
site-footer { display: contents; }

.site-header {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0 1.5rem;
  height: 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-logo {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 0.25rem;
}

.site-logo:hover {
  color: var(--accent);
  opacity: 0.85;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  flex: 1;
}

.nav-link {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.1rem 0.25rem;
  transition: color 0.1s;
}

.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 500; }
.nav-link.soon   { color: var(--text-subtle); pointer-events: none; }

.nav-sep {
  color: var(--text-subtle);
  font-size: 0.8rem;
  padding: 0 0.4rem;
  user-select: none;
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.25rem;
  line-height: 1;
  transition: color 0.1s;
  margin-left: auto;
  flex-shrink: 0;
}

.theme-toggle:hover { color: var(--text-muted); }

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.page-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.page-desc a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.page-desc a:hover { color: var(--text); }

.tool-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  align-items: start;
}

.tool-output {
  position: sticky;
  top: 52px;
}

.panel-header {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-subtle);
  margin-bottom: 0.625rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

textarea.text-input {
  min-height: 70px;
  resize: none;
}

.section-label  { font-size: 0.75rem; color: var(--text-muted); }
.unit           { font-size: 0.75rem; color: var(--text-subtle); }
.slider-label   { font-size: 0.75rem; color: var(--text-muted); }
.slider-label span:last-child { font-family: 'JetBrains Mono', 'Courier New', monospace; color: var(--text-subtle); }
.divider        { height: 1px; background: var(--border); }

.ctrl-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 40px;
}

.toggle-group {
  display: flex;
  background: var(--input-bg);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.toggle-btn {
  flex: 1;
  padding: 0.3125rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.1s, color 0.1s;
  touch-action: manipulation;
}

.toggle-btn:hover { color: var(--text); }

.toggle-btn.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
}

.options-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.options-grid.cols-4,
.direction-grid { grid-template-columns: repeat(4, 1fr); }

.option-btn {
  padding: 0.5rem 0.25rem;
  background: var(--btn-bg);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.775rem;
  text-align: center;
  transition: background 0.1s, color 0.1s;
  touch-action: manipulation;
  user-select: none;
}

.option-btn:hover { background: var(--btn-hover); color: var(--text); }
.option-btn.selected { background: var(--active-bg); color: var(--active-text); }

.direction-btn {
  padding: 0.375rem;
  background: var(--btn-bg);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  text-align: center;
  transition: background 0.1s, color 0.1s;
  touch-action: manipulation;
}

.direction-btn:hover { background: var(--btn-hover); color: var(--text); }
.direction-btn.selected { background: var(--active-bg); color: var(--active-text); }

.font-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.25rem;
  max-height: 175px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.font-option {
  padding: 0.3125rem 0.5rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s, color 0.1s;
}

.font-option:hover { background: var(--btn-bg); color: var(--text); }
.font-option.selected { background: var(--active-bg); color: var(--active-text); font-weight: 500; }

.text-input,
.hex-input,
.number-input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
}

.text-input:focus,
.hex-input:focus,
.number-input:focus {
  outline: none;
  border-color: var(--border-strong);
}

.text-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  resize: vertical;
  min-height: 64px;
  transition: border-color 0.1s;
  line-height: 1.5;
}

.text-input::placeholder { color: var(--text-subtle); }

.hex-input {
  width: 72px;
  padding: 0.375rem 0.5rem;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.75rem;
}

.number-input {
  width: 65px;
  padding: 0.375rem 0.5rem;
  font-size: 0.8rem;
  text-align: center;
}

select.number-input {
  cursor: pointer;
  text-align: left;
  width: 90px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

select.number-input option {
  background: var(--input-bg);
  color: var(--text);
}

.color-picker {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  padding: 2px;
}

.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border: none; border-radius: 2px; }

.slider {
  width: 100%;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-strong);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--text);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.checkbox-group input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-group label {
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}

.collapsible-settings {
  border-top: 1px solid var(--border);
  display: none;
}

.collapsible-settings.visible { display: block; }

.preview-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 120px;
  max-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  margin-bottom: 0.625rem;
  overflow: hidden;
}

#previewContent {
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#previewContent svg { max-width: 100%; overflow: hidden; }

.code-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.7rem;
  line-height: 1.6;
  max-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-muted);
}

.copy-btn {
  width: 100%;
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
  background: var(--active-bg);
  border: none;
  border-radius: var(--radius);
  color: var(--active-text);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.1s;
  touch-action: manipulation;
}

.copy-btn:hover { opacity: 0.82; }
.copy-btn.copied { opacity: 0.55; }

.color-stop {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.375rem;
}

.color-stop input[type="color"] {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  background: none;
  padding: 0;
}

.color-stop input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-stop input[type="color"]::-webkit-color-swatch { border: 1px solid var(--border); border-radius: 2px; }

.color-hex {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.675rem;
  color: var(--text-subtle);
}

.remove-btn {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1;
  padding: 0 0.1rem;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
}

.color-stop:hover .remove-btn { opacity: 1; }
.remove-btn:hover { color: #b94040; }

.add-color-btn {
  width: 30px;
  height: 30px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-subtle);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s;
}

.add-color-btn:hover { border-color: var(--border-strong); color: var(--text-muted); }

.preview-area.preview-widget { background: #ffffff; }
[data-theme="dark"] .preview-area.preview-widget { background: var(--surface); }

.gradient-bar {
  height: 4px;
  border-radius: 2px;
  margin-top: 0.625rem;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.preset-btn {
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.1s, transform 0.1s;
}

.preset-btn:hover { border-color: var(--border-strong); transform: scale(1.04); }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 1.25rem 0 1.5rem;
  font-size: 0.78rem;
  color: var(--text-subtle);
  text-align: center;
  line-height: 1.7;
}

.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

.nav-dropdown-btn {
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.1rem 0.4rem 0.1rem 0.25rem;
  line-height: 1;
}

.nav-dropdown-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.nav-dropdown-item {
  display: block;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.1s, background 0.1s;
}

.nav-dropdown-item:hover { color: var(--text); background: var(--btn-hover); }
.nav-dropdown-item.active { color: var(--text); font-weight: 500; }

@media (max-width: 1024px) {
  .tool-layout { grid-template-columns: 1fr; }
  .tool-output  { position: static; }
}

@media (max-width: 640px) {
  .page { padding: 1rem; }

  .site-header { padding: 0 0.75rem; }

  .controls-grid { grid-template-columns: 1fr; }

  .option-btn   { padding: 0.625rem 0.375rem; font-size: 0.8rem; }
  .toggle-btn   { padding: 0.5rem 0.625rem; }
  .direction-btn { padding: 0.5rem; }
  .copy-btn     { padding: 1.2rem; font-size: 1rem; }

  .options-grid.cols-4,
  .direction-grid { grid-template-columns: repeat(2, 1fr); }

  .presets-grid { grid-template-columns: repeat(3, 1fr); }

  .preview-area { overflow: hidden; }
  .preview-area svg,
  .preview-area > * { max-width: 100%; }
}
