:root {
    color-scheme: dark;
    --ink: #f6fbff;
    --muted: #b8c8d8;
    --panel: rgba(8, 21, 34, 0.82);
    --panel-strong: rgba(6, 16, 28, 0.94);
    --line: rgba(201, 230, 255, 0.22);
    --blue: #4bb7ff;
    --cyan: #79f0ff;
    --amber: #ffcc66;
    --green: #7ee08b;
    --danger: #ff6f75;
    --runway: #263344;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(180deg, rgba(88, 171, 222, 0.96) 0%, rgba(177, 220, 244, 0.9) 34%, rgba(63, 103, 98, 0.94) 35%, rgba(10, 29, 43, 1) 100%);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
}

.scene {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.scene::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, transparent 0 17%, rgba(255, 255, 255, 0.18) 17.2% 17.5%, transparent 17.8% 81.8%, rgba(255, 255, 255, 0.15) 82% 82.3%, transparent 82.6%),
        linear-gradient(180deg, transparent 0 48%, rgba(255, 255, 255, 0.14) 48.2% 48.4%, transparent 48.6%);
    opacity: 0.38;
}

.cloud {
    position: absolute;
    height: 62px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.48);
    filter: blur(1px);
}

.cloud::before,
.cloud::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.52);
}

.cloud::before {
    width: 72px;
    height: 72px;
    left: 36px;
    top: -28px;
}

.cloud::after {
    width: 96px;
    height: 96px;
    right: 28px;
    top: -46px;
}

.cloud-a {
    width: 230px;
    left: 8vw;
    top: 12vh;
}

.cloud-b {
    width: 290px;
    right: 8vw;
    top: 20vh;
    opacity: 0.65;
}

.runway {
    position: absolute;
    left: 50%;
    bottom: -18vh;
    width: min(48vw, 660px);
    height: 72vh;
    transform: translateX(-50%) perspective(720px) rotateX(62deg);
    transform-origin: bottom;
    background:
        repeating-linear-gradient(180deg, transparent 0 58px, rgba(255, 255, 255, 0.78) 58px 92px, transparent 92px 142px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.36) 0 2px, transparent 2px calc(100% - 2px), rgba(255, 255, 255, 0.36) calc(100% - 2px) 100%),
        linear-gradient(180deg, #364357, #111a25);
    clip-path: polygon(41% 0, 59% 0, 100% 100%, 0 100%);
    opacity: 0.72;
}

.app-shell {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto;
    padding: 26px 0 34px;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 22px;
    align-items: end;
    margin-bottom: 18px;
}

.eyebrow,
.section-kicker {
    margin: 0 0 7px;
    color: var(--cyan);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 900px;
    margin-bottom: 10px;
    font-size: clamp(2.1rem, 5vw, 5.2rem);
    line-height: 0.95;
}

h2 {
    margin-bottom: 0;
    font-size: clamp(1.35rem, 2vw, 2rem);
}

.subtitle {
    max-width: 740px;
    margin-bottom: 0;
    color: #eaf6ff;
    font-size: 1.05rem;
    line-height: 1.55;
}

.status-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(86px, 1fr));
    gap: 10px;
    min-width: min(380px, 100%);
}

.status-panel > div {
    padding: 14px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(3, 13, 24, 0.7);
    box-shadow: var(--shadow);
}

.status-panel span {
    display: block;
    font-size: 1.5rem;
    font-weight: 850;
    line-height: 1;
}

.status-panel small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.74rem;
}

