@font-face {
    font-family: "Nexus Orbitron";
    src: url("../../assets/fonts/google/Orbitron-wght.ttf") format("truetype");
    font-weight: 400 900;
    font-style: normal;
}

@font-face {
    font-family: "Nexus Exo 2";
    src: url("../../assets/fonts/google/Exo2-wght.ttf") format("truetype");
    font-weight: 400 900;
    font-style: normal;
}

@font-face {
    font-family: "Nexus Share Tech Mono";
    src: url("../../assets/fonts/google/ShareTechMono-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: "Nexus Rajdhani";
    src: url("../../assets/fonts/google/Rajdhani-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
}

:root {
    color-scheme: dark;
    --primary: #3fb8aa;
    --on-primary: #031816;
    --primary-container: #0f302c;
    --on-primary-container: #b7e7df;
    --secondary-container: #102522;
    --on-secondary-container: #c1ddd8;
    --surface: #050b0a;
    --surface-low: #081311;
    --surface-high: #0d1c19;
    --on-surface: #e2f5f1;
    --on-surface-muted: #91aca6;
    --outline: #4d857b;
    --outline-soft: #153d37;
    --error: #ffb4ab;
    --success: #a9ffcb;
    --accent: #a8c957;
    --accent-soft: rgba(168, 201, 87, 0.075);
    --panel-glow: rgba(63, 184, 170, 0.04);
    --grid-line: rgba(63, 184, 170, 0.035);
    --shadow: rgba(0, 0, 0, 0.44);
    --radius: 8px;
    --font-ui: Inter, Roboto, "Segoe UI", Arial, sans-serif;
    --font-title: "Nexus Orbitron";
    --font-data: "Nexus Share Tech Mono";
}

[hidden] {
    display: none !important;
}

.editor-panel,
.editor-panel *,
.control-panel,
.control-panel * {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--on-surface);
    background:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
        linear-gradient(135deg, var(--surface) 0%, var(--surface-low) 58%, var(--surface-high) 100%);
    background-size: 34px 34px, 34px 34px, auto;
    font-family: var(--font-ui);
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

.noscript-alert {
    margin: 1rem;
    padding: 0.75rem 1rem;
    color: var(--error);
    background: color-mix(in srgb, var(--error) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
    border-radius: var(--radius);
}

.app-header {
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 26%, var(--outline-soft));
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--primary) 6%, transparent), transparent 34%),
        color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: 0 12px 34px var(--shadow);
}

.eyebrow {
    margin: 0 0 2px;
    color: var(--primary);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-family: var(--font-title), "Cascadia Mono", "Segoe UI", var(--font-ui);
    font-size: clamp(1.55rem, 4vw, 2.35rem);
    font-weight: 700;
    line-height: 1.1;
    min-height: 1.1em;
    text-transform: uppercase;
}

h1 a,
h1 a:hover {
    color: inherit;
    text-decoration: none;
}

h2 {
    margin-bottom: 0;
    font-family: "Cascadia Mono", "Segoe UI", var(--font-ui);
    font-size: 1.2rem;
    text-transform: uppercase;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 78px;
}

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

.workspace > *,
.editor-panel > *,
.control-panel > *,
.panel-heading > *,
.metadata > *,
.actions > *,
.setting-area > *,
.method-settings > * {
    min-width: 0;
}

.editor-panel,
.control-panel {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface-high) 24%, transparent), transparent 170px),
        color-mix(in srgb, var(--surface) 96%, #000000 4%);
    border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--outline-soft));
    border-radius: var(--radius);
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--primary) 5%, transparent),
        0 0 10px var(--panel-glow),
        0 10px 22px color-mix(in srgb, var(--shadow) 64%, transparent);
}

.editor-panel {
    min-width: 0;
    min-height: calc(100vh - 180px);
    padding: 16px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 14px;
    overflow: visible;
}

