:root {
    --blue: #0d6efd;
    --blue-dark: #0a58ca;
    --blue-soft: #eaf2ff;
    --dark: #243246;
    --gray: #667085;
    --muted: #98a2b3;
    --border: #e4e9f2;
    --page: #ffffff;
    --soft: #f5f7fb;
    --shadow: 0 8px 24px rgba(16, 42, 90, 0.08);
    --radius: 10px;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--page);
    color: var(--dark);
    font: 15px/1.65 system-ui, -apple-system, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    padding-top: 60px;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    color: var(--blue-dark);
}

ul {
    list-style: none;
}

img,
svg {
    max-width: 100%;
}

.container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1140px;
    height: 60px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 22px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 19px;
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
}

.logo:hover {
    color: var(--dark);
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--blue), #4da3ff);
    color: #fff;
    font-size: 16px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.main-nav a {
    color: var(--dark);
    font-size: 14px;
    white-space: nowrap;
}

.main-nav a:hover {
    color: var(--blue);
}

.header-search {
    position: relative;
    margin-left: auto;
    width: 260px;
    flex: 0 1 260px;
}

.header-search input {
    width: 100%;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--soft);
    padding: 0 42px 0 14px;
    font-size: 13px;
    color: var(--dark);
    outline: none;
    transition: 0.2s;
}

.header-search input:focus {
    border-color: #9ec1ff;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.header-search button {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.header-search button svg {
    width: 15px;
    height: 15px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    white-space: nowrap;
}

.header-actions a {
    color: var(--dark);
}

.header-actions a:hover {
    color: var(--blue);
}

.lang-select {
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--gray);
    font-size: 12px;
    padding: 0 6px;
    outline: none;
}

.inline-form {
    display: inline;
}

.link-btn {
    border: 0;
    background: none;
    color: var(--dark);
    font: inherit;
    cursor: pointer;
}

.link-btn:hover {
    color: var(--blue);
}

.user-name {
    color: var(--gray);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: var(--blue);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: 0.18s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--blue-dark);
    color: #fff;
}

.btn-sm {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 13px;
}

.btn-light {
    background: var(--soft);
    border-color: var(--border);
    color: var(--dark);
}

.btn-light:hover {
    background: var(--blue-soft);
    border-color: #bcd4ff;
    color: var(--blue-dark);
}

.btn-ghost {
    background: #fff;
    border-color: var(--border);
    color: var(--gray);
}

.btn-ghost:hover {
    background: var(--soft);
    color: var(--dark);
}

.btn.active {
    background: var(--blue-soft);
    border-color: #bcd4ff;
    color: var(--blue-dark);
}

/* Hero */
.hero {
    padding: 46px 0 26px;
    background: linear-gradient(180deg, #edf4ff 0%, #ffffff 100%);
    text-align: center;
}

.hero h1 {
    font-size: 34px;
    line-height: 1.25;
    color: #102a52;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.hero p {
    margin-top: 10px;
    color: var(--gray);
    font-size: 15px;
}

.hero-search {
    max-width: 620px;
    margin: 24px auto 0;
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 4px 5px 4px 18px;
    box-shadow: var(--shadow);
}

.hero-search input {
    flex: 1;
    min-width: 0;
    height: 38px;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--dark);
}

.hero-search button {
    border: 0;
    border-radius: 22px;
    min-height: 38px;
    padding: 0 22px;
    background: var(--blue);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.hero-search button:hover {
    background: var(--blue-dark);
}

/* Sections */
.section {
    padding: 26px 0;
}

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

.section-head h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--dark);
}

.section-head a {
    font-size: 13px;
    color: var(--gray);
}

.section-head a:hover {
    color: var(--blue);
}

/* Grids */
.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.tool-card {
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    transition: 0.2s;
    color: var(--dark);
}

.tool-card:hover {
    border-color: #bcd4ff;
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    color: var(--dark);
}

