:root {
    --void: #070910;
    --surface: rgba(7, 10, 18, 0.88);
    --surface-deep: rgba(4, 7, 13, 0.94);
    --ink: #f6f7fa;
    --ink-soft: rgba(235, 239, 246, 0.72);
    --muted: rgba(218, 225, 236, 0.48);
    --line: rgba(210, 223, 240, 0.22);
    --line-bright: rgba(219, 233, 247, 0.46);
    --signal: #d9604f;
    --signal-dark: #b84435;
    --relic: #8bc8dc;
    --gold: #e4bb63;
    --discord: #5865f2;
    --danger: #f07a70;
    --success: #7fd3ad;
    color-scheme: dark;
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-synthesis: none;
    letter-spacing: 0;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-width: 320px;
    min-height: 100%;
    margin: 0;
    background: var(--void);
}

body {
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
    letter-spacing: 0;
}

button {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(139, 200, 220, 0.58);
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}

.portal-shell {
    position: relative;
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    overflow: hidden;
    isolation: isolate;
    background: var(--void);
}

.portal-bg {
    position: absolute;
    z-index: -3;
    inset: -2%;
    width: 104%;
    height: 104%;
    object-fit: cover;
    object-position: center;
    animation: bg-breathe 18s ease-in-out infinite alternate;
}

.portal-veil {
    position: absolute;
    z-index: -2;
    inset: 0;
    pointer-events: none;
    background: rgba(3, 5, 11, 0.24);
}

.portal-veil::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 53%;
    background: rgba(3, 6, 13, 0.58);
    clip-path: polygon(0 0, 86% 0, 100% 18%, 91% 100%, 0 100%);
}

.portal-veil::after {
    content: '';
    position: absolute;
    inset: auto 0 0;
    height: 92px;
    background: rgba(3, 5, 10, 0.54);
    border-top: 1px solid rgba(214, 227, 242, 0.12);
}

.portal-title {
    position: absolute;
    z-index: 4;
    top: 30px;
    left: 36px;
    display: flex;
    align-items: stretch;
    gap: 12px;
    color: #fff;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.78);
}

.portal-title-rule {
    width: 4px;
    background: var(--signal);
    clip-path: polygon(0 0, 100% 6px, 100% 100%, 0 calc(100% - 6px));
}

.portal-title h1,
.portal-title p {
    margin: 0;
}

.portal-title h1 {
    font-size: 25px;
    line-height: 1.16;
    font-weight: 700;
}

.portal-title p {
    margin-top: 4px;
    color: var(--ink-soft);
    font-size: 11px;
}

.portal-rail {
    position: absolute;
    z-index: 4;
    top: 28px;
    right: 34px;
    width: 332px;
    padding: 15px 18px 14px;
    background: rgba(5, 8, 15, 0.7);
    border-right: 3px solid var(--relic);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
}

.status-card {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: baseline;
    column-gap: 10px;
}

.status-kicker {
    color: var(--relic);
    font-size: 10px;
    font-weight: 700;
}

.status-card strong {
    font-size: 15px;
    font-weight: 700;
}

.status-card p {
    grid-column: 2;
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 11px;
    line-height: 1.5;
}

.portal-stats {
    margin: 13px 0 0;
    padding: 10px 0 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    border-top: 1px solid var(--line);
}

.portal-stats div,
.portal-stats dt,
.portal-stats dd {
    min-width: 0;
    margin: 0;
}

.portal-stats dt {
    color: var(--muted);
    font-size: 9px;
}

.portal-stats dd {
    margin-top: 3px;
    overflow: hidden;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-workspace {
    position: relative;
    z-index: 2;
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    padding: 116px 42px 104px max(48px, calc((100vw - 1320px) / 2));
    display: flex;
    align-items: center;
}

.portal-window {
    position: relative;
    width: 450px;
    max-height: calc(100svh - 164px);
    padding: 29px 32px 30px;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line-bright);
    border-left: 3px solid var(--signal);
    clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 0 100%);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
    backdrop-filter: blur(16px);
    scrollbar-color: rgba(139, 200, 220, 0.45) transparent;
    scrollbar-width: thin;
}