.control-panel {
    position: sticky;
    top: 18px;
    padding: 18px;
    display: grid;
    gap: 18px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.remember-toggle {
    min-height: 34px;
    padding: 6px 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #eeeaff;
    border: 1px solid color-mix(in srgb, #8f7cff 46%, var(--outline-soft));
    border-radius: 999px;
    background:
        linear-gradient(135deg, color-mix(in srgb, #8f7cff 28%, transparent), color-mix(in srgb, #3fb8aa 10%, transparent)),
        color-mix(in srgb, var(--surface-high) 86%, transparent);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.remember-toggle.is-off {
    color: var(--on-surface-muted);
    border-color: color-mix(in srgb, var(--outline-soft) 76%, transparent);
    background: color-mix(in srgb, var(--surface-low) 82%, transparent);
}

.remember-toggle i {
    color: #a99cff;
    font-size: 1.05rem;
    line-height: 1;
}

.remember-toggle.is-off i {
    color: var(--on-surface-muted);
}

.editor-panel__top,
.metadata,
.actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.editor-panel__top {
    justify-content: space-between;
}

.editor-label,
.field span {
    color: var(--on-surface-muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.metadata {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: min(100%, 300px);
}

.metadata p {
    margin: 0;
    padding: 6px 10px;
    color: var(--on-primary-container);
    background: color-mix(in srgb, var(--primary-container) 78%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
    border-radius: 6px;
    font-family: var(--font-data), "Cascadia Mono", Consolas, monospace;
    font-size: 0.86rem;
    text-align: center;
}

.metadata strong {
    color: var(--primary);
}

input,
select,
textarea {
    width: 100%;
    color: var(--on-surface);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface-high) 46%, transparent), transparent),
        var(--surface-low);
    border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--outline-soft));
    border-radius: var(--radius);
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input,
select {
    min-height: 44px;
    padding: 0 12px;
}

textarea {
    display: block;
    height: 100%;
    max-width: 100%;
    min-height: 0;
    padding: 18px;
    resize: vertical;
    font-family: "Cascadia Mono", Consolas, "Liberation Mono", monospace;
    font-size: 0.98rem;
    line-height: 1.75;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 8%, transparent);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--primary) 11%, transparent),
        0 0 12px color-mix(in srgb, var(--primary) 8%, transparent);
}

.settings-panel {
    min-height: 0;
    padding-top: 2px;
    padding-bottom: 0;
}

.setting-group {
    display: grid;
    gap: 12px;
}

.settings-grid {
    display: grid;
    gap: 12px;
}

.empty-settings {
    margin: 0;
    min-height: 54px;
    padding: 14px;
    color: var(--on-surface-muted);
    background: color-mix(in srgb, var(--surface-low) 76%, transparent);
    border: 1px dashed color-mix(in srgb, var(--primary) 38%, var(--outline-soft));
    border-radius: var(--radius);
}

.is-typing::after {
    content: "_";
    display: inline-block;
    margin-left: 2px;
    color: var(--accent);
    animation: typing-caret 700ms steps(1) infinite;
}

textarea.is-typing {
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent),
        0 0 12px color-mix(in srgb, var(--primary) 10%, transparent),
        inset 0 0 0 1px color-mix(in srgb, var(--primary) 8%, transparent);
}

textarea.is-feedback-flashing {
    animation: text-area-success-flash 1200ms ease-in-out;
}

.segmented-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 5px;
    background: color-mix(in srgb, var(--surface-low) 78%, #000000 4%);
    border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--outline-soft));
    border-radius: var(--radius);
}

.segmented-control input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.segmented-control label {
    min-height: 38px;
    padding: 8px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--on-surface-muted);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    text-align: center;
    transition: background-color 150ms ease, color 150ms ease;
}

.segmented-control input:checked + label {
    color: var(--on-primary-container);
    background: var(--primary-container);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 12%, transparent);
}

.actions {
    display: grid;
    grid-template-columns: 44px 44px minmax(150px, 220px) 44px 44px;
    justify-content: center;
    position: relative;
    z-index: 1;
    align-self: end;
    margin-top: 2px;
}

