:root {
    --hexa-bg: #0c0f1d;
    --panel: rgba(14, 21, 38, 0.78);
    --panel-soft: rgba(22, 31, 54, 0.64);
    --line: rgba(139, 92, 246, 0.28);
    --cyan: #67e8f9;
    --amber: #fbbf24;
    --violet: #8b5cf6;
    --pink: #f472b6;
    /* 尖角朝上（正上方為角） */
    --hex-clip: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    --hex-r: 2.15rem;
    --hex-w: calc(var(--hex-r) * 1.73205080757);
    --hex-h: calc(var(--hex-r) * 2);
    --hex-center-r: 2.35rem;
    --hex-center-w: calc(var(--hex-center-r) * 1.73205080757);
    --hex-center-h: calc(var(--hex-center-r) * 2);
    --hex-node-scale: 0.9;
}

body.hexa-page {
    min-height: 100vh;
    color: #f8fafc;
    background:
        radial-gradient(circle at 50% 25%, rgba(139, 92, 246, 0.25), transparent 24rem),
        radial-gradient(circle at 20% 80%, rgba(6, 182, 212, 0.18), transparent 24rem),
        radial-gradient(circle at 80% 24%, rgba(244, 114, 182, 0.18), transparent 24rem),
        var(--hexa-bg);
    font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

.hexa-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.hexa-hero,
.matrix-panel,
.progress-card,
.detail-grid article {
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: linear-gradient(145deg, var(--panel), rgba(15, 23, 42, 0.54));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
}

.hexa-hero {
    padding: 1.5rem;
    border-radius: 1.5rem;
}

.eyebrow {
    margin: 0 0 0.45rem;
    color: var(--cyan);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.18em;
}

.hexa-hero h1,
.matrix-layout h2,
.detail-grid h2 {
    margin: 0;
}

.hexa-hero h1 {
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    line-height: 1.15;
    color: transparent;
    background: linear-gradient(90deg, #fde68a, #f472b6, #67e8f9);
    background-clip: text;
    -webkit-background-clip: text;
}

.hero-note {
    margin: 0.8rem 0 0;
    color: #cbd5e1;
}

.hexa-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.7rem;
}

.toggle-chip,
.ghost-button {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid rgba(103, 232, 249, 0.28);
    border-radius: 999px;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.78);
    font-weight: 700;
    cursor: pointer;
}

.ghost-button {
    color: #fde68a;
    border-color: rgba(251, 191, 36, 0.34);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.progress-card {
    padding: 1.15rem;
    border-radius: 1.2rem;
}

.progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.progress-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.progress-head strong {
    color: var(--amber);
    font-size: 1.55rem;
}

.progress-track {
    height: 0.75rem;
    overflow: hidden;
    margin: 0.85rem 0;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.9);
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f59e0b, #f472b6);
    box-shadow: 0 0 22px rgba(251, 191, 36, 0.45);
    transition: width 0.25s ease;
}

.soul-track span {
    background: linear-gradient(90deg, #22d3ee, #8b5cf6);
    box-shadow: 0 0 22px rgba(34, 211, 238, 0.42);
}

.progress-card p {
    margin: 0;
    color: #cbd5e1;
}

.matrix-panel {
    padding: 1.25rem;
    border-radius: 1.5rem;
}

.matrix-layout {
    display: grid;
    grid-template-columns: minmax(11.5rem, 13.5rem) minmax(0, 1fr) minmax(11.5rem, 13.5rem);
    gap: 0.75rem 1rem;
    align-items: start;
}

.matrix-side-left {
    min-width: 0;
}

.matrix-side-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    min-width: 0;
}

.matrix-stage-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-width: 0;
}

#active-skill {
    margin: 0;
    color: #cbd5e1;
    text-align: right;
}

.matrix-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.55rem;
    width: 100%;
}

.matrix-controls .toggle-chip,
.matrix-controls .ghost-button {
    justify-content: flex-start;
    width: min(100%, 11.5rem);
    text-align: left;
}

.profile-panel {
    margin-top: 1rem;
}

.profile-panel h2 {
    margin: 0 0 0.65rem;
    font-size: 1.05rem;
}

.profile-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
    margin: 0 0 0.55rem;
    padding: 0;
    list-style: none;
}