.tabbar {
    display: flex;
    gap: 9px;
    align-items: center;
    margin-bottom: 10px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.dynamic-tabs {
    display: flex;
    gap: 9px;
}

.tab-button {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: rgba(5, 18, 31, 0.75);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tab-button:hover {
    transform: translateY(-1px);
    border-color: rgba(121, 240, 255, 0.65);
}

.tab-button.is-active {
    border-color: rgba(121, 240, 255, 0.85);
    background: linear-gradient(180deg, rgba(31, 122, 169, 0.84), rgba(5, 24, 43, 0.86));
}

.tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 20px;
    margin-right: 6px;
    border: 1px solid rgba(121, 240, 255, 0.45);
    border-radius: 4px;
    color: var(--cyan);
    font-size: 0.68rem;
    font-weight: 850;
}

.tab-add {
    color: #06101d;
    border-color: rgba(255, 204, 102, 0.7);
    background: linear-gradient(180deg, #ffe19a, var(--amber));
    font-weight: 800;
}

.command-row {
    display: flex;
    gap: 10px;
    align-items: end;
    justify-content: space-between;
    margin-bottom: 14px;
}

.tab-create {
    display: flex;
    gap: 10px;
    width: min(520px, 100%);
    margin-left: auto;
    padding: 10px;
    border: 1px solid rgba(255, 204, 102, 0.4);
    border-radius: 8px;
    background: rgba(7, 18, 30, 0.88);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(310px, 370px);
    gap: 18px;
    align-items: start;
}

.workspace {
    min-width: 0;
}

.panel,
.calculator {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.panel {
    padding: 18px;
}

.panel-head,
.calculator-head {
    display: flex;
    gap: 16px;
    align-items: start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-note {
    max-width: 640px;
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.mode-control,
.tool-form label,
.calc-grid label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.82rem;
}

.mode-control {
    width: min(220px, 100%);
}

.global-mode {
    flex: 0 0 min(220px, 100%);
    padding: 10px;
    border: 1px solid rgba(201, 230, 255, 0.2);
    border-radius: 8px;
    background: rgba(5, 18, 31, 0.72);
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(201, 230, 255, 0.24);
    border-radius: 6px;
    color: var(--ink);
    background: rgba(2, 9, 18, 0.74);
    outline: none;
}

input {
    padding: 0 12px;
}

select {
    padding: 0 34px 0 12px;
}

input:focus,
select:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(121, 240, 255, 0.16);
}

.tool-form {
    display: grid;
    grid-template-columns: minmax(150px, 0.9fr) minmax(220px, 1.3fr) minmax(220px, 1.25fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.primary-button {
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 6px;
    color: #06101d;
    background: linear-gradient(180deg, #8df4ff, var(--blue));
    font-weight: 850;
    box-shadow: 0 8px 22px rgba(75, 183, 255, 0.28);
}

.primary-button:hover {
    filter: brightness(1.06);
}

.primary-button:disabled {
    cursor: wait;
    filter: grayscale(0.4);
    opacity: 0.7;
}

.primary-button.compact {
    padding: 0 14px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.tool-card {
    position: relative;
    display: grid;
    gap: 14px;
    min-height: 190px;
    padding: 16px;
    border: 1px solid rgba(201, 230, 255, 0.2);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(18, 70, 105, 0.88), rgba(7, 18, 30, 0.92)),
        repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 255, 255, 0.035) 18px 19px);
}

.tool-card::before {
    content: "";
    position: absolute;
    inset: 11px 11px auto auto;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(126, 224, 139, 0.42);
    border-radius: 50%;
    background:
        linear-gradient(90deg, transparent 48%, rgba(126, 224, 139, 0.55) 49% 51%, transparent 52%),
        linear-gradient(0deg, transparent 48%, rgba(126, 224, 139, 0.55) 49% 51%, transparent 52%);
    opacity: 0.46;
}

.tool-card h3 {
    max-width: calc(100% - 42px);
    margin: 0;
    font-size: 1.18rem;
    line-height: 1.25;
}

.tool-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.48;
}

.tool-card time {
    color: rgba(246, 251, 255, 0.62);
    font-size: 0.78rem;
}

.launch-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin-top: auto;
    border: 1px solid rgba(121, 240, 255, 0.45);
    border-radius: 6px;
    color: #eafdff;
    text-decoration: none;
    background: rgba(3, 13, 24, 0.56);
    font-weight: 800;
}

.launch-button:hover {
    border-color: var(--cyan);
    background: rgba(121, 240, 255, 0.14);
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 6px;
    color: var(--ink);
    background: rgba(3, 13, 24, 0.74);
    font-size: 1.1rem;
    font-weight: 900;
}

.danger {
    color: #fff6f6;
    border-color: rgba(255, 111, 117, 0.7);
    background: rgba(108, 22, 30, 0.82);
}

.delete-control {
    display: none;
}

.is-delete-mode .delete-control {
    display: inline-flex;
}

.tool-card .delete-control {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
}

.upload-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: stretch;
    margin-bottom: 16px;
}

.upload-box input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.upload-box label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px;
    align-items: center;
    min-height: 78px;
    padding: 14px;
    border: 1px dashed rgba(121, 240, 255, 0.55);
    border-radius: 8px;
    background: rgba(4, 16, 28, 0.68);
}

