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

:root {
    --green-900: #0b5a22;
    --green-700: #118e1d;
    --green-500: #20a33c;
    --blue-900: #0a2d67;
    --blue-800: #135790;
    --blue-700: #0c4aa3;
    --blue-500: #2e75d2;
    --gold-700: #b58c19;
    --gold-500: #d9b131;
    --gold-300: #f3df7a;
    --ink: #102034;
    --muted: #5b6d7e;
    --line: rgba(16, 32, 52, 0.1);
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: rgba(255, 255, 255, 0.98);
    --surface-soft: rgba(255, 255, 255, 0.78);
    --success-soft: rgba(17, 142, 29, 0.12);
    --warning-soft: rgba(217, 177, 49, 0.18);
    --danger-soft: rgba(210, 73, 73, 0.12);
    --danger: #d24949;
    --sidebar-w: 300px;
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --shadow: 0 24px 60px rgba(9, 35, 64, 0.14);
    --font: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    color: var(--ink);
    display: flex;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(12, 74, 163, 0.24), transparent 26%),
        radial-gradient(circle at top right, rgba(17, 142, 29, 0.22), transparent 26%),
        linear-gradient(180deg, #0c3f84 0%, #11705a 30%, #edf7f5 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 88%);
}

body,
button,
input,
textarea,
select {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

code {
    font-family: "SFMono-Regular", "Consolas", "Monaco", monospace;
}

.eyebrow {
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.78rem;
    color: var(--muted);
}

.sidebar,
.top-bar,
.tool-card,
.tool-page,
.client-tool,
.pane,
.calc-display,
.calc-section,
.hero-panel,
.hero-aside,
.tool-notes,
.result-text-box,
.result-success,
.result-error {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.48);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.sidebar {
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 16px;
    left: 16px;
    bottom: 16px;
    z-index: 100;
    overflow-y: auto;
    border-radius: var(--radius-xl);
    transition: transform 0.25s ease;
}

.sidebar-header {
    padding: 1.2rem 1.2rem 1rem;
    border-bottom: 1px solid var(--line);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    color: var(--ink);
}

.logo span {
    display: flex;
    flex-direction: column;
}

.logo small {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.logo strong {
    font-size: 1.16rem;
    line-height: 1.1;
}

.logo-mark {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    object-fit: contain;
}

.sidebar-nav {
    padding: 0.75rem 0;
    flex: 1;
}

.nav-category {
    padding: 0 0.55rem;
}

.nav-category + .nav-category {
    margin-top: 0.15rem;
}

.nav-category-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.8rem 0.95rem;
    border: none;
    border-radius: 14px;
    background: transparent;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
}

.nav-category-btn:hover,
.nav-category-btn.open {
    background: rgba(19, 87, 144, 0.08);
}

.nav-category-btn .chevron {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.nav-category-btn.open .chevron {
    transform: rotate(180deg);
}

.nav-items {
    display: none;
    padding: 0.2rem 0 0.4rem;
}

.nav-items.open {
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-left: 0.4rem;
    padding: 0.58rem 0.9rem 0.58rem 1.25rem;
    border-radius: 12px;
    font-size: 0.86rem;
    color: var(--muted);
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(19, 87, 144, 0.12);
    color: var(--blue-800);
    transform: translateX(2px);
}

.main-content {
    flex: 1;
    margin-left: calc(var(--sidebar-w) + 32px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    margin: 16px 16px 0 0;
    padding: 1rem 1.4rem;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 16px;
    z-index: 50;
}

.top-heading {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.top-title {
    font-weight: 800;
    font-size: 1.08rem;
}

.top-subtitle {
    color: var(--muted);
    font-size: 0.88rem;
    max-width: 70ch;
}

.menu-btn {
    display: none;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--ink);
}

.content-area {
    flex: 1;
    padding: 22px 22px 30px 0;
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 21, 41, 0.38);
    z-index: 90;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.78rem 1.2rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:active {
    transform: scale(0.985);
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue-700), var(--green-700));
    color: white;
    box-shadow: 0 16px 28px rgba(12, 74, 163, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--green-700), var(--green-500));
    color: white;
}

.btn-small {
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    background: rgba(19, 87, 144, 0.08);
    color: var(--blue-800);
}

.btn-small:hover {
    background: rgba(19, 87, 144, 0.14);
}

.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.82fr);
    gap: 20px;
    margin-bottom: 28px;
}

.hero-panel,
.hero-aside {
    padding: 26px;
    border-radius: var(--radius-xl);
}

.hero-panel {
    color: white;
    background:
        linear-gradient(140deg, rgba(12, 74, 163, 0.86), rgba(17, 142, 29, 0.8)),
        var(--surface);
}