.profile-tab,
.profile-add {
    justify-content: flex-start;
    width: min(100%, 11.5rem);
    text-align: left;
}

.profile-tab {
    min-height: 2.5rem;
    padding: 0.55rem 0.95rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 999px;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.72);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.profile-tab:hover {
    border-color: rgba(103, 232, 249, 0.45);
}

.profile-tab.active {
    border-color: rgba(139, 92, 246, 0.65);
    background: linear-gradient(145deg, rgba(76, 29, 149, 0.55), rgba(109, 40, 217, 0.38));
    box-shadow: 0 0 18px rgba(139, 92, 246, 0.28);
}

.profile-add {
    margin-top: 0;
}

.profile-add:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.profile-hint {
    margin: 0.75rem 0 0;
    color: #94a3b8;
    font-size: 0.88rem;
    line-height: 1.6;
}

.matrix-stage {
    position: relative;
    width: min(100%, 600px);
    height: 540px;
    margin: 0;
    overflow: hidden;
    border-radius: 1rem;
    background:
        radial-gradient(circle at center, rgba(103, 232, 249, 0.12), transparent 8rem),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.16), transparent 10rem),
        rgba(2, 6, 23, 0.58);
}

.matrix-lines {
    position: absolute;
    inset: 8%;
    opacity: 0.75;
    background:
        linear-gradient(45deg, transparent 49.8%, var(--line) 50%, transparent 50.2%),
        linear-gradient(135deg, transparent 49.8%, var(--line) 50%, transparent 50.2%),
        radial-gradient(circle at center, transparent 12%, rgba(139, 92, 246, 0.2) 12.4%, transparent 13%),
        radial-gradient(circle at center, transparent 22%, rgba(103, 232, 249, 0.12) 22.4%, transparent 23%);
}

.matrix-center {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: var(--hex-center-w);
    height: var(--hex-center-h);
    color: rgba(255, 255, 255, 0.95);
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: -0.06em;
    transform: translate(-50%, -50%);
    clip-path: var(--hex-clip);
    border: 1px solid rgba(167, 139, 250, 0.55);
    background: linear-gradient(145deg, rgba(76, 29, 149, 0.72), rgba(109, 40, 217, 0.55));
    box-shadow: 0 0 24px rgba(139, 92, 246, 0.42);
}

.hexa-matrix {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.hexa-node {
    position: absolute;
    display: grid;
    place-items: center;
    width: calc(var(--hex-w) * var(--hex-node-scale));
    height: calc(var(--hex-h) * var(--hex-node-scale));
    border: 0;
    color: #fff;
    font: inherit;
    font-size: 1.1rem;
    font-weight: 900;
    transform: translate(-50%, -50%);
    clip-path: var(--hex-clip);
    cursor: pointer;
    isolation: isolate;
    transition: transform 0.18s ease, filter 0.18s ease;
}

.hexa-node::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    background: linear-gradient(145deg, var(--node-a), var(--node-b));
}

.hexa-node::after {
    content: "";
    position: absolute;
    inset: 1.5px;
    z-index: -1;
    clip-path: inherit;
    background: rgba(15, 23, 42, 0.5);
    border: 0.5px solid rgba(255, 255, 255, 0.22);
}

.hexa-node:hover {
    transform: translate(-50%, calc(-50% - 3px)) scale(1.05);
    filter: drop-shadow(0 0 14px var(--node-glow));
}

.hexa-node:focus-visible {
    outline: 3px solid #fef3c7;
    outline-offset: 4px;
}

.hexa-node.locked {
    cursor: not-allowed;
    opacity: 0.58;
    filter: grayscale(0.25);
}

.hexa-node.excluded {
    opacity: 0.42;
}

.hexa-node.locked::before {
    background: linear-gradient(145deg, #64748b, #334155);
}

.node-origin {
    --node-a: #7c3aed;
    --node-b: #a855f7;
    --node-glow: rgba(168, 85, 247, 0.62);
}

.node-mastery {
    --node-a: #be185d;
    --node-b: #f472b6;
    --node-glow: rgba(244, 114, 182, 0.58);
}

.node-enhance {
    --node-a: #0284c7;
    --node-b: #67e8f9;
    --node-glow: rgba(103, 232, 249, 0.56);
}

.node-common {
    --node-a: #475569;
    --node-b: #a5b4fc;
    --node-glow: rgba(165, 180, 252, 0.52);
}

.node-level {
    display: grid;
    place-items: center;
    min-width: 1.55rem;
    min-height: 1.55rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.62);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.36);
}