.upload-mark {
    grid-row: span 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #06101d;
    background: var(--amber);
    font-size: 1.45rem;
    font-weight: 900;
}

.upload-box small {
    color: var(--muted);
}

.file-list {
    display: grid;
    gap: 10px;
}

.file-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid rgba(201, 230, 255, 0.18);
    border-radius: 8px;
    background: rgba(4, 15, 27, 0.72);
}

.file-type {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid rgba(255, 204, 102, 0.45);
    border-radius: 5px;
    color: var(--amber);
    font-size: 0.74rem;
    font-weight: 850;
    text-transform: uppercase;
}

.file-row h3 {
    margin: 0 0 4px;
    overflow-wrap: anywhere;
    font-size: 1rem;
}

.file-row p {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.file-open {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(121, 240, 255, 0.45);
    border-radius: 6px;
    color: var(--cyan);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.empty-state {
    padding: 22px;
    border: 1px dashed rgba(201, 230, 255, 0.25);
    border-radius: 8px;
    color: var(--muted);
    background: rgba(4, 15, 27, 0.48);
    text-align: center;
}

.calculator {
    position: sticky;
    top: 18px;
    padding: 18px;
    background: var(--panel-strong);
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.calc-result {
    margin-top: 16px;
    padding: 15px;
    border: 1px solid rgba(126, 224, 139, 0.38);
    border-radius: 8px;
    background: rgba(11, 44, 35, 0.72);
}

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

.calc-result strong {
    display: block;
    margin: 6px 0;
    color: #ecfff0;
    font-size: 2rem;
    line-height: 1.05;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    max-width: min(420px, calc(100vw - 36px));
    padding: 13px 15px;
    border: 1px solid rgba(121, 240, 255, 0.4);
    border-radius: 8px;
    color: var(--ink);
    background: rgba(5, 18, 31, 0.94);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.is-error {
    border-color: rgba(255, 111, 117, 0.78);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1060px) {
    .topbar,
    .layout {
        grid-template-columns: 1fr;
    }

    .calculator {
        position: static;
    }

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

    .tool-form .primary-button {
        grid-column: span 2;
    }
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 20px, 1480px);
        padding-top: 14px;
    }

    h1 {
        font-size: clamp(2rem, 14vw, 3.3rem);
    }

    .status-panel,
    .tool-form,
    .upload-box,
    .file-row,
    .calc-grid {
        grid-template-columns: 1fr;
    }

    .panel,
    .calculator {
        padding: 14px;
    }

    .panel-head {
        display: grid;
    }

    .mode-control {
        width: 100%;
    }

    .tool-form .primary-button {
        grid-column: auto;
    }

    .tab-create {
        margin-left: 0;
    }

    .command-row {
        display: grid;
    }

    .file-open,
    .file-row .icon-button {
        width: 100%;
        justify-content: center;
    }

    .runway {
        width: 92vw;
    }
}
