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

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e4e4e7;
  --border-hover: #a1a1aa;
  --text: #09090b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --primary: #18181b;
  --primary-hover: #27272a;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --ring: 0 0 0 3px rgba(24,24,27,0.06);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* ── Header ─────────────────────────────────── */

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.logo svg { opacity: 0.5; }

header h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: var(--text);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.5rem;
  font-weight: 400;
}

/* ── Tool Card ──────────────────────────────── */

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

/* ── Input ───────────────────────────────────── */

.input-section {
  margin-bottom: 1.75rem;
}

.input-section > label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-wrap {
  position: relative;
}

.input-section input[type="text"] {
  width: 100%;
  padding: 0.65rem 2.2rem 0.65rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-section input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.input-section input[type="text"]::placeholder {
  color: var(--text-muted);
}

.input-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}

.input-clear.visible {
  display: flex;
}

.input-clear:hover {
  color: var(--text);
  background: var(--bg);
}


/* ── History ─────────────────────────────────── */

.history {
  margin-top: 0.65rem;
  display: none;
}

.history.visible { display: block; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.history-header span {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.history-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 0.55rem;
  color: var(--text-muted);
  cursor: help;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  position: relative;
}

.history-info::after {
  content: "Saved in your browser only. Nothing is sent to any server.";
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  padding: 0.35rem 0.55rem;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 10;
}

.history-info:hover::after { opacity: 1; }

@media (max-width: 600px) {
  .history-info::after {
    white-space: normal;
    width: 200px;
    left: 0;
    top: calc(100% + 6px);
    transform: none;
  }
}

.history-clear {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s;
}

.history-clear:hover { color: var(--text-secondary); }

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.history-item {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s;
}

.history-item:hover {
  border-color: var(--border-hover);
}

.history-label {
  padding: 0.2rem 0 0.2rem 0.65rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  transition: color 0.15s;
}

.history-label:hover { color: var(--text); }

.history-del {
  padding: 0.2rem 0.5rem 0.2rem 0.3rem;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}

.history-del:hover { color: var(--text); }

/* ── Workspace ───────────────────────────────── */

.workspace {
  display: flex;
  gap: 1.75rem;
  align-items: flex-start;
}

/* ── Preview ─────────────────────────────────── */

.preview-area {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.preview-bg {
  width: 260px;
  height: 260px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.preview-bg.checkerboard {
  background: repeating-conic-gradient(#e4e4e7 0% 25%, #f4f4f5 0% 50%) 0 0 / 14px 14px;
}

.preview-bg img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  image-rendering: pixelated;
}

.preview-bg img[src=""] { display: none; }

.preview-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  transition: opacity 0.2s;
}

.preview-hint.hidden {
  opacity: 0;
  height: 0;
  overflow: hidden;
}

/* ── Options ─────────────────────────────────── */

.options-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.option-group > label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.label-value {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

/* Color pickers */
.color-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

input[type="color"] {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s;
  flex-shrink: 0;
}

input[type="color"]:hover { border-color: var(--border-hover); }

.hex-prefix {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: "SF Mono", Monaco, "Cascadia Code", "Fira Code", monospace;
  user-select: none;
}

.hex-input {
  width: 64px;
  padding: 0.3rem 0.4rem;
  font-size: 0.82rem;
  font-family: "SF Mono", Monaco, "Cascadia Code", "Fira Code", monospace;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.hex-input:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

/* Checkbox */
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.45rem;
  font-weight: 400 !important;
  font-size: 0.85rem !important;
  color: var(--text) !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Radio group */
.radio-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.radio-label {
  flex: 1;
  text-align: center;
  padding: 0.3rem 0;
  font-size: 0.78rem;
  font-weight: 600 !important;
  color: var(--text) !important;
  text-transform: none !important;
  letter-spacing: 0.02em !important;
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.radio-label:last-child { border-right: none; }
.radio-label:hover { background: var(--bg); }

.radio-label:has(input:checked) {
  background: var(--primary);
  color: #fff !important;
}

.radio-label input[type="radio"] { display: none; }

/* Sliders */
input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Buttons */
.download-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.08s;
  user-select: none;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--border-hover);
}

.btn kbd {
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 400;
  opacity: 0.4;
  margin-left: 0.1rem;
}

.btn-share {
  width: 100%;
  margin-top: 0.35rem;
  background: none;
  color: var(--text-secondary);
  border: 1px dashed var(--border);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem;
}

.btn-share:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: var(--text);
  border-style: solid;
}

/* Disabled state for bg color */
.option-group.disabled {
  opacity: 0.25;
  pointer-events: none;
}

/* ── Features ────────────────────────────────── */

.features {
  margin-top: 3.5rem;
}

.features h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

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

.feature {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 0.15s;
}

.feature:hover { border-color: var(--border-hover); }

.feature-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.feature h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}

.feature p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── FAQ ─────────────────────────────────────── */

.faq {
  margin-top: 2.5rem;
}

.faq h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.85rem;
}

details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s;
}

details:hover { border-color: var(--border-hover); }
details + details { margin-top: 0.4rem; }

summary {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.1s;
  user-select: none;
}

summary:hover { background: var(--bg); }

summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

summary::after {
  content: "+";
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 0.75rem;
  width: 1rem;
  text-align: center;
}

details[open] summary::after { content: "\2212"; }
summary::-webkit-details-marker { display: none; }

details[open] summary {
  border-bottom: 1px solid var(--border);
}

details p {
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ── Footer ──────────────────────────────────── */

footer {
  margin-top: 3.5rem;
  text-align: center;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

footer a:hover { color: var(--text-secondary); }

/* ── Content Pages (about, blog, etc.) ────────── */

.content-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.content-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.content-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.15s;
}

.content-nav a:hover { color: var(--text); }

.content-nav .nav-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.content-nav .nav-logo svg { opacity: 0.5; }

article h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

article .meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

article h2 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
}

article h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

article p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 1rem;
}

article ul, article ol {
  margin: 0.5rem 0 1rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.75;
}

article li { margin-bottom: 0.3rem; }

article strong { color: var(--text); }

article a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

article a:hover { color: var(--text-secondary); }

article code {
  font-family: "SF Mono", Monaco, monospace;
  font-size: 0.85em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15em 0.35em;
}

article blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.content-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.content-footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
}

.content-footer a:hover { color: var(--text-secondary); }

/* Blog index */
.blog-list { list-style: none; }

.blog-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.blog-list li:last-child { border-bottom: none; }

.blog-list a {
  text-decoration: none;
  display: block;
}

.blog-list .post-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
  transition: color 0.15s;
}

.blog-list a:hover .post-title { color: var(--text-secondary); }

.blog-list .post-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.blog-list .post-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.5;
}

/* ── Responsive ──────────────────────────────── */

@media (max-width: 700px) {
  .app {
    padding: 2rem 1rem 3rem;
  }

  header { margin-bottom: 1.75rem; }

  header h1 { font-size: 1.65rem; }

  .tagline { font-size: 0.88rem; }

  .tool-card { padding: 1.25rem; }

  .workspace {
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
  }

  .preview-area {
    flex: none;
    align-items: center;
  }

  .preview-bg {
    width: 200px;
    height: 200px;
  }

  .options-panel { width: 100%; }

  .feature-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .feature { padding: 1rem; }
}

@media (max-width: 480px) {
  .app { padding: 1.5rem 0.85rem 2.5rem; }

  header h1 { font-size: 1.4rem; }

  .tool-card { padding: 1rem; }

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

  .preview-bg {
    width: 180px;
    height: 180px;
  }

  .download-buttons { flex-direction: column; }
}