.button,
.icon-button {
    min-height: 44px;
    border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    position: relative;
    box-shadow:
        inset 0 -3px 0 color-mix(in srgb, #000000 26%, transparent),
        0 6px 0 color-mix(in srgb, #000000 22%, transparent),
        0 14px 24px var(--shadow);
    transform: translateY(0);
    transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.button:hover,
.icon-button:hover {
    border-color: color-mix(in srgb, var(--primary) 28%, transparent);
    filter: brightness(1.02);
    transform: none;
    box-shadow:
        inset 0 -3px 0 color-mix(in srgb, #000000 24%, transparent),
        0 6px 0 color-mix(in srgb, #000000 20%, transparent),
        0 14px 24px var(--shadow);
}

.button:active,
.icon-button:active {
    transform: scaleY(0.94);
    transform-origin: bottom;
    box-shadow:
        inset 0 -1px 0 color-mix(in srgb, #000000 12%, transparent),
        0 1px 0 color-mix(in srgb, #000000 12%, transparent),
        0 8px 16px var(--shadow);
}

.button:disabled,
.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
    box-shadow:
        0 2px 0 color-mix(in srgb, #000000 10%, transparent);
}

.button--primary {
    min-width: 180px;
    padding: 0 18px;
    color: var(--on-primary);
    background:
        linear-gradient(180deg, color-mix(in srgb, #ffffff 18%, transparent), transparent 52%),
        var(--primary);
}

.button--tonal,
.button--ghost,
.icon-button {
    color: var(--on-secondary-container);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--primary) 14%, transparent), transparent),
        var(--secondary-container);
}

.icon-button--danger {
    color: #ffffff;
    border-color: #8f2e29;
    background: #a93a34;
    filter: none;
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.26),
        0 6px 0 rgba(0, 0, 0, 0.22),
        0 14px 24px var(--shadow);
}

.icon-button--danger:hover,
.icon-button--danger:active {
    color: #ffffff;
    border-color: #8f2e29;
    background: #a93a34;
    filter: none;
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.24),
        0 6px 0 rgba(0, 0, 0, 0.2),
        0 14px 24px var(--shadow);
}

.icon-button--danger:active {
    transform: scaleY(0.94);
    transform-origin: bottom;
    box-shadow:
        inset 0 -1px 0 rgba(0, 0, 0, 0.14),
        0 1px 0 rgba(0, 0, 0, 0.14),
        0 8px 16px var(--shadow);
}

.button--tonal,
.button--ghost {
    padding: 0 16px;
}

.button--ghost {
    min-width: 92px;
}

.icon-button {
    width: 44px;
    padding: 0;
}

.icon-button img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.icon-button svg {
    width: 21px;
    height: 21px;
    fill: currentColor;
}

.icon-button .bi {
    width: 20px;
    height: 20px;
}

.icon-button.is-muted {
    opacity: 0.72;
}

.about__header .icon-button {
    width: 38px;
    min-height: 38px;
    flex: 0 0 38px;
}

.icon-button--no-glow {
    box-shadow:
        inset 0 -3px 0 color-mix(in srgb, #000000 26%, transparent),
        0 6px 0 color-mix(in srgb, #000000 22%, transparent),
        0 14px 24px var(--shadow);
}

.text-dialog {
    width: min(460px, calc(100% - 32px));
    padding: 0;
    color: var(--on-surface);
    border: 1px solid color-mix(in srgb, var(--primary) 42%, var(--outline-soft));
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, transparent), color-mix(in srgb, var(--accent) 6%, transparent)),
        var(--surface);
    box-shadow: 0 24px 70px var(--shadow);
}

.text-dialog::backdrop {
    background: rgba(2, 8, 7, 0.72);
    backdrop-filter: blur(6px);
}

.text-dialog__panel {
    padding: 20px;
    display: grid;
    gap: 14px;
}

.text-dialog__header,
.text-dialog__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.text-dialog h2 {
    margin: 0;
    color: var(--primary);
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.text-dialog p {
    margin: 0;
    color: var(--on-surface-muted);
}

.text-dialog.is-error h2 {
    color: var(--error);
}

.text-dialog.is-confirmation h2 {
    color: #ff7a70;
}

.text-dialog.is-confirmation .button {
    border-bottom: 4px solid color-mix(in srgb, #000000 34%, var(--secondary-container));
    filter: none;
    box-shadow: none;
}

.text-dialog.is-confirmation .button:hover,
.text-dialog.is-confirmation .button:active {
    filter: none;
    box-shadow: none;
}

.text-dialog.is-confirmation .button:active {
    border-bottom-width: 1px;
    transform: scaleY(0.94);
    transform-origin: bottom;
}

.text-dialog.is-confirmation .button--ghost {
    color: var(--on-secondary-container);
    border-bottom: 4px solid #071615;
    background: var(--secondary-container);
    box-shadow: none;
}

.text-dialog.is-confirmation .button--ghost:hover,
.text-dialog.is-confirmation .button--ghost:active {
    color: var(--on-secondary-container);
    border-bottom: 4px solid #071615;
    background: var(--secondary-container);
    filter: none;
    box-shadow: none;
}

.text-dialog.is-confirmation .button--ghost:active {
    border-bottom-width: 1px;
    transform: scaleY(0.94);
    transform-origin: bottom;
}

.text-dialog.is-confirmation .button--primary {
    color: #ffffff;
    border-bottom: 4px solid #6f211d;
    background: #a93a34;
    filter: none;
    box-shadow: none;
}

.text-dialog.is-confirmation .button--primary:hover,
.text-dialog.is-confirmation .button--primary:active {
    color: #ffffff;
    background: #a93a34;
    filter: none;
    box-shadow: none;
}

.text-dialog.is-confirmation .button--primary:active {
    border-bottom-width: 1px;
    transform: scaleY(0.94);
    transform-origin: bottom;
    filter: none;
    box-shadow: none;
}

.text-dialog__close {
    width: 34px;
    height: 34px;
    color: #fff;
    border: 1px solid color-mix(in srgb, #ffffff 78%, transparent);
    border-radius: 6px;
    background: #a93a34;
    cursor: pointer;
    font-weight: 900;
}

.text-dialog__close:active {
    filter: brightness(0.92);
    transform: scale(0.97);
}

.text-dialog__actions {
    justify-content: flex-end;
}

.text-dialog__actions .button {
    min-width: 92px;
    min-height: 38px;
    padding: 0 14px;
}

.about {
    margin-top: 18px;
    padding: 18px;
    color: var(--on-surface-muted);
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--primary) 5%, transparent), transparent 30%),
        var(--surface);
    border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--outline-soft));
    border-radius: var(--radius);
    box-shadow:
        0 0 8px color-mix(in srgb, var(--primary) 4%, transparent),
        0 10px 22px color-mix(in srgb, var(--shadow) 48%, transparent);
}

.about h2 {
    color: var(--on-surface);
}

.about__header {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.about-collapsed {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(22px, 5vw, 42px);
}

.about-collapsed__item {
    width: clamp(22px, 3.2vw, 32px);
    height: clamp(22px, 3.2vw, 32px);
    display: block;
    background: color-mix(in srgb, var(--accent) 28%, var(--primary));
    border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--outline-soft));
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-soft);
}