.brand-ribbon {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hero-logo {
    width: 76px;
    height: 76px;
    flex: 0 0 auto;
    object-fit: contain;
    filter: drop-shadow(0 14px 22px rgba(9, 34, 62, 0.18));
}

.home-hero h1 {
    font-size: clamp(2.2rem, 4vw, 3.8rem);
    line-height: 0.98;
    letter-spacing: -0.04em;
}

.hero-panel .eyebrow {
    color: rgba(255, 255, 255, 0.76);
}

.hero-copy {
    margin-top: 18px;
    max-width: 60ch;
    line-height: 1.7;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.92);
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.hero-stat,
.hero-card.feature {
    border-radius: var(--radius-lg);
    padding: 18px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.hero-stat strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.hero-stat span {
    color: rgba(255, 255, 255, 0.86);
    line-height: 1.45;
    font-size: 0.88rem;
}

.hero-aside {
    display: grid;
    gap: 14px;
}

.hero-card.feature {
    color: var(--ink);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(242, 248, 246, 0.98));
}

.hero-card.feature p {
    margin-top: 6px;
    color: var(--muted);
    line-height: 1.55;
}

.hero-step {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    margin-bottom: 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(12, 74, 163, 0.12), rgba(17, 142, 29, 0.18));
    color: var(--blue-800);
    font-weight: 800;
}

.category-section {
    margin-bottom: 24px;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.95rem;
    font-size: 1.08rem;
    font-weight: 800;
    color: white;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.95rem;
}

.tool-card {
    border-radius: var(--radius-lg);
    padding: 1.05rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.tool-card:hover {
    transform: translateY(-2px);
    border-color: rgba(12, 74, 163, 0.28);
}

.tool-card .card-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-grid;
    place-items: center;
    font-size: 1.15rem;
    color: var(--blue-800);
    background: linear-gradient(135deg, rgba(12, 74, 163, 0.12), rgba(17, 142, 29, 0.12));
    flex-shrink: 0;
}

.tool-card .card-body h3 {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 0.18rem;
}

.tool-card .card-body p {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.45;
}

.tool-page,
.client-tool {
    max-width: 820px;
    padding: 24px;
    border-radius: var(--radius-xl);
}

.tool-header {
    margin-bottom: 1.3rem;
}

.tool-header h1 {
    font-size: 1.65rem;
    margin-bottom: 0.35rem;
}

.tool-header p {
    color: var(--muted);
    line-height: 1.6;
}

.tool-notes {
    margin-bottom: 1.2rem;
    padding: 1rem 1.1rem;
    border-left: 4px solid var(--gold-500);
    border-radius: var(--radius-md);
    background: rgba(255, 248, 225, 0.85);
    color: #5a4200;
    line-height: 1.55;
    font-size: 0.9rem;
}

.tool-notes p {
    margin-bottom: 0.5rem;
}

.tool-notes p:last-child {
    margin-bottom: 0;
}

.tool-notes code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.12rem 0.35rem;
    border-radius: 6px;
    font-size: 0.84rem;
}

.tool-notes details {
    margin-top: 0.45rem;
}

.tool-notes details > summary {
    cursor: pointer;
    font-weight: 700;
    color: #8a6300;
}

.tool-notes ol,
.tool-notes ul {
    margin: 0.25rem 0 0.4rem 1.2rem;
}

.tool-notes a {
    color: #8a6300;
}

.upload-zone {
    position: relative;
    margin-bottom: 1rem;
    padding: 2.4rem 1.2rem;
    border: 2px dashed rgba(19, 87, 144, 0.24);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(244, 249, 247, 0.92));
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.18s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--blue-700);
    background: linear-gradient(180deg, rgba(240, 247, 255, 0.9), rgba(242, 249, 245, 0.96));
    transform: translateY(-1px);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-prompt i {
    font-size: 2.45rem;
    color: var(--blue-700);
}

.upload-prompt p {
    margin: 0.55rem 0 0.15rem;
    font-size: 1rem;
    font-weight: 700;
}

.upload-prompt span,
.upload-prompt small {
    display: block;
    color: var(--muted);
}

.upload-prompt small {
    margin-top: 0.45rem;
    font-size: 0.78rem;
}

.file-list {
    text-align: left;
    margin-top: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    margin-bottom: 0.45rem;
    padding: 0.55rem 0.7rem;
    background: rgba(19, 87, 144, 0.06);
    border: 1px solid rgba(19, 87, 144, 0.08);
    border-radius: 12px;
    font-size: 0.86rem;
}

.remove-file {
    border: none;
    background: transparent;
    color: var(--danger);
    font-size: 1rem;
    cursor: pointer;
}

.tool-options {
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 0.9rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.34rem;
    font-size: 0.86rem;
    font-weight: 700;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.78rem 0.88rem;
    border: 1px solid rgba(16, 32, 52, 0.12);
    border-radius: 14px;
    background: var(--surface-strong);
    color: var(--ink);
    font-size: 0.94rem;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(12, 74, 163, 0.4);
    box-shadow: 0 0 0 4px rgba(46, 117, 210, 0.12);
}

textarea {
    resize: vertical;
}

.text-input {
    min-height: 120px;
}

.checkbox-label,
.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.92rem;
    cursor: pointer;
}

.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.range-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.range-group input[type="range"] {
    flex: 1;
}

.range-value {
    min-width: 3rem;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--blue-800);
}