.portal-window::before {
    content: '';
    position: absolute;
    top: 0;
    right: 15px;
    left: 0;
    height: 3px;
    background: rgba(139, 200, 220, 0.6);
}

.workspace-heading {
    margin-bottom: 23px;
}

.workspace-heading p,
.workspace-heading h2,
.workspace-heading span {
    margin: 0;
}

.workspace-heading p,
.panel-heading p {
    color: var(--signal);
    font-size: 11px;
    font-weight: 700;
}

.workspace-heading h2 {
    margin-top: 6px;
    font-size: 32px;
    line-height: 1.2;
    font-weight: 700;
}

.workspace-heading span {
    display: block;
    margin-top: 9px;
    color: var(--ink-soft);
    font-size: 12px;
    line-height: 1.55;
}

.maintenance-notice,
.global-message {
    margin: 0 0 18px;
}

.maintenance-notice {
    padding: 12px 14px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    background: rgba(60, 41, 22, 0.72);
    border-left: 2px solid var(--gold);
}

.maintenance-notice-label {
    color: var(--gold);
    font-size: 10px;
    font-weight: 700;
}

.maintenance-notice strong {
    display: block;
    font-size: 12px;
    line-height: 1.5;
}

.maintenance-notice p {
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 11px;
    line-height: 1.55;
}

.global-message {
    padding: 11px 13px;
    background: rgba(31, 78, 91, 0.58);
    border-left: 2px solid var(--relic);
    color: #dff8ff;
    font-size: 12px;
    line-height: 1.5;
}

.auth-tabs {
    height: 42px;
    margin-bottom: 22px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-bottom: 1px solid var(--line);
}

.auth-tabs button {
    position: relative;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.auth-tabs button::after {
    content: '';
    position: absolute;
    right: 16px;
    bottom: -1px;
    left: 16px;
    height: 2px;
    background: transparent;
}

.auth-tabs button:hover:not(:disabled) {
    color: var(--ink);
}

.auth-tabs button.active {
    color: var(--ink);
}

.auth-tabs button.active::after {
    background: var(--signal);
}

.auth-tabs button:disabled {
    opacity: 0.32;
    cursor: not-allowed;
}

.auth-grid,
.panel {
    min-width: 0;
}

.panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.panel-heading {
    margin-bottom: 20px;
}

.panel-heading h2,
.panel-heading p {
    margin: 0;
}

.panel-heading h2 {
    margin-top: 5px;
    font-size: 25px;
    line-height: 1.3;
}

.panel label {
    margin: 0 0 7px;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 600;
}

.panel input {
    width: 100%;
    height: 46px;
    margin: 0 0 17px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-left: 2px solid rgba(139, 200, 220, 0.55);
    border-radius: 0;
    background: rgba(2, 5, 11, 0.7);
    color: var(--ink);
    caret-color: var(--relic);
}

.panel input:hover {
    border-color: var(--line-bright);
}

.panel input:focus {
    border-color: var(--relic);
}

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

.primary-action,
.discord-action,
.secondary-action,
.ghost-action {
    min-height: 44px;
    border-radius: 0;
    cursor: pointer;
}

.primary-action {
    width: 100%;
    margin-top: 3px;
    border: 0;
    background: var(--signal);
    color: #fff;
    clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%);
    font-size: 13px;
    font-weight: 700;
}

.primary-action:hover:not(:disabled) {
    background: var(--signal-dark);
}

.primary-action:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.auth-divider {
    margin: 18px 0 14px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 10px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    height: 1px;
    background: var(--line);
}