.about-collapsed__item.is-bouncing {
    animation: bounce-dot 1100ms cubic-bezier(0.18, 0.82, 0.24, 1);
}

.about p {
    max-width: 920px;
    min-height: 1.5em;
    margin-bottom: 12px;
}

.about section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--outline-soft);
}

.about h3 {
    margin: 0 0 8px;
    color: var(--primary);
}

.about strong {
    color: var(--primary);
}

.privacy-note {
    margin-top: 18px;
    padding: 14px 16px;
    color: var(--on-primary-container);
    background:
        linear-gradient(90deg, var(--accent-soft), transparent),
        var(--primary-container);
    border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent);
    border-radius: var(--radius);
    font-weight: 700;
}

@media (max-width: 900px) {

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

    .control-panel {
        position: static;
        order: -1;
    }

    .editor-panel {
        min-height: auto;
        grid-template-rows: auto minmax(320px, 52vh) auto;
    }

}

@keyframes bounce-dot {

    0% {
        transform: translateY(0) scale(1);
    }

    28% {
        transform: translateY(-46px) scale(1.04);
    }

    48% {
        transform: translateY(0) scale(0.96);
    }

    62% {
        transform: translateY(-18px) scale(1.02);
    }

    76% {
        transform: translateY(0) scale(0.98);
    }

    88% {
        transform: translateY(-7px) scale(1.01);
    }

    100% {
        transform: translateY(0) scale(1);
    }

}

@keyframes typing-caret {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }

}

@keyframes text-area-success-flash {

    0% {
        border-color: color-mix(in srgb, var(--primary) 32%, var(--outline-soft));
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 8%, transparent);
    }

    20%,
    48% {
        border-color: #ff4fd8;
        box-shadow:
            0 0 0 3px rgba(255, 79, 216, 0.22),
            0 0 32px rgba(255, 176, 0, 0.3),
            inset 0 0 0 1px rgba(255, 79, 216, 0.28);
    }

    72% {
        border-color: color-mix(in srgb, #ff4fd8 48%, var(--primary));
        box-shadow:
            0 0 0 2px rgba(255, 79, 216, 0.12),
            0 0 16px rgba(255, 176, 0, 0.16),
            inset 0 0 0 1px rgba(255, 79, 216, 0.14);
    }

    100% {
        border-color: color-mix(in srgb, var(--primary) 32%, var(--outline-soft));
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 8%, transparent);
    }

}

@media (max-width: 620px) {
    .app-shell {
        width: calc(100% - 20px);
    }

    .app-shell {
        margin-top: 10px;
        margin-bottom: 20px;
    }

    .editor-panel,
    .control-panel,
    .about {
        padding: 12px;
    }

    .editor-panel__top,
    .metadata,
    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .metadata {
        gap: 8px;
    }

    .metadata p,
    .button,
    .button--primary,
    .button--ghost {
        width: 100%;
    }

    .icon-button {
        width: 100%;
    }

    .actions {
        grid-template-columns: 44px minmax(128px, 1fr) 44px;
        column-gap: 8px;
        row-gap: 8px;
        align-self: auto;
        margin-top: 0;
    }

    .actions .icon-button {
        width: 44px;
    }

    .actions #modifyButton {
        width: 100%;
        min-width: 0;
    }

    #clearButton {
        grid-column: 1;
        grid-row: 2;
    }

    #undoButton {
        grid-column: 1;
        grid-row: 1;
    }

    #modifyButton {
        grid-column: 2;
        grid-row: 1;
    }

    #redoButton {
        grid-column: 3;
        grid-row: 1;
    }

    #copyButton {
        grid-column: 3;
        grid-row: 2;
    }

}
