:root {
    --primary-color: #2f6fd6;
    --background-color: #f3f5f8;
    --text-color: #1f2937;
    --white: #fff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --bg-gradient: linear-gradient(110deg, #ff8a8a 0%, #ffd56a 45%, #7edbff 100%);
    --card-bg: rgba(255, 255, 255, 0.86);
    --card-border: rgba(255, 255, 255, 0.45);
    --history-bg: #f6f7fb;
    --divider-color: rgba(31, 41, 55, 0.15);
}

[data-theme="dark"] {
    --primary-color: #7cc4ff;
    --background-color: #0b0f14;
    --text-color: #e5e7eb;
    --white: #0f172a;
    --shadow-color: rgba(0, 0, 0, 0.45);
    --bg-gradient: radial-gradient(circle at 10% 20%, #1b2b4a 0%, #0b1220 40%, #120b1d 100%);
    --card-bg: rgba(15, 23, 42, 0.84);
    --card-border: rgba(148, 163, 184, 0.2);
    --history-bg: rgba(30, 41, 59, 0.7);
    --divider-color: rgba(226, 232, 240, 0.2);
}

body {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: var(--bg-gradient);

}

.container {
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow-color);
    text-align: center;
    max-width: 900px;
    width: 100%;
    backdrop-filter: blur(10px);
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

h1 {
    color: var(--primary-color);
    margin: 0;
    text-align: left;
    font-size: 2em;
}

.subtitle {
    text-align: left;
    margin: 12px 0 24px;
    color: var(--text-color);
    opacity: 0.8;
}

#theme-toggle {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--divider-color);
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9em;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

#theme-toggle:hover {
    transform: translateY(-1px);
    background-color: rgba(255, 255, 255, 0.15);
}

.tool-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
    justify-content: flex-start;
}

.tab {
    border: 1px solid var(--divider-color);
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: transparent;
}

.tool-panel {
    display: none;
    text-align: left;
    padding: 20px;
    border-radius: 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    margin-bottom: 24px;
}

.tool-panel.active {
    display: grid;
    gap: 16px;
}

.panel-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.panel-head h2 {
    margin: 0 0 6px;
    color: var(--primary-color);
    font-size: 1.3em;
}

.hint {
    font-weight: 400;
    font-size: 0.9em;
    opacity: 0.7;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button.primary {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

button.ghost {
    background: transparent;
    border: 1px solid var(--divider-color);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.output {
    background: var(--history-bg);
    border-radius: 12px;
    padding: 16px;
    display: grid;
    gap: 12px;
}

.output-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.output-block {
    margin: 0;
    white-space: pre-wrap;
    font-family: "Fira Code", "Courier New", monospace;
    background: rgba(15, 23, 42, 0.08);
    padding: 12px;
    border-radius: 8px;
    line-height: 1.5;
    min-height: 48px;
}

.footer-note {
    margin-top: 20px;
    font-size: 0.9em;
    opacity: 0.7;
    text-align: left;
}

@media (max-width: 520px) {
    .header {
        flex-direction: column;
        align-items: stretch;
    }

    h1 {
        text-align: center;
    }

    .tool-panel {
        padding: 16px;
    }
}
