:root {
    --bg: #050505;
    --bg-soft: #0d0d0d;
    --panel: rgba(15, 15, 15, 0.94);
    --panel-alt: rgba(24, 24, 24, 0.96);
    --panel-muted: rgba(255, 255, 255, 0.05);
    --text: #fafafa;
    --text-muted: #b8b8b8;
    --text-soft: #8f8f8f;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);
    --shadow: 0 26px 80px rgba(0, 0, 0, 0.55);
    --button-bg: #f5f5f5;
    --button-text: #050505;
    --chip-bg: #ffffff;
    --chip-text: #050505;
    --error-bg: rgba(255, 255, 255, 0.06);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), transparent 22rem),
        radial-gradient(circle at 85% 10%, rgba(255, 255, 255, 0.08), transparent 18rem),
        linear-gradient(180deg, #020202 0%, #090909 46%, #111111 100%);
    background-color: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), transparent 22rem),
        radial-gradient(circle at 85% 10%, rgba(255, 255, 255, 0.08), transparent 18rem),
        linear-gradient(180deg, #020202 0%, #090909 46%, #111111 100%);
    background-color: var(--bg);
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
    overflow-x: hidden;
}

a {
    color: inherit;
}

code {
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
    font-size: 0.9em;
}

strong {
    font-weight: 600;
}

[hidden] {
    display: none !important;
}

.page-frame {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    padding:
        calc(1.2rem + env(safe-area-inset-top))
        calc(1.2rem + env(safe-area-inset-right))
        calc(1.2rem + env(safe-area-inset-bottom))
        calc(1.2rem + env(safe-area-inset-left));
    overflow: hidden;
}

.page-grid,
.page-glow {
    position: absolute;
    pointer-events: none;
}

.page-grid {
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 2.8rem 2.8rem;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0.32));
}

.page-glow {
    width: 30rem;
    height: 30rem;
    border-radius: 999px;
    filter: blur(18px);
    opacity: 0.52;
}

.page-glow-left {
    left: -9rem;
    top: -4rem;
    background: rgba(255, 255, 255, 0.08);
}

.page-glow-right {
    right: -9rem;
    top: 9rem;
    background: rgba(255, 255, 255, 0.06);
}

.site-header {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.35rem 0 0;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    flex: 1 1 auto;
    gap: 0.9rem;
    min-width: 0;
    text-decoration: none;
}

.brand-mark__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark__icon svg {
    width: 1.3rem;
    height: 1.3rem;
    fill: #f4f4f4;
}

.brand-mark__copy {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.brand-mark__title,
.brand-mark__subtitle {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-mark__title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.brand-mark__subtitle {
    color: var(--text-soft);
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.header-controls {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.9rem;
    margin-left: auto;
}

.secondary-link,
.secondary-button,
.profile-dropdown__link,
.profile-dropdown__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.8rem;
    padding: 0 1rem;
    border-radius: 999px;
    text-decoration: none;
    font: inherit;
}

    .secondary-link,
    .secondary-button {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.secondary-link:hover,
.secondary-button:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.06);
}

.profile-menu {
    position: relative;
    z-index: 30;
}

.profile-menu summary {
    list-style: none;
}

.profile-menu summary::-webkit-details-marker {
    display: none;
}

.profile-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 3rem;
    padding: 0.35rem 0.45rem 0.35rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.profile-trigger:hover,
.profile-menu[open] .profile-trigger {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.08);
}

.profile-trigger__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    background: #fafafa;
    color: #050505;
    font-size: 0.92rem;
    font-weight: 700;
}

.profile-trigger__text {
    display: grid;
    line-height: 1.15;
    min-width: 0;
}

.profile-trigger__label {
    color: var(--text-soft);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.profile-trigger__name {
    font-size: 0.94rem;
    font-weight: 600;
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-trigger__caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 1.05rem;
    line-height: 1;
}

.profile-menu[open] .profile-trigger__caret {
    transform: rotate(45deg);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 0.7rem);
    right: 0;
    display: grid;
    gap: 0.55rem;
    min-width: 15rem;
    max-width: min(18rem, calc(100vw - 2rem));
    padding: 1rem;
    border-radius: 1.2rem;
    border: 1px solid var(--border);
    background: rgba(14, 14, 14, 0.98);
    box-shadow: var(--shadow);
    z-index: 40;
}

