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

:root {
    /* Modern Color Palette */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #818cf8;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --accent-color: #ec4899;
    --accent-light: #f472b6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --link-color: #3b82f6;
    --link-hover: #2563eb;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-color: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --code-bg: #f1f5f9;
    --border-color: #e5e7eb;
    --border-light: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    --radius-sm: 2px;
    --radius-md: 3px;
    --radius-lg: 4px;
    --radius-xl: 6px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
    --header-bg: #2563eb;
    --notice-bg: #f0fdf4;
    --notice-border: #86efac;
    --notice-text: #166534;
    color-scheme: light;
}

/* Dark theme: follows the system unless the visitor picked a theme with the toggle */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --primary-color: #7b7ff5;
        --primary-hover: #9396f8;
        --primary-light: #a5b4fc;
        --link-color: #60a5fa;
        --link-hover: #93c5fd;
        --text-color: #e5e7eb;
        --text-secondary: #a3aab8;
        --text-muted: #8089a0;
        --bg-color: #1b1e26;
        --bg-secondary: #111318;
        --bg-tertiary: #262a35;
        --code-bg: #262a35;
        --border-color: #353a48;
        --glass-bg: rgba(27, 30, 38, 0.8);
        --header-bg: #1e3a8a;
        --notice-bg: #0f2a1c;
        --notice-border: #1f6b40;
        --notice-text: #86efac;
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --primary-color: #7b7ff5;
    --primary-hover: #9396f8;
    --primary-light: #a5b4fc;
    --link-color: #60a5fa;
    --link-hover: #93c5fd;
    --text-color: #e5e7eb;
    --text-secondary: #a3aab8;
    --text-muted: #8089a0;
    --bg-color: #1b1e26;
    --bg-secondary: #111318;
    --bg-tertiary: #262a35;
    --code-bg: #262a35;
    --border-color: #353a48;
    --glass-bg: rgba(27, 30, 38, 0.8);
    --header-bg: #1e3a8a;
    --notice-bg: #0f2a1c;
    --notice-border: #1f6b40;
    --notice-text: #86efac;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-color);
    background: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    margin-bottom: 0.75em;
    line-height: 1.3;
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2.5em;
}

h2 {
    font-size: 2em;
    margin-top: 2em;
    margin-bottom: 1em;
    color: var(--text-color);
}

