/* ToolAstro - Cosmic Developer Tools */
:root {
    --primary: #a855f7;
    --primary-dark: #9333ea;
    --primary-light: rgba(168,85,247,0.15);
    --accent: #06b6d4;
    --accent-glow: rgba(6,182,212,0.3);
    --bg: #0a0a1a;
    --bg-card: rgba(15,15,35,0.8);
    --bg-card-solid: #0f0f23;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(168,85,247,0.15);
    --border-focus: #a855f7;
    --success: #10b981;
    --error: #f43f5e;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    --glow: 0 0 20px rgba(168,85,247,0.3);
    --glow-cyan: 0 0 20px rgba(6,182,212,0.3);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    --max-w: 1200px;
    --nav-h: 64px;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(168,85,247,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(168,85,247,0.05) 0%, transparent 40%);
    background-attachment: fixed;
}

/* Star field */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 50% 10%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 15% 85%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 45% 45%, rgba(168,85,247,0.6), transparent),
        radial-gradient(1px 1px at 75% 70%, rgba(6,182,212,0.5), transparent),
        radial-gradient(1.5px 1.5px at 25% 30%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1.5px 1.5px at 85% 15%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 60% 90%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 5% 50%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1px 1px at 95% 55%, rgba(168,85,247,0.4), transparent),
        radial-gradient(1px 1px at 40% 75%, rgba(6,182,212,0.3), transparent),
        radial-gradient(1.5px 1.5px at 55% 25%, rgba(255,255,255,0.45), transparent);
    pointer-events: none;
    z-index: 0;
}

body > * { position: relative; z-index: 1; }

/* ---- NAV ---- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10,10,26,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--nav-h);
    display: flex;
    align-items: center;
}
.nav-inner {
    max-width: var(--max-w);
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-logo {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-logo svg { width: 28px; height: 28px; }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-links a:hover { color: var(--accent); background: rgba(6,182,212,0.1); }
.hamburger { display: none; background: none; border: none; font-size: 1.5rem; color: var(--text); cursor: pointer; padding: 4px; }

/* ---- HERO ---- */
.hero {
    text-align: center;
    padding: 48px 20px 32px;
    max-width: var(--max-w);
    margin: 0 auto;
    width: 100%;
}
.hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text);
    line-height: 1.2;
}
.hero h1 span {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 24px;
}
.search-bar {
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}
.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color 0.15s;
    outline: none;
    font-family: var(--font);
}
.search-bar input:focus { border-color: var(--accent); box-shadow: var(--glow-cyan); }
.search-bar svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

/* ---- CATEGORIES ---- */
.categories {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 0 20px 24px;
    flex-wrap: wrap;
}
.cat-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
}
.cat-btn:hover, .cat-btn.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; border-color: transparent; box-shadow: var(--glow); }

/* ---- TOOL GRID ---- */
.tools-grid {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 20px 48px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.tool-card:hover {
    border-color: var(--accent);
    box-shadow: var(--glow-cyan);
    transform: translateY(-2px);
}
.tool-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(6,182,212,0.2));
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: var(--mono);
}
.tool-card h3 { font-size: 1.05rem; font-weight: 600; }
.tool-card p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; flex: 1; }
.tool-card-cat {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- AD SLOTS ---- */
.ad-slot {
    max-width: var(--max-w);
    margin: 0 auto 24px;
    padding: 0 20px;
    text-align: center;
    min-height: 90px;
}
.ad-slot-inner {
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---- TOOL PAGE ---- */
.tool-header {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 24px 20px 16px;
    width: 100%;
}
.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.tool-header h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: 8px; }
.tool-header p { color: var(--text-secondary); font-size: 1rem; }

.tool-container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 20px 48px;
    width: 100%;
}

/* Tool I/O panels */
.tool-io {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.tool-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tool-panel label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.tool-panel textarea, .tool-single textarea {
    width: 100%;
    min-height: 200px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text);
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
    line-height: 1.6;
}
.tool-panel textarea:focus, .tool-single textarea:focus { border-color: var(--accent); box-shadow: var(--glow-cyan); }

.tool-single {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tool-single label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Actions bar */
.tool-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.tool-actions.wrap { flex-wrap: wrap; }

/* Buttons */
.btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
    white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-color: transparent;
    box-shadow: var(--glow);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #0891b2); color: white; box-shadow: 0 0 30px rgba(168,85,247,0.4); }
.btn-copy { color: var(--text-secondary); }
.btn-copy:hover { color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* Config rows */
.tool-config {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}
.config-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.config-row:last-child { margin-bottom: 0; }
.config-row label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.config-row input[type="number"],
.config-row select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    width: 80px;
    outline: none;
    font-family: var(--font);
}
.config-row select { width: auto; }
.config-row input[type="range"] { width: 150px; }

/* Stats grid (word counter) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

/* Password display */
.pw-output-wrap {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}
.pw-display {
    flex: 1;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 1.1rem;
    background: var(--bg-card);
    color: var(--text);
    outline: none;
    font-weight: 600;
    letter-spacing: 1px;
}
.pw-strength {
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.pw-weak { color: var(--error); }
.pw-moderate { color: var(--warning); }
.pw-strong { color: var(--success); }
.pw-vstrong { color: var(--accent); }

/* Color converter */
.color-tool {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
    margin-bottom: 16px;
}
.color-preview-wrap { position: relative; }
.color-preview {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.color-preview-wrap input[type="color"] {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    border: 2px solid white;
    border-radius: var(--radius);
    cursor: pointer;
}
.color-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.color-field {
    display: flex;
    align-items: center;
    gap: 12px;
}
.color-field label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    width: 40px;
    text-align: right;
}
.color-field input[type="text"],
.color-field input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text);
    outline: none;
    width: 100%;
}
.color-field input[type="number"] { width: 70px; }
.rgb-row { display: flex; gap: 8px; flex: 1; }