.node-gear {
    font-size: 1.15rem;
    opacity: 0.85;
}

.matrix-label {
    position: absolute;
    z-index: 3;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.78);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.label-origin {
    top: 0.5rem;
    left: 0.5rem;
}

.label-mastery {
    top: 0.5rem;
    right: 0.5rem;
}

.label-enhance {
    bottom: 0.5rem;
    left: 0.5rem;
}

.label-common {
    right: 0.5rem;
    bottom: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1rem;
    margin-top: 1rem;
}

.detail-grid article {
    padding: 1.15rem;
    border-radius: 1.2rem;
}

.detail-grid ul {
    margin: 0.8rem 0 0;
    padding-left: 1.2rem;
    color: #cbd5e1;
    line-height: 1.8;
}

.detail-grid p {
    color: #cbd5e1;
    line-height: 1.8;
}

.load-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 22rem;
    margin: 0;
    padding: 1rem;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: 1rem;
    color: #fecaca;
    background: rgba(127, 29, 29, 0.32);
    line-height: 1.7;
    text-align: center;
}

.completion-panel {
    margin-top: 1rem;
    padding: 1.25rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 1.35rem;
    background: linear-gradient(145deg, var(--panel), rgba(15, 23, 42, 0.54));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
}

.completion-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.block-hint {
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 500;
}

.completion-result-sticky {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: 1rem 0 0;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(103, 232, 249, 0.28);
    border-radius: 0.85rem;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(6, 78, 99, 0.88));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
}

.completion-result-sticky:empty {
    display: none;
    padding: 0;
    margin: 0;
    border: none;
}

.completion-result-sticky .result-highlight {
    padding: 0;
    border: none;
    background: transparent;
}

.completion-result-sticky .result-highlight p {
    margin: 0.25rem 0;
}

.completion-result-sticky .section-note {
    margin-top: 0.45rem;
    margin-bottom: 0;
}

.section-note {
    margin: 0.55rem 0 0;
    color: #94a3b8;
    font-size: 0.88rem;
    line-height: 1.65;
}

.completion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.completion-block {
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 1rem;
    background: var(--panel-soft);
}

.completion-block-wide {
    grid-column: 1 / -1;
}

.completion-block h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    color: #e2e8f0;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 0.65rem;
}

.resource-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: #cbd5e1;
    font-size: 0.88rem;
}

.resource-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.resource-icon {
    flex-shrink: 0;
    border-radius: 0.25rem;
}

.progress-breath-note {
    color: #94a3b8;
    font-size: 0.88em;
    font-weight: 500;
}

.resource-field input,
.bonus-field input,
.num-input {
    -moz-appearance: textfield;
    appearance: textfield;
}

.resource-field input::-webkit-outer-spin-button,
.resource-field input::-webkit-inner-spin-button,
.bonus-field input::-webkit-outer-spin-button,
.bonus-field input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.resource-field input {
    width: 100%;
    min-height: 2.35rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid rgba(103, 232, 249, 0.22);
    border-radius: 0.65rem;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.85);
    font: inherit;
}

.bonus-field {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
    color: #cbd5e1;
    font-size: 0.9rem;
}

.bonus-field input {
    width: 5rem;
    min-height: 2.2rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(103, 232, 249, 0.22);
    border-radius: 0.55rem;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.85);
    font: inherit;
}

