/* ============================================================
   汇添富基金风险提示生成器 — 墨与纸 · 精炼金融风格
   ============================================================ */

:root {
    /* Ink & paper palette */
    --bg-1: #edf1f7;
    --bg-2: #e2e8f2;
    --paper: #ffffff;
    --paper-soft: #f7f9fc;
    --ink: #16273c;
    --ink-2: #33475f;
    --ink-soft: #647587;
    --line: #dde4ee;
    --line-soft: #eaeff6;

    --brand: #1d4e89;
    --brand-600: #17406f;
    --brand-700: #123456;
    --brand-050: #eaf1fa;
    --brand-100: #d7e5f5;

    --accent: #b8863b;          /* warm brass — used sparingly */
    --accent-soft: #f5ecd9;

    --danger: #c23b3b;
    --warn-bg: #fdf3d7;
    --warn-fg: #8a6414;
    --info-bg: #e3f0fb;
    --info-fg: #16537e;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(22, 39, 60, 0.05);
    --shadow: 0 6px 20px -8px rgba(22, 39, 60, 0.16), 0 1px 2px rgba(22, 39, 60, 0.05);
    --shadow-lg: 0 18px 44px -16px rgba(18, 52, 86, 0.32);

    --font-sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", "Roboto Mono", Menlo, monospace;
}

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

body {
    font-family: var(--font-sans);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.6;
    background:
        radial-gradient(1200px 600px at 100% -5%, rgba(29, 78, 137, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(184, 134, 59, 0.06), transparent 55%),
        linear-gradient(180deg, var(--bg-1), var(--bg-2));
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---------------- Header ---------------- */
header {
    position: relative;
    background:
        linear-gradient(120deg, var(--brand-700) 0%, var(--brand-600) 55%, var(--brand) 100%);
    color: #fff;
    padding: 22px 32px 24px;
    overflow: hidden;
    box-shadow: 0 8px 28px -12px rgba(18, 52, 86, 0.55);
}
/* subtle engraved grid texture */
header::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    -webkit-mask-image: radial-gradient(120% 120% at 85% 0%, #000 20%, transparent 75%);
    mask-image: radial-gradient(120% 120% at 85% 0%, #000 20%, transparent 75%);
    pointer-events: none;
}
.header-inner {
    position: relative;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.brand-mark {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.brand-mark svg { width: 23px; height: 23px; display: block; }
.header-text h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    line-height: 1.2;
}
.header-text .subtitle {
    margin-top: 3px;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.3px;
}
.header-tag {
    margin-left: auto;
    align-self: center;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    padding: 5px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

/* ---------------- Usage guide ---------------- */
.usage {
    max-width: 1600px;
    margin: 20px auto 0;
    padding: 0 20px;
}
.usage-inner {
    background: var(--paper);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 14px 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    animation: rise 0.5s ease both;
}
.usage-title {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
    color: var(--brand-600);
    font-size: 13.5px;
    padding-top: 1px;
}
.usage-title svg { width: 16px; height: 16px; }
.usage-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
    font-size: 13px;
    color: var(--ink-2);
}
.usage-steps .step { display: flex; align-items: baseline; gap: 7px; }
.usage-steps .step b {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: var(--brand);
    width: 17px; height: 17px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: center;
}

/* ---------------- Layout ---------------- */
.container {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    align-items: flex-start;
}
.panel-left {
    flex: 0 0 520px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
}

/* ---------------- Cards ---------------- */
.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
    animation: rise 0.5s ease both;
}
.panel-left .card:hover {
    box-shadow: var(--shadow);
    border-color: var(--brand-100);
}
/* staggered entrance */
.panel-left .card:nth-child(1) { animation-delay: 0.04s; }
.panel-left .card:nth-child(2) { animation-delay: 0.10s; }
.panel-left .card:nth-child(3) { animation-delay: 0.16s; }
.panel-left .card:nth-child(4) { animation-delay: 0.22s; }
.panel-right .card { animation-delay: 0.12s; }

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.2px;
}
.card h2 .num {
    background: linear-gradient(155deg, var(--brand) 0%, var(--brand-700) 100%);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: var(--font-mono);
    font-weight: 700;
    box-shadow: 0 2px 6px -1px rgba(18, 52, 86, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ---------------- Form elements ---------------- */
label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--ink-2);
    font-size: 13px;
}
input[type="text"], select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--paper-soft);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input[type="text"]::placeholder { color: #9aa7b6; }
input[type="text"]:focus, select:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(29, 78, 137, 0.14);
}

/* ---------------- Autocomplete ---------------- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    max-height: 260px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-lg);
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    transition: background 0.12s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--brand-050); }
.autocomplete-item .code { color: var(--ink-soft); font-size: 12px; font-family: var(--font-mono); }
.autocomplete-item .name { font-weight: 500; }

/* ---------------- Manual add ---------------- */
.manual-add-section {
    padding: 12px;
    background: var(--paper-soft);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--line);
}

/* ---------------- Checkbox rows ---------------- */
.card > label[style] { line-height: 1.5; }
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    vertical-align: -2px;
    margin-right: 4px;
    cursor: pointer;
}
.checkbox-group { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 400;
    cursor: pointer;
    padding: 4px 0;
}
.sub-options {
    margin-left: 24px;
    padding: 8px 0 4px 12px;
    border-left: 2px solid var(--brand-100);
    display: none;
}
.sub-options.show { display: block; }