/* Hash results */
.hash-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.hash-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.hash-row label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    width: 65px;
    text-align: right;
    flex-shrink: 0;
}
.hash-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.8rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
}

/* Regex tester */
.regex-top { margin-bottom: 16px; }
.regex-pattern {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
}
.regex-slash { color: var(--accent); font-size: 1.2rem; font-weight: 700; font-family: var(--mono); }
.regex-pattern input {
    border: none;
    background: none;
    font-family: var(--mono);
    font-size: 1rem;
    color: var(--text);
    outline: none;
    flex: 1;
}
.regex-pattern input:last-child { width: 50px; flex: none; text-align: center; }
.regex-result {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    min-height: 200px;
    font-family: var(--mono);
    font-size: 0.9rem;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.regex-result pre { white-space: pre-wrap; word-break: break-all; }
.regex-result mark {
    background: rgba(168,85,247,0.3);
    color: #e2e8f0;
    padding: 1px 2px;
    border-radius: 2px;
    border: 1px solid rgba(168,85,247,0.4);
}
.regex-info {
    margin-top: 12px;
    font-size: 0.9rem;
}
.regex-info table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 0.85rem;
}
.regex-info th, .regex-info td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
}
.regex-info th { background: var(--bg); font-weight: 600; }
.regex-info code {
    background: var(--primary-light);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 0.85em;
}

/* Markdown preview */
.md-editor .tool-panel:last-child { overflow: hidden; }
.md-preview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    min-height: 200px;
    overflow: auto;
    line-height: 1.7;
}
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 { margin: 16px 0 8px; font-weight: 700; }
.md-preview h1 { font-size: 1.6rem; border-bottom: 2px solid var(--border); padding-bottom: 8px; }
.md-preview h2 { font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.md-preview h3 { font-size: 1.1rem; }
.md-preview p { margin-bottom: 12px; }
.md-preview pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    overflow-x: auto;
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.md-preview code {
    background: var(--primary-light);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 0.9em;
}
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote {
    border-left: 4px solid var(--accent);
    padding: 8px 16px;
    margin: 12px 0;
    color: var(--text-secondary);
    background: var(--bg);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.md-preview ul, .md-preview ol { margin: 8px 0 12px 20px; }
.md-preview li { margin-bottom: 4px; }
.md-preview table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 8px 12px; }
.md-preview th { background: var(--bg); font-weight: 600; }
.md-preview hr { border: none; border-top: 2px solid var(--border); margin: 16px 0; }
.md-preview img { border-radius: var(--radius); }
.md-preview a { color: var(--accent); }

/* About section on tool pages */
.tool-about {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 32px;
}
.tool-about h2 { font-size: 1.1rem; margin-bottom: 8px; }
.tool-about p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.7; }

/* Related tools */
.related-tools {
    margin-top: 32px;
}
.related-tools h2 { font-size: 1.1rem; margin-bottom: 16px; }
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.related-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.15s;
}
.related-card:hover { border-color: var(--accent); box-shadow: var(--glow-cyan); }
.related-card .tool-card-icon { width: 36px; height: 36px; font-size: 0.7rem; flex-shrink: 0; }
.related-card span { font-weight: 600; font-size: 0.9rem; }

/* Status toast */
.status-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}
.status-toast.show { opacity: 1; transform: translateY(0); }
.status-toast.success { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; box-shadow: var(--glow); }
.status-toast.error { background: var(--error); color: white; }

/* ---- FOOTER ---- */
.footer {
    margin-top: auto;
    background: rgba(10,10,26,0.9);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 32px 20px;
    text-align: center;
}
.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
}
.footer-links { display: flex; justify-content: center; gap: 24px; margin-bottom: 12px; flex-wrap: wrap; }
.footer-links a { color: var(--text-secondary); text-decoration: none; font-size: 0.85rem; }
.footer-links a:hover { color: var(--accent); }
.footer-copy { color: var(--text-muted); font-size: 0.8rem; }

.muted { color: var(--text-muted); }
.error { color: var(--error); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.6rem; }
    .tool-io { grid-template-columns: 1fr; }
    .tool-header h1 { font-size: 1.4rem; }
    .nav-links { display: none; position: absolute; top: var(--nav-h); left: 0; right: 0; background: rgba(10,10,26,0.95); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); flex-direction: column; padding: 12px; }
    .nav-links.open { display: flex; }
    .hamburger { display: block; }
    .color-tool { grid-template-columns: 1fr; }
    .color-preview { aspect-ratio: 3/1; }
    .tools-grid { grid-template-columns: 1fr; }
    .hash-row { flex-wrap: wrap; }
    .hash-row label { width: 100%; text-align: left; }
    .pw-output-wrap { flex-wrap: wrap; }
    .pw-display { min-width: 100%; }
}

@media (max-width: 480px) {
    .hero { padding: 32px 16px 24px; }
    .hero h1 { font-size: 1.4rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .config-row { flex-direction: column; align-items: flex-start; }
}

/* Print */
@media print {
    .nav, .footer, .ad-slot, .tool-actions { display: none !important; }
    body { background: white; color: black; }
    body::before { display: none; }
}