/* AI Tools - English Static Site
   Clean Minimal style with Dark Mode toggle.
   Mobile-first, fast, no external requests. */

/* ---------- Theme tokens ---------- */
:root {
  /* Light (default) - refined Clean Minimal */
  --bg: #ffffff;
  --bg-alt: #f7f8fa;
  --bg-soft: #fafbfc;
  --text: #0d1117;
  --text-muted: #57606a;
  --text-soft: #6e7781;
  --border: #d8dee4;
  --border-soft: #eaeef2;
  --primary: #0969da;
  --primary-hover: #0550ae;
  --primary-soft: rgba(9, 105, 218, 0.08);
  --success: #1a7f37;
  --success-bg: #dafbe1;
  --danger: #cf222e;
  --danger-bg: #ffebe9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 3px 12px rgba(0, 0, 0, 0.06);
  --radius: 6px;
  --radius-lg: 10px;
  --max-width: 960px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Monaco, Consolas, "Courier New", monospace;
  --transition: 0.15s ease;
}

:root[data-theme="dark"] {
  /* GitHub Dark-inspired, easier on dev eyes */
  --bg: #0d1117;
  --bg-alt: #161b22;
  --bg-soft: #1c2129;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-soft: #6e7681;
  --border: #30363d;
  --border-soft: #21262d;
  --primary: #58a6ff;
  --primary-hover: #79b8ff;
  --primary-soft: rgba(88, 166, 255, 0.12);
  --success: #3fb950;
  --success-bg: rgba(63, 185, 80, 0.12);
  --danger: #f85149;
  --danger-bg: rgba(248, 81, 73, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 3px 12px rgba(0, 0, 0, 0.5);
}

/* Respect system preference if user hasn't toggled */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0d1117;
    --bg-alt: #161b22;
    --bg-soft: #1c2129;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-soft: #6e7681;
    --border: #30363d;
    --border-soft: #21262d;
    --primary: #58a6ff;
    --primary-hover: #79b8ff;
    --primary-soft: rgba(88, 166, 255, 0.12);
    --success: #3fb950;
    --success-bg: rgba(63, 185, 80, 0.12);
    --danger: #f85149;
    --danger-bg: rgba(248, 81, 73, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 3px 12px rgba(0, 0, 0, 0.5);
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* ---------- Header ---------- */
.header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

:root[data-theme="dark"] .header {
  background: rgba(13, 17, 23, 0.85);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .header {
    background: rgba(13, 17, 23, 0.85);
  }
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.logo:hover {
  color: var(--primary);
}

/* Theme toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show sun icon in dark mode, moon icon in light mode */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Container ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px 48px;
}

/* ---------- Homepage tool grid ---------- */
.section-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 24px;
  max-width: 640px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.tool-card {
  display: block;
  padding: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.tool-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.tool-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.tool-card .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 12px;
}

/* ---------- Tool page ---------- */
.tool-header {
  margin-bottom: 24px;
}

.tool-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--text);
}

.tool-header p {
  color: var(--text-muted);
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

/* ---------- Form elements ---------- */
textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
  min-height: 200px;
  line-height: 1.5;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input[type="file"] {
  font-size: 13px;
  color: var(--text-muted);
}

input[type="file"]::file-selector-button {
  padding: 8px 14px;
  margin-right: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
}

input[type="file"]::file-selector-button:hover {
  background: var(--border-soft);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

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

.btn:active {
  transform: translateY(0.5px);
}

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

.btn-secondary:hover {
  background: var(--bg-alt);
  border-color: var(--text-soft);
  color: var(--text);
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0;
}

/* Inline controls row (slider + value) */
.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.control-row input[type="range"] {
  flex: 1;
  min-width: 200px;
  padding: 0;
}

.control-row .value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  min-width: 60px;
}

/* Preview area (for images) */
.preview {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  display: none;
}

.preview img {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius);
}

.preview .meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---------- Output area ---------- */
.output {
  margin-top: 8px;
  padding: 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 80px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 500px;
  overflow-y: auto;
}

.output:empty { display: none; }

.output.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger);
}

.output.success {
  color: var(--success);
}

/* ---------- Inline messages ---------- */
.msg {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
}

.msg:empty { display: none; }

.msg.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.msg.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}

/* ---------- FAQ ---------- */
.faq {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.faq h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.faq-item {
  margin-bottom: 18px;
}

.faq-item h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.faq-item p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ---------- Sitemap page ---------- */
.sitemap-list {
  list-style: none;
  padding: 0;
  margin-top: 8px;
}

.sitemap-list li {
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
  line-height: 1.5;
}

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

.sitemap-list a {
  font-weight: 600;
}

.sitemap-list .desc {
  color: var(--text-muted);
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 64px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}

.footer a {
  color: var(--text-soft);
}

.footer a:hover {
  color: var(--primary);
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .header-inner, .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  .tool-grid {
    grid-template-columns: 1fr;
  }
  .tool-header h1, .section-title {
    font-size: 22px;
  }
  .btn-row {
    flex-direction: column;
  }
  .btn-row .btn {
    width: 100%;
  }
  .control-row input[type="range"] {
    min-width: 100%;
  }
}