.discord-action {
    width: 100%;
    border: 1px solid rgba(159, 168, 255, 0.5);
    background: rgba(88, 101, 242, 0.72);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.discord-action:hover {
    background: var(--discord);
}

.form-message {
    min-height: 19px;
    margin: 12px 0 0;
    color: var(--ink-soft);
    font-size: 11px;
    line-height: 1.55;
}

.form-message:empty {
    min-height: 0;
    margin: 0;
}

.form-message.error {
    color: #ffaaa2;
}

.form-message.success {
    color: var(--success);
}

.oauth-setup-panel .primary-action {
    margin-top: 6px;
}

.oauth-identity {
    margin-bottom: 18px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    background: rgba(4, 8, 15, 0.62);
}

.optional-label,
.field-note,
.field-label {
    color: var(--muted);
    font-size: 10px;
}

.field-note {
    margin: -8px 0 16px;
    line-height: 1.55;
}

.account-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}

.account-grid > div {
    min-width: 0;
    padding: 13px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.account-grid strong,
.discord-box strong {
    display: block;
    margin-top: 5px;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 12px;
}

.ghost-action,
.secondary-action {
    padding: 0 13px;
    border: 1px solid var(--line-bright);
    background: rgba(4, 7, 13, 0.45);
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 600;
}

.ghost-action:hover,
.secondary-action:hover {
    border-color: var(--relic);
    color: #fff;
}

.discord-box {
    margin-top: 18px;
    padding: 15px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.button-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.discord-action.compact {
    width: auto;
    padding: 0 13px;
}

.link-code {
    margin: 14px 0 0;
    color: var(--gold);
    font-size: 17px;
    font-weight: 700;
    text-align: center;
}

.state-pending {
    color: var(--gold) !important;
}

.state-approved {
    color: var(--success) !important;
}

.state-rejected,
.state-suspended {
    color: var(--danger) !important;
}

@keyframes bg-breathe {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.025);
    }
}

@media (max-width: 900px) {
    .portal-bg {
        inset: 0;
        width: 100%;
        height: 100%;
        object-position: 62% center;
    }

    .portal-veil {
        background: rgba(3, 5, 11, 0.18);
    }

    .portal-veil::before {
        display: none;
    }

    .portal-veil::after {
        height: 76%;
        background: rgba(3, 6, 12, 0.36);
    }

    .portal-title {
        top: 18px;
        left: 18px;
        gap: 9px;
    }

    .portal-title h1 {
        font-size: 20px;
    }

    .portal-title p {
        margin-top: 2px;
        font-size: 9px;
    }

    .portal-rail {
        top: 16px;
        right: 16px;
        width: 138px;
        padding: 9px 11px;
        background: rgba(5, 8, 15, 0.66);
    }

    .status-card {
        grid-template-columns: auto 1fr;
        column-gap: 7px;
    }

    .status-card strong {
        font-size: 11px;
    }

    .status-card p,
    .portal-stats {
        display: none;
    }

    .portal-workspace {
        height: 100vh;
        height: 100svh;
        min-height: 0;
        padding: 0;
        align-items: flex-end;
    }

    .portal-window {
        width: 100%;
        max-height: 74svh;
        padding: 23px 22px 26px;
        border-right: 0;
        border-bottom: 0;
        border-left-width: 0;
        border-top: 2px solid var(--signal);
        clip-path: none;
        background: var(--surface-deep);
    }

    .portal-window::before {
        right: 0;
        width: 34%;
        height: 2px;
        background: var(--relic);
    }

    .workspace-heading {
        margin-bottom: 18px;
    }

    .workspace-heading h2 {
        font-size: 27px;
    }

    .workspace-heading span {
        font-size: 11px;
    }

    .auth-tabs {
        margin-bottom: 18px;
    }

    .panel input {
        height: 44px;
        margin-bottom: 14px;
    }

    .maintenance-notice {
        grid-template-columns: 1fr;
        gap: 4px;
    }

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

    .discord-box {
        align-items: stretch;
        flex-direction: column;
    }

    .button-row {
        justify-content: stretch;
    }

    .button-row button {
        flex: 1 1 auto;
    }
}

@media (max-height: 700px) and (min-width: 901px) {
    .portal-workspace {
        padding-top: 96px;
        padding-bottom: 80px;
    }

    .portal-window {
        max-height: calc(100svh - 130px);
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .workspace-heading {
        margin-bottom: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-bg {
        animation: none;
    }
}
