:root {
    --brand: #2563eb;    --brand-dark: #1d4ed8;
    --brand-soft: #eff4ff;
    --page-bg: #f6f8fc;
    --surface: #ffffff;
    --border: #e4e9f2;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 10px 28px rgba(16, 24, 40, .10);
}

[data-bs-theme="dark"] {
    --brand-soft: #17233c;
    --page-bg: #0f141b;
    --surface: #161c24;
    --border: #232b36;
    --shadow-md: 0 10px 28px rgba(0, 0, 0, .45);
}

[hidden] {
    display: none !important;
}

body {
    background: var(--page-bg);
    color: #1f2937;
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}

[data-bs-theme="dark"] body {
    color: #e5e7eb;
}

/* 导航 */
.app-navbar {
    background: rgba(255, 255, 255, .86);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    padding-top: .55rem;
    padding-bottom: .55rem;
}

[data-bs-theme="dark"] .app-navbar {
    background: rgba(22, 28, 36, .86);
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(37, 99, 235, .28);
}

.app-search {
    min-width: 260px;
}

.navbar .nav-link {
    font-size: .94rem;
}

/* 首页 Hero */
.hero {
    padding: 76px 0 60px;
    background:
        radial-gradient(1100px 380px at 50% -140px, #dbe9ff 0%, rgba(219, 233, 255, 0) 70%),
        linear-gradient(180deg, #f4f8ff, var(--page-bg));
    border-bottom: 1px solid var(--border);
}

[data-bs-theme="dark"] .hero {
    background:
        radial-gradient(1100px 380px at 50% -140px, #1b2a44 0%, rgba(27, 42, 68, 0) 70%),
        linear-gradient(180deg, #121821, var(--page-bg));
}

.hero-search {
    max-width: 660px;
}

.hero-search .form-control,
.hero-search .input-group-text {
    height: 3.25rem;
}

.hero-tag {
    display: inline-block;
    margin: 0 .18rem .35rem;
    padding: .18rem .6rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, .08);
    color: var(--brand-dark);
    font-size: .82rem;
    text-decoration: none;
}

.hero-tag:hover {
    background: rgba(37, 99, 235, .16);
}

/* 分类卡片 */
.cat-card,
.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.tool-card:hover,
.cat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #c7d7f5;
}

[data-bs-theme="dark"] .tool-card:hover,
[data-bs-theme="dark"] .cat-card:hover {
    border-color: #33507e;
}

.tool-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

.cat-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--brand-soft);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex: 0 0 auto;
}

.cat-icon-lg {
    width: 54px;
    height: 54px;
    font-size: 1.6rem;
    border-radius: 15px;
}

.tool-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--brand-soft);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex: 0 0 auto;
}

.tool-icon-lg {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
    border-radius: 13px;
}

.chip {
    display: inline-block;
    padding: .18rem .6rem;
    font-size: .78rem;
    line-height: 1.5;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    text-decoration: none;
    white-space: nowrap;
}

[data-bs-theme="dark"] .chip {
    color: #9ec1ff;
}

.chip:hover {
    background: rgba(37, 99, 235, .18);
}

.chip-more {
    background: transparent;
    border: 1px dashed var(--border);
    color: #6b7280;
}

.chip-lg {
    font-size: .88rem;
    padding: .4rem .9rem;
}

.all-tool-link {
    padding: .45rem .7rem;
    border-radius: 10px;
    color: #374151;
    font-size: .9rem;
    text-decoration: none;
    border: 1px solid transparent;
}

[data-bs-theme="dark"] .all-tool-link {
    color: #d1d5db;
}

.all-tool-link:hover {
    background: var(--brand-soft);
    border-color: var(--border);
    color: var(--brand-dark);
}

/* 表单与结果 */
.card {
    border-radius: var(--radius);
    border-color: var(--border);
    background: var(--surface);
}

.card-header {
    background: transparent;
    border-bottom-color: var(--border);
    padding: .85rem 1rem;
}

.form-control,
.form-select {
    border-radius: 10px;
    border-color: var(--border);
}

.form-control:focus,
.form-select:focus {
    border-color: #93b4f5;
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12);
}

textarea.font-monospace,
input.font-monospace {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: .88rem;
}

.result-card {
    border-left: 3px solid var(--brand);
}

.result-block + .result-block {
    margin-top: 1rem;
}

.result-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .82rem;
    color: #6b7280;
    margin-bottom: .35rem;
}

.result-text {
    display: block;
    padding: .7rem .85rem;
    background: #f7f9fc;
    border: 1px solid var(--border);
    border-radius: 10px;
    word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .9rem;
}

[data-bs-theme="dark"] .result-text {
    background: #10161e;
}

.result-image {
    max-width: 100%;
    max-height: 520px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.result-image-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .6rem;
}

.tool-result-table th.table-key {
    width: 168px;
    font-weight: 500;
    color: #6b7280;
    background: #fafbfe;
}

[data-bs-theme="dark"] .tool-result-table th.table-key {
    background: #121821;
    color: #9ca3af;
}

.tool-result-table {
    font-size: .88rem;
}

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 10px;
    font-size: .84rem;
    max-height: 560px;
    overflow: auto;
    word-break: break-all;
}

/* 收藏角标 */
.fav-count {
    position: absolute;
    top: -7px;
    right: -7px;
    font-size: .62rem;
    padding: .16rem .34rem;
    line-height: 1;
}

.fav-toggle.is-active {
    background: #fff7e6;
    border-color: #f5c451;
    color: #a8730a;
}

/* 页脚 */
.app-footer {
    margin-top: 3rem;
    padding: 1.4rem 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* 加载 */
.is-loading .bi-play-fill {
    display: none;
}

.empty-state i {
    opacity: .5;
}

/* 计算器快捷键 */
.calc-pad {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .4rem;
    margin-top: .6rem;
}

.calc-pad button {
    font-family: ui-monospace, Consolas, monospace;
}

/* 手机端微调 */
@media (max-width: 768px) {
    .hero {
        padding: 48px 0 40px;
    }
    .hero-search .form-control {
        height: 2.85rem;
    }
    .tool-result-table th.table-key {
        width: 110px;
    }
}