.result-area {
    margin-top: 1.5rem;
}

.result-success,
.result-error {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    padding: 1rem 1.05rem;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
}

.result-success {
    background: rgba(232, 250, 248, 0.92);
    color: #1a7a6d;
}

.result-success .btn {
    margin-left: auto;
}

.result-error {
    background: rgba(253, 234, 234, 0.96);
    color: var(--danger);
}

.result-text-box {
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.result-text-header,
.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.75rem 0.9rem;
    background: rgba(19, 87, 144, 0.06);
    border-bottom: 1px solid var(--line);
    font-size: 0.86rem;
    font-weight: 700;
}

.result-text-box pre,
.pane-body pre {
    padding: 0.9rem;
    max-height: 420px;
    overflow: auto;
    font-size: 0.86rem;
    white-space: pre-wrap;
    word-break: break-word;
}

#result-preview {
    margin-top: 0.8rem;
    width: 100%;
}

#result-preview img {
    max-width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
}

.spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.split-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.pane {
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.pane-body {
    padding: 0.9rem;
}

.pane-body textarea {
    width: 100%;
    min-height: 250px;
    border: none;
    background: transparent;
    resize: vertical;
    outline: none;
    font-family: "SFMono-Regular", "Consolas", "Monaco", monospace;
    font-size: 0.86rem;
}

.calc-display {
    border-radius: var(--radius-lg);
    padding: 1rem;
    text-align: right;
    margin-bottom: 1rem;
}

.calc-expression {
    font-size: 0.86rem;
    color: var(--muted);
    min-height: 1.2em;
}

.calc-result {
    font-size: 2rem;
    font-weight: 800;
    word-break: break-all;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.55rem;
}

.calc-btn {
    padding: 0.88rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-strong);
    font-size: 1.08rem;
    cursor: pointer;
}

.calc-btn:hover {
    background: rgba(19, 87, 144, 0.07);
}

.calc-btn.op {
    background: rgba(19, 87, 144, 0.1);
    color: var(--blue-800);
    font-weight: 800;
}

.calc-btn.eq {
    background: linear-gradient(135deg, var(--blue-700), var(--green-700));
    color: white;
}

.calc-btn.span2 {
    grid-column: span 2;
}

.converter-row {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
    margin-bottom: 0.8rem;
}

.converter-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.converter-swap {
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-strong);
    cursor: pointer;
    font-size: 1.15rem;
}

.color-preview {
    width: 100%;
    height: 88px;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--blue-700);
}

.color-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.calc-section {
    padding: 1.15rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
}

.calc-section h3 {
    font-size: 0.98rem;
    margin-bottom: 0.8rem;
}

.calc-result-inline {
    margin-top: 0.55rem;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--blue-800);
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
    width: auto;
    flex: 0 0 auto;
}

.inline-form .wide {
    flex: 1;
    min-width: 100px;
}

.inline-form span {
    font-size: 0.9rem;
    white-space: nowrap;
}

.md-preview {
    padding: 0.9rem;
    min-height: 250px;
    line-height: 1.6;
}

.md-preview h1,
.md-preview h2,
.md-preview h3 {
    margin: 0.8em 0 0.4em;
}

.md-preview h1 {
    font-size: 1.5rem;
}

.md-preview h2 {
    font-size: 1.25rem;
}

.md-preview h3 {
    font-size: 1.1rem;
}

.md-preview p {
    margin-bottom: 0.6em;
}

.md-preview code {
    background: rgba(19, 87, 144, 0.08);
    padding: 0.15em 0.4em;
    border-radius: 6px;
    font-size: 0.9em;
}

.md-preview pre {
    background: rgba(19, 87, 144, 0.08);
    padding: 0.8rem;
    border-radius: 12px;
    overflow-x: auto;
}

.md-preview pre code {
    background: none;
    padding: 0;
}

.md-preview ul,
.md-preview ol {
    padding-left: 1.5em;
    margin-bottom: 0.6em;
}

.md-preview blockquote {
    border-left: 3px solid var(--blue-700);
    padding-left: 0.8rem;
    color: var(--muted);
    margin: 0.6em 0;
}

.md-preview table {
    width: 100%;
    margin: 0.6em 0;
    border-collapse: collapse;
}

.md-preview th,
.md-preview td {
    border: 1px solid var(--line);
    padding: 0.4rem 0.6rem;
    text-align: left;
}

.md-preview th {
    background: rgba(19, 87, 144, 0.08);
    font-weight: 700;
}

@media (max-width: 1080px) {
    .home-hero {
        grid-template-columns: 1fr;
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        top: 0;
        left: 0;
        bottom: 0;
        border-radius: 0;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .top-bar {
        margin: 12px;
    }

    .menu-btn {
        display: block;
    }

    .content-area {
        padding: 0 12px 22px;
    }

    .split-pane,
    .color-inputs {
        grid-template-columns: 1fr;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .converter-row {
        flex-direction: column;
    }

    .inline-form input,
    .inline-form select {
        width: 100%;
    }
}