.period-input { display: none; margin-top: 4px; margin-left: 24px; }
.period-input.show { display: flex; align-items: center; gap: 6px; }
.period-input input { width: 100px; }

/* ---------------- Manager tags ---------------- */
.manager-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.manager-tag {
    background: var(--brand-050);
    border: 1px solid var(--brand-100);
    color: var(--brand-600);
    border-radius: 999px;
    padding: 4px 8px 4px 13px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}
.manager-tag .remove {
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 16px;
    line-height: 1;
    transition: color 0.12s;
}
.manager-tag .remove:hover { color: var(--danger); }

/* ---------------- Buttons ---------------- */
.btn {
    padding: 11px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.2s, background 0.15s, color 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-600) 100%);
    color: #fff;
    width: 100%;
    letter-spacing: 1px;
    padding: 14px;
    box-shadow: 0 10px 24px -10px rgba(18, 52, 86, 0.6);
}
.btn-primary:hover {
    box-shadow: 0 14px 30px -10px rgba(18, 52, 86, 0.7);
    filter: brightness(1.06);
}
.btn-group { display: flex; gap: 8px; }
.btn-sm { padding: 7px 15px; font-size: 13px; font-weight: 500; }
.btn-outline {
    background: #fff;
    color: var(--brand);
    border: 1px solid var(--brand-100);
}
.btn-outline:hover { background: var(--brand-050); border-color: var(--brand); }

/* ---------------- Output ---------------- */
.panel-right .card { flex: 1; display: flex; flex-direction: column; }
.output-area { flex: 1; min-height: 400px; overflow-y: auto; }
#output-text {
    width: 100%;
    height: 100%;
    min-height: 420px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    font-size: 14px;
    line-height: 1.9;
    resize: vertical;
    font-family: inherit;
    color: var(--ink);
    background:
        linear-gradient(var(--paper-soft), var(--paper-soft)) padding-box,
        repeating-linear-gradient(transparent, transparent 33px, var(--line-soft) 33px, var(--line-soft) 34px) padding-box;
}
#output-text:focus { outline: none; border-color: var(--brand-100); }
#output-text::placeholder { color: #a3afbc; }

/* ---------------- Warnings ---------------- */
.warnings { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.warning-item {
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid transparent;
}
.warning-item.warning { background: var(--warn-bg); color: var(--warn-fg); border-color: #f2dd9f; }
.warning-item.info { background: var(--info-bg); color: var(--info-fg); border-color: #c3ddf4; }
.warning-icon { flex-shrink: 0; }

/* ---------------- Selected funds ---------------- */
.selected-fund-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 13px;
    transition: border-color 0.15s, background 0.15s;
}
.selected-fund-item:hover { border-color: var(--brand-100); background: #fff; }
.selected-fund-item .fund-badge {
    background: linear-gradient(155deg, var(--brand) 0%, var(--brand-700) 100%);
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 6px;
    flex-shrink: 0;
    font-weight: 700;
    font-family: var(--font-mono);
    min-width: 20px;
    text-align: center;
    line-height: 1.5;
}
.selected-fund-item .fund-item-info {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    align-items: center;
}
.selected-fund-item .fund-item-name { font-weight: 500; }
.selected-fund-item .fund-item-code { color: var(--ink-soft); font-size: 12px; font-family: var(--font-mono); }
.selected-fund-item .fund-item-type {
    color: var(--brand);
    font-size: 11px;
    background: var(--brand-050);
    border: 1px solid var(--brand-100);
    border-radius: 5px;
    padding: 0 6px;
}
.selected-fund-item .fund-remove {
    cursor: pointer;
    color: #9ca3af;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    border: none;
    background: none;
    padding: 0 2px;
    transition: color 0.12s;
}
.selected-fund-item .fund-remove:hover { color: var(--danger); }

/* ---------------- Fund special tags ---------------- */
.fund-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
    padding-left: 32px;
}
.fund-tag {
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-soft);
    transition: all 0.15s;
    user-select: none;
}
.fund-tag:hover { border-color: #9dc0e6; color: var(--brand); }
.fund-tag.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    box-shadow: 0 2px 6px -2px rgba(18, 52, 86, 0.5);
}
.fund-tag-more { font-size: 11px; padding: 2px 8px; color: var(--brand); cursor: pointer; user-select: none; }
.fund-tag-more:hover { text-decoration: underline; }

.fund-sub-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    padding-left: 32px;
}
.fund-sub-inputs .sub-input-group { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.fund-sub-inputs input { width: 80px; padding: 4px 7px; font-size: 12px; }

/* ---------------- ICP footer ---------------- */
.site-footer {
    padding: 6px 20px calc(24px + env(safe-area-inset-bottom));
    color: var(--ink-soft);
    font-size: 12px;
    text-align: center;
}
.site-footer a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
}
.site-footer a:hover { color: var(--brand); text-decoration: underline; }
.site-footer a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1000px) {
    .container { flex-direction: column; }
    .panel-left { flex: none; }
    .panel-right { position: static; max-height: none; }
    .header-tag { display: none; }
    .usage-inner { flex-direction: column; gap: 10px; }
}