.tool-card h3 {
    font-size: 16px;
    line-height: 1.4;
    color: var(--blue);
    font-weight: 600;
}

.tool-card p {
    margin-top: 8px;
    color: var(--gray);
    font-size: 13px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 42px;
}

.card-foot {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.meta {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--gray);
    font-size: 12px;
    line-height: 1.5;
}

.tool-card:hover .meta {
    background: var(--blue-soft);
    color: var(--blue-dark);
}

/* Categories */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.cat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--dark);
    transition: 0.2s;
}

.cat-card:hover {
    border-color: #bcd4ff;
    box-shadow: var(--shadow);
    color: var(--dark);
}

.cat-icon {
    font-size: 24px;
    line-height: 1;
}

.cat-name {
    font-size: 14px;
    font-weight: 600;
}

.cat-count {
    font-size: 12px;
    color: var(--muted);
}

/* Tags */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag-pill {
    display: inline-block;
    padding: 6px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--gray);
    font-size: 13px;
    transition: 0.18s;
}

.tag-pill:hover {
    background: var(--blue-soft);
    border-color: #bcd4ff;
    color: var(--blue-dark);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 18px 0;
    font-size: 13px;
    color: var(--muted);
}

.breadcrumb a {
    color: var(--gray);
}

.breadcrumb a:hover {
    color: var(--blue);
}

/* Tool page */
.tool-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 6px 0 20px;
}

.tool-head h1 {
    font-size: 27px;
    line-height: 1.3;
    color: #102a52;
}

.tool-subtitle {
    margin-top: 8px;
    color: var(--gray);
    font-size: 14px;
    max-width: 780px;
}

.tool-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
}

.tool-meta .tags {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tool-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.tool-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 2px 8px rgba(16, 42, 90, 0.03);
}

.tool-about {
    margin-top: 24px;
    background: var(--soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
}

.tool-about h2 {
    font-size: 18px;
    margin-bottom: 10px;
}

.tool-about p {
    color: var(--gray);
    font-size: 14px;
    margin-top: 6px;
}

.note {
    color: var(--muted) !important;
    font-size: 13px !important;
}

/* Forms */
.field {
    margin-bottom: 16px;
}

.field label,
.field-title {
    display: block;
    margin-bottom: 7px;
    color: var(--dark);
    font-size: 13px;
    font-weight: 600;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field input[type="email"],
.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="search"],
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    color: var(--dark);
    font: inherit;
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    transition: 0.18s;
}

.field textarea {
    min-height: 210px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
        monospace;
    font-size: 13px;
    line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: #9ec1ff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.field textarea[readonly] {
    background: #fbfcfe;
}

.tool-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.tool-form-grid .field textarea {
    min-height: 250px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray);
    font-size: 13px;
}