.boss-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.boss-diff-option {
    display: block;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 0.45rem;
    background: transparent;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.boss-diff-option:hover {
    transform: translateY(-1px);
}

.boss-diff-option.active {
    border-color: #f87171;
    border-width: 3px;
    box-shadow:
        0 0 0 2px rgba(248, 113, 113, 0.55),
        0 0 16px rgba(239, 68, 68, 0.85);
    transform: scale(1.06);
}

.boss-diff-option.active .boss-thumb {
    outline: 2px solid rgba(252, 165, 165, 0.95);
    outline-offset: -2px;
}

.boss-thumb {
    position: relative;
    display: block;
    width: 4rem;
    height: 4rem;
    border-radius: 0.4rem;
    overflow: hidden;
}

.boss-avatar {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.boss-diff-badge {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 0.12rem 0;
    color: #0f172a;
    background: rgba(203, 213, 225, 0.92);
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-align: center;
    line-height: 1.15;
}

.source-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.source-group {
    margin: 0;
    height: 100%;
    padding: 0.75rem;
    border: 1px dashed rgba(148, 163, 184, 0.22);
    border-radius: 0.75rem;
}

.source-group legend {
    padding: 0 0.35rem;
    color: #cbd5e1;
    font-size: 0.88rem;
    font-weight: 700;
}

.source-option {
    display: flex;
    margin-top: 0.45rem;
}

.date-settings {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.date-settings-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}

.date-settings-check {
    align-self: flex-start;
}

.calc-mode-group {
    margin: 0;
    padding: 0.85rem;
    border: 1px dashed rgba(148, 163, 184, 0.22);
    border-radius: 0.75rem;
}

.calc-mode-group legend {
    padding: 0 0.35rem;
    color: #cbd5e1;
    font-size: 0.88rem;
    font-weight: 700;
}

.calc-mode-option {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 0.55rem;
    row-gap: 0.1rem;
    align-items: start;
    margin-top: 0.55rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 0.65rem;
    background: rgba(15, 23, 42, 0.45);
    cursor: pointer;
}

.calc-mode-option:has(input:checked) {
    border-color: rgba(103, 232, 249, 0.45);
    background: rgba(6, 78, 99, 0.18);
}

.calc-mode-option input[type="radio"] {
    grid-row: 1 / span 2;
    margin-top: 0.2rem;
}

.calc-mode-label {
    color: #e2e8f0;
    font-weight: 700;
    font-size: 0.92rem;
}

.calc-mode-desc {
    grid-column: 2;
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.45;
}

.calc-end-date {
    margin-top: 0.65rem;
    margin-left: 1.35rem;
}

.date-field.is-disabled {
    opacity: 0.45;
}

.date-field {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #cbd5e1;
    font-size: 0.88rem;
}

.date-field input {
    min-height: 2.35rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid rgba(103, 232, 249, 0.22);
    border-radius: 0.55rem;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.85);
    font: inherit;
}

.date-field input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.completion-result {
    color: #e2e8f0;
    line-height: 1.75;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.75rem;
}

.result-card {
    padding: 0.85rem;
    border: 1px solid rgba(103, 232, 249, 0.18);
    border-radius: 0.75rem;
    background: rgba(15, 23, 42, 0.55);
}

.result-card h3 {
    margin: 0 0 0.45rem;
    font-size: 0.92rem;
    color: #67e8f9;
}

.result-card p {
    margin: 0.25rem 0;
}

.result-highlight {
    padding: 0.85rem 1rem;
    border: 1px solid rgba(103, 232, 249, 0.28);
    border-radius: 0.75rem;
    background: rgba(6, 78, 99, 0.22);
}

.result-highlight p {
    margin: 0.35rem 0;
}

.result-warning {
    margin: 0;
    color: #fecaca;
}

@media (max-width: 900px) {
    .matrix-layout {
        grid-template-columns: 1fr;
    }

    .matrix-side-right {
        align-items: flex-start;
    }

    .matrix-controls {
        align-items: flex-start;
    }

    .matrix-controls .toggle-chip,
    .matrix-controls .ghost-button,
    .profile-tab,
    .profile-add {
        width: min(100%, 14rem);
    }

    .summary-grid,
    .detail-grid,
    .completion-grid,
    .source-columns {
        grid-template-columns: 1fr;
    }

    #active-skill {
        text-align: left;
    }

    .matrix-stage {
        height: 480px;
    }
}

@media (max-width: 640px) {
    :root {
        --hex-r: 1.85rem;
        --hex-center-r: 2rem;
    }

    .hexa-shell {
        width: min(100% - 1rem, 1180px);
        padding-top: 1rem;
    }

    .hexa-hero,
    .matrix-panel {
        padding: 1rem;
    }

    .matrix-stage {
        height: 420px;
    }

    .hexa-node {
        font-size: 0.9rem;
    }

    .matrix-center {
        font-size: 1.05rem;
    }

    .matrix-label {
        font-size: 0.68rem;
    }
}