h3 {
    font-size: 1.5em;
    margin-top: 1.5em;
    color: var(--text-color);
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

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

code {
    background-color: var(--code-bg);
    padding: 0.25em 0.5em;
    border-radius: 3px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.875em;
    color: var(--accent-color);
    border: 1px solid var(--border-color);
}

/* Keep the hidden attribute working on elements that set their own display */
[hidden] {
    display: none !important;
}

/* Header and Navigation */
header {
    background: var(--header-bg);
    color: white;
    padding: 0.875rem 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5em;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
}

header h1 a {
    color: white;
}

header h1 a:hover {
    color: white;
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.theme-toggle {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 3px;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0.4rem 0.6rem;
    transition: background-color 0.2s ease;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.nav-links a {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    color: white;
    text-decoration: none;
    background-color: rgba(255, 255, 255, 0.2);
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.section {
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.section h2 {
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25em;
    margin-bottom: 0.75rem;
}

/* Homepage layout: sticky sidebar + main column */
.home-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.home-sidebar {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
}

.sidebar-heading {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 1rem 0 0.4rem;
    padding: 1rem 0.5rem 0;
    /* Accent bar separating the groups */
    border-top: 3px solid var(--primary-color);
}

.home-sidebar nav > .sidebar-heading:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.sidebar-links {
    list-style: none;
    padding: 0;
}

.sidebar-links a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    color: var(--text-color);
    font-size: 0.9rem;
}

.sidebar-links a:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

/* Keep anchored sections clear of the sticky header */
.home-main .section,
.home-main .category-section {
    scroll-margin-top: 5rem;
}

@media (max-width: 900px) {
    .home-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .home-sidebar {
        position: static;
        max-height: none;
    }

    /* Each group becomes one row of chips that scrolls sideways */
    .sidebar-links {
        display: flex;
        gap: 0.4rem;
        padding: 0 0.5rem 0.25rem;
        overflow-x: auto;
    }

    .sidebar-links a {
        border: 1px solid var(--border-color);
        background: var(--bg-secondary);
        white-space: nowrap;
    }
}

/* Hero/Intro Section */
.hero-section {
    text-align: left;
    padding: 0.5rem 1.5rem 0.5rem 1.5rem;
}

.intro-text {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin: 0;
}

.section h2::before {
    content: '';
    width: 3px;
    height: 1.2em;
    background: var(--primary-color);
    border-radius: 2px;
}

/* Tools Lists */
.tools-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tools-list li {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

.tools-list li.tool-item {
    cursor: pointer;
    position: relative;
    padding-right: 2.75rem;
}

/* Stretch the link over the whole row so the row stays clickable */
.tools-list li.tool-item .tool-name::after {
    content: '';
    position: absolute;
    inset: 0;
}

.tools-list li.tool-item.active {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

/* Favorite star */
.fav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
}

.fav-btn:hover,
.fav-btn[aria-pressed="true"] {
    color: var(--warning-color);
}

.tools-list .fav-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 1;
}

.tool-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.tool-title-row .fav-btn {
    font-size: 1.6rem;
}

.tools-list li:hover {
    background: var(--bg-tertiary);
}

.tool-name {
    font-weight: 600;
    color: var(--primary-color);
}

.tools-list li.tool-item:hover .tool-name {
    color: var(--primary-hover);
    text-decoration: underline;
}

.tool-description {
    color: var(--text-secondary);
    margin-left: 0.5em;
    font-size: 0.95em;
}

.tool-date {
    color: var(--text-muted);
    font-size: 0.8em;
    margin-left: 0.5em;
}

/* Category Sections */
.category-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.category-section:last-child {
    border-bottom: none;
}

.category-section h3 {
    color: var(--text-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.1em;
}

.tool-count {
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 500;
}

/* Search */
.search-container {
    position: relative;
}

#search-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-shortcut {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    pointer-events: none;
}

#search-input:focus + .search-shortcut,
#search-input:not(:placeholder-shown) + .search-shortcut {
    display: none;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

#search-input::placeholder {
    color: var(--text-muted);
}

#search-results {
    margin-top: 1rem;
}

#search-results .tool-category {
    display: inline-block;
    background: var(--bg-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

.no-results {
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
}

/* Timeline */
.timeline-month {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary-color);
}

.timeline-month h4 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95em;
    font-weight: 600;
}

/* Footer */
footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

footer p {
    max-width: 600px;
    margin: 0 auto;
}

/* Tool Page Styles */
.tool-header {
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.tool-header h1 {
    margin-bottom: 0.25em;
    color: var(--text-color);
}

.tool-meta {
    color: var(--text-secondary);
    font-size: 1.1em;
}

.tool-interface {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.25rem 0;
    box-shadow: var(--shadow-sm);
}

.tool-interface h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.15em;
}

.tool-interface textarea,
.tool-interface input[type="text"],
.tool-interface input[type="datetime-local"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.875em;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    color: var(--text-color);
}

.tool-interface textarea:focus,
.tool-interface input[type="text"]:focus,
.tool-interface input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.tool-interface textarea {
    min-height: 200px;
    resize: vertical;
}

.tool-interface button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
}

.tool-interface button:hover {
    background: var(--primary-hover);
}

.output {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-top: 0.75rem;
    min-height: 80px;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.875em;
    line-height: 1.5;
    color: var(--text-color);
}

#current-time {
    background: var(--notice-bg);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    border: 1px solid var(--notice-border);
}

#current-time strong {
    color: var(--notice-text);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container,
    .nav-container {
        padding: 1.5rem 1rem;
    }

    .section {
        padding: 1.5rem;
        border-radius: 4px;
    }

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.65em;
    }

    h3 {
        font-size: 1.35em;
    }

    .nav-container {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .nav-links {
        gap: 1rem;
        width: 100%;
    }

    .nav-links a {
        padding: 0.5rem 0.75rem;
        font-size: 0.9em;
    }

    .tools-list li {
        padding: 0.875rem 1rem;
        padding-left: 2.5rem;
    }

    .tool-interface {
        padding: 1.5rem;
    }

    .tool-header {
        padding: 1.5rem;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection color */
::selection {
    background-color: var(--primary-light);
    color: white;
}