.checkbox-row input {
    width: 16px;
    height: 16px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error {
    background: #fff1f0;
    border: 1px solid #ffccc7;
    color: #b42318;
}

.alert-info {
    background: var(--blue-soft);
    border: 1px solid #cfe2ff;
    color: var(--blue-dark);
}

.alert-success {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: #067647;
}

.result-box {
    width: 100%;
    min-height: 74px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfe;
    padding: 14px 16px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 15px;
    color: var(--dark);
    word-break: break-all;
    white-space: pre-wrap;
}

.big-result {
    font-size: 34px;
    font-weight: 700;
    color: var(--blue);
    line-height: 1.3;
    word-break: break-word;
}

.result-label {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.data-table th {
    width: 38%;
    color: var(--gray);
    font-weight: 500;
    background: #fbfcfe;
}

.data-table tr:last-child th,
.data-table tr:last-child td {
    border-bottom: 0;
}

.data-table td {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--dark);
    word-break: break-all;
}

/* Clock / stopwatch */
.clock-display {
    text-align: center;
    padding: 26px 0 10px;
}

.clock-time {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(42px, 9vw, 82px);
    line-height: 1.1;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: 0.02em;
}

.clock-date {
    margin-top: 10px;
    color: var(--gray);
    font-size: 16px;
}

.lap-list {
    margin-top: 18px;
    max-height: 260px;
    overflow: auto;
    border-top: 1px solid var(--border);
}

.lap-list li {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.lap-list li span:last-child {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Search page */
.search-summary {
    color: var(--gray);
    font-size: 14px;
    margin-bottom: 18px;
}

.empty-state {
    padding: 46px 20px;
    text-align: center;
    color: var(--gray);
    background: var(--soft);
    border: 1px dashed var(--border);
    border-radius: 12px;
}

/* Auth */
.auth-wrap {
    padding: 40px 0 60px;
}

.auth-card {
    max-width: 440px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.auth-card h1 {
    font-size: 23px;
    text-align: center;
    margin-bottom: 22px;
}

.auth-card .btn {
    width: 100%;
    margin-top: 6px;
}

.auth-switch {
    margin-top: 18px;
    text-align: center;
    font-size: 13px;
    color: var(--gray);
}

.form-error {
    color: #b42318;
    font-size: 13px;
    margin-top: 5px;
}

/* Footer */
.site-footer {
    margin-top: 40px;
    padding: 34px 0 26px;
    background: #f7f9fc;
    border-top: 1px solid var(--border);
}

.footer-inner {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: space-between;
}

.footer-brand {
    max-width: 460px;
}

.footer-brand .logo {
    margin-bottom: 10px;
}

.footer-brand p {
    color: var(--gray);
    font-size: 13px;
}

.footer-links {
    display: flex;
    gap: 34px;
    flex-wrap: wrap;
}

.footer-col h4 {
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--dark);
}

.footer-col a {
    display: block;
    color: var(--gray);
    font-size: 13px;
    line-height: 2;
}

.footer-col a:hover {
    color: var(--blue);
}

.footer-bottom {
    max-width: 1140px;
    margin: 22px auto 0;
    padding: 18px 16px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, 0.5);
}

.modal-panel {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(16, 24, 40, 0.2);
}

.modal-panel h2 {
    font-size: 18px;
    margin-bottom: 14px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: none;
    font-size: 22px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
}

/* Toast */
#toastBox {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 18px;
    border-radius: 8px;
    background: #102a52;
    color: #fff;
    font-size: 13px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(8px);
    transition: 0.25s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: #b42318;
}

.toast.success {
    background: #067647;
}

/* Related */
.related {
    padding-bottom: 10px;
}

/* Responsive */
@media (max-width: 960px) {
    .header-search {
        display: none;
    }

    .main-nav {
        gap: 14px;
    }

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    body {
        font-size: 14px;
    }

    .header-inner {
        height: auto;
        min-height: 56px;
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 14px;
    }

    body {
        padding-top: 64px;
    }

    .main-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .header-actions {
        margin-left: auto;
        gap: 10px;
    }

    .user-name {
        display: none;
    }

    .hero {
        padding: 34px 0 20px;
    }

    .hero h1 {
        font-size: 26px;
    }

    .hero-search {
        border-radius: 12px;
        padding: 5px;
    }

    .hero-search button {
        border-radius: 9px;
    }

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

    .cat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tool-head {
        flex-direction: column;
    }

    .tool-actions {
        width: 100%;
    }

    .tool-actions .btn {
        flex: 1;
    }

    .tool-form-grid,
    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .tool-panel {
        padding: 16px;
    }

    .footer-inner {
        flex-direction: column;
    }
}

.gresult {
    margin: 10px 0 0;
}

.gresult-row {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border, #e5e7eb);
    align-items: baseline;
    flex-wrap: wrap;
}

.gresult-row dt {
    color: var(--muted, #6b7280);
    min-width: 180px;
    flex-shrink: 0;
}

.gresult-row dd {
    margin: 0;
    word-break: break-all;
    flex: 1;
}

.gresult-row dd.mono {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.result-table th,
.result-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