.profile-dropdown__eyebrow {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.profile-dropdown__name {
    margin: 0 0 0.3rem;
    font-size: 1rem;
    font-weight: 700;
}

.profile-dropdown__link,
.profile-dropdown__button {
    width: 100%;
    justify-content: flex-start;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

.profile-dropdown__button {
    cursor: pointer;
}

.profile-dropdown__form {
    margin: 0;
}

.site-main {
    position: relative;
    z-index: 5;
    max-width: 1180px;
    margin: 0 auto;
    padding: 2.4rem 0 1rem;
}

.auth-body--signup .site-main {
    max-width: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auth-body--signup .flash-stack,
.auth-body--signup .auth-layout--centered {
    width: min(100%, 32rem);
}

.flash-stack {
    display: grid;
    gap: 0.75rem;
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.flash-message {
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
}

.surface-card {
    border: 1px solid var(--border);
    border-radius: 1.8rem;
    background: linear-gradient(180deg, rgba(20, 20, 20, 0.98) 0%, rgba(11, 11, 11, 0.96) 100%);
    box-shadow: var(--shadow);
}

.auth-layout,
.workspace-grid {
    display: grid;
    gap: 1.4rem;
}

.auth-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(22rem, 0.95fr);
    align-items: center;
    min-height: calc(100vh - 11rem);
}

.auth-layout--centered {
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
}

.auth-layout--centered .auth-card {
    width: 100%;
}

.auth-layout--centered .section-heading {
    text-align: center;
}

.auth-copy,
.hero-panel,
.page-heading,
.workspace-panel,
.tool-card,
.auth-card,
.settings-panel {
    animation: rise-in 360ms ease both;
}

.auth-copy {
    padding-right: 1.6rem;
}

.eyebrow,
.tool-card__tag,
.result-group__eyebrow {
    margin: 0 0 0.85rem;
    color: var(--text-soft);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
    font-weight: 600;
    letter-spacing: -0.03em;
}

h1 {
    max-width: 12ch;
    font-size: clamp(2.8rem, 5vw, 5rem);
    line-height: 0.92;
}

h2 {
    font-size: 1.7rem;
    line-height: 1.06;
}

p {
    margin: 0;
}

.section-copy {
    margin-top: 1rem;
    max-width: 42rem;
    color: var(--text-muted);
    font-size: 1.02rem;
    line-height: 1.72;
}

.auth-card,
.workspace-panel,
.settings-panel {
    padding: 1.9rem;
}

.hero-panel,
.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.hero-panel {
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1.4rem;
}

.tool-card {
    display: grid;
    gap: 1rem;
    padding: 1.8rem;
}

.tool-card p:last-of-type {
    color: var(--text-muted);
    line-height: 1.7;
}

.page-heading {
    margin-bottom: 1.4rem;
}

.workspace-grid {
    grid-template-columns: minmax(0, 0.96fr) minmax(0, 1.04fr);
    align-items: start;
}

.section-heading {
    margin-bottom: 1.4rem;
}

.section-heading p:last-child {
    margin-top: 0.75rem;
    color: var(--text-muted);
    line-height: 1.68;
}

.stack-form {
    display: grid;
    gap: 1rem;
}

.form-row {
    display: grid;
    gap: 0.45rem;
}

.form-row label {
    font-size: 0.92rem;
    font-weight: 600;
}

.label-note {
    color: var(--text-soft);
    font-weight: 500;
}

.form-input,
.form-textarea,
.result-output {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font: inherit;
    padding: 0.95rem 1rem;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.form-input {
    min-height: 3.2rem;
}

.form-textarea,
.result-output {
    min-height: 12rem;
    resize: vertical;
    line-height: 1.65;
}

.result-output {
    min-height: 7rem;
    background: rgba(255, 255, 255, 0.04);
}

.form-input:focus,
.form-textarea:focus,
.result-output:focus {
    outline: none;
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.26);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

.field-help {
    color: var(--text-soft);
    font-size: 0.89rem;
    line-height: 1.56;
}

.field-error {
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.5;
}

.errorlist {
    margin: 0;
    padding-left: 1rem;
    color: var(--text);
    line-height: 1.55;
}

.form-alert {
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    line-height: 1.58;
}

.form-alert--error {
    border-color: rgba(255, 96, 96, 0.42);
    background: rgba(120, 10, 10, 0.28);
    color: #ffb4b4;
}

.error-summary-list {
    margin: 0;
    padding-left: 1rem;
    line-height: 1.55;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3.2rem;
    padding: 0 1.3rem;
    border: 0;
    border-radius: 999px;
    background: var(--button-bg);
    color: var(--button-text);
    text-decoration: none;
    font-size: 0.96rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

.primary-button:hover {
    transform: translateY(-2px);
}

.primary-button:disabled {
    cursor: progress;
    opacity: 0.74;
}

.wide-button {
    width: 100%;
}

.auth-footer {
    margin-top: 1.15rem;
    color: var(--text-soft);
    text-align: center;
    font-size: 0.9rem;
}

.auth-footer a,
.secondary-link,
.secondary-button {
    color: var(--text);
    font-weight: 600;
}

.secondary-button {
    cursor: pointer;
}

.secondary-button:disabled {
    cursor: not-allowed;
    opacity: 0.56;
    transform: none;
}

.result-groups {
    display: grid;
    gap: 1rem;
}

.result-group {
    display: grid;
    gap: 0.9rem;
    padding: 1.15rem;
    border-radius: 1.25rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
}

.result-group--error {
    border-style: dashed;
    background: var(--error-bg);
}

.result-group__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.result-group__meta {
    color: var(--text-muted);
    line-height: 1.58;
}

.result-output--group {
    min-height: 9.5rem;
}

.result-output--error {
    background: rgba(255, 255, 255, 0.02);
}

.result-copy-button {
    min-width: 11rem;
}

.result-copy-feedback {
    min-height: 1.4rem;
}

.empty-state {
    padding: 1.5rem;
    border-radius: 1.25rem;
    border: 1px dashed var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
}

.empty-state__title {
    margin-bottom: 0.42rem;
    color: var(--text);
    font-weight: 700;
}

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

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

    .auth-layout {
        min-height: auto;
        padding-top: 2rem;
    }

    .auth-copy {
        padding-right: 0;
    }
}

@media (max-width: 760px) {
    .page-frame {
        padding:
            calc(0.95rem + env(safe-area-inset-top))
            calc(0.95rem + env(safe-area-inset-right))
            calc(0.95rem + env(safe-area-inset-bottom))
            calc(0.95rem + env(safe-area-inset-left));
    }

    .site-header {
        align-items: center;
        flex-wrap: nowrap;
        gap: 0.75rem;
    }

    .hero-panel,
    .page-heading,
    .result-group__header {
        flex-direction: column;
    }

    .header-controls {
        margin-left: auto;
        align-items: center;
        flex: 0 0 auto;
        justify-content: flex-end;
    }

    .secondary-link,
    .secondary-button {
        width: auto;
    }

    .profile-menu {
        margin-left: 0;
    }

    .profile-trigger {
        max-width: 100%;
        width: auto;
        margin-left: 0;
    }

    .profile-trigger__text {
        max-width: clamp(6rem, 32vw, 8.5rem);
    }

    .profile-dropdown {
        right: 0;
        left: auto;
        width: min(18rem, calc(100vw - 2rem));
    }

    .result-copy-button {
        width: 100%;
    }

    .site-main {
        padding-top: 1.8rem;
    }

    .auth-card,
    .workspace-panel,
    .settings-panel,
    .hero-panel,
    .tool-card {
        padding: 1.35rem;
    }
}

@media (max-width: 560px) {
    h1 {
        max-width: none;
        font-size: clamp(2.3rem, 11vw, 3.2rem);
    }

    .brand-mark {
        min-height: 3rem;
    }

    .brand-mark__title {
        font-size: 0.92rem;
        letter-spacing: 0.12em;
    }

    .brand-mark__subtitle {
        display: none;
    }

    .profile-trigger {
        gap: 0.65rem;
        padding: 0.35rem 0.4rem 0.35rem 0.45rem;
    }

    .profile-trigger__name {
        max-width: 6.4rem;
    }
}
