/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #F7F6F3;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --border-soft:  #edf2f7;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-faint:   #a0aec0;
  --accent:       #4f46e5;
  --accent-2:     #7c3aed;
  --accent-light: #eef2ff;
  --accent-border:#c7d2fe;
  --green:        #22c55e;
  --green-light:  #f0fdf4;
  --green-border: #bbf7d0;
  --radius-sm:    6px;
  --radius:       12px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow:       0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: .625rem;
}

.logo-icon { width: 34px; height: 34px; flex-shrink: 0; }
.logo-icon img { display: block; width: 34px; height: 34px; }

.logo-label { display: flex; flex-direction: column; line-height: 1.2; }

.logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}

.logo-sub {
  font-size: .65rem;
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: .02em;
}
.logo-sub a { color: inherit; }

/* Header controls (homepage — model select) */
.header-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.model-select-wrapper {
  display: none;
  align-items: center;
  gap: .5rem;
  padding: .4rem .625rem .4rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  position: relative;
}
@media (min-width: 640px) { .model-select-wrapper { display: flex; } }

.model-icon { width: 15px; height: 15px; stroke: var(--text-faint); flex-shrink: 0; }

.model-select-wrapper select {
  background: transparent;
  border: none;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text);
  outline: none;
  cursor: pointer;
  padding-right: 1.25rem;
  appearance: none;
}

.chevron { width: 13px; height: 13px; stroke: var(--text-faint); position: absolute; right: .5rem; pointer-events: none; }

.encoding-badge {
  display: none;
  font-size: .7rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  padding: .2rem .55rem;
  border-radius: 99px;
  letter-spacing: .02em;
}
@media (min-width: 768px) { .encoding-badge { display: inline-block; } }

/* Tool nav (tool pages) */
.tool-nav {
  display: none;
  align-items: center;
  gap: .25rem;
}
@media (min-width: 640px) { .tool-nav { display: flex; } }

.nav-link {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: .375rem .75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-light); color: var(--accent); }

/* ── Main ─────────────────────────────────────────────────────────────────── */
main {
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
  padding: 2rem 1.5rem;
  flex: 1;
}

/* ── Section header ───────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .875rem;
}

.section-title {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}

.action-buttons { display: flex; align-items: center; gap: .25rem; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.text-btn {
  display: flex;
  align-items: center;
  gap: .35rem;
  height: 30px;
  padding: 0 .625rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, color .15s, background .15s;
}
.text-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.text-btn:hover { background: var(--accent-light); border-color: var(--accent-border); color: var(--accent); }
.text-btn:disabled { opacity: .3; cursor: not-allowed; }
.text-btn:disabled:hover { background: var(--surface); border-color: var(--border); color: var(--text-muted); }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-faint);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text-muted); border-color: var(--border); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.icon-btn.copied { color: #16a34a; background: #f0fdf4; border-color: #bbf7d0; }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Tools bar (above footer) ─────────────────────────────────────────────── */
.tools-bar {
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  padding: 1.5rem;
}

.tools-bar-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.tools-bar-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.tools-list {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
}

.tools-item {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .625rem .875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
  min-width: 160px;
}
.tools-item:hover { background: var(--accent-light); border-color: var(--accent-border); box-shadow: var(--shadow-sm); text-decoration: none; }
.tools-item-name { font-size: .875rem; font-weight: 700; color: var(--text); transition: color .15s; }
.tools-item:hover .tools-item-name { color: var(--accent); }
.tools-item-desc { font-size: .75rem; color: var(--text-faint); }

/* ── Footer ───────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border-soft);
  padding: 1rem 1.5rem;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .375rem;
  font-size: .75rem;
  color: var(--text-faint);
}
@media (min-width: 640px) { .footer-inner { flex-direction: row; justify-content: space-between; } }

.version {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-faint);
  margin-right: .625rem;
  opacity: .6;
}

.status-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  margin-right: .375rem;
  vertical-align: middle;
}
