.app-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 頂部導覽列 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 28px;
    background: rgba(10, 14, 28, 0.78);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border-subtle);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.4px;
    color: var(--text-main);
}

.brand-badge {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.28), rgba(167, 139, 250, 0.28));
    border: 1px solid var(--border-glow);
    color: var(--accent-star);
    box-shadow: var(--shadow-glow);
}

.bot-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 4px 12px 4px 5px;
    border-radius: 999px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    font-size: 13px;
    font-weight: 600;
}

.user-pill img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* 主要內容 */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1220px;
    margin: 0 auto;
    padding: 32px 24px 56px;
}

.fade-in {
    animation: fadeSlideUp 0.24s ease-out;
}

/* 通用按鈕與玻璃卡片 */
.glass-card {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
    color: var(--text-main);
    background: var(--bg-elevated);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--border-glow);
}

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

.btn-primary {
    background: linear-gradient(135deg, #5d7cf6, #8b5cf6);
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
    box-shadow: 0 8px 24px rgba(93, 124, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 10px 28px rgba(139, 92, 246, 0.42);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-subtle);
    color: var(--text-soft);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-main);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.14);
    border-color: rgba(248, 113, 113, 0.32);
    color: #fecaca;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.24);
}

.btn-sm {
    padding: 6px 11px;
    font-size: 12.5px;
    border-radius: 8px;
}

.icon {
    width: 17px;
    height: 17px;
    display: inline-flex;
    flex-shrink: 0;
}

.icon svg {
    width: 100%;
    height: 100%;
}

/* Badges & Alerts */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(122, 162, 255, 0.14);
    color: var(--accent-star);
    border: 1px solid rgba(122, 162, 255, 0.28);
}

.badge-violet {
    background: rgba(167, 139, 250, 0.16);
    color: #ddd6fe;
    border-color: rgba(167, 139, 250, 0.35);
}

.badge-success {
    background: var(--success-bg);
    color: #bbf7d0;
    border-color: rgba(74, 222, 128, 0.3);
}

.badge-warning {
    background: var(--warning-bg);
    color: #fde68a;
    border-color: rgba(251, 191, 36, 0.3);
}

.badge-muted {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-muted);
    border-color: rgba(148, 163, 184, 0.22);
}

.alert-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 22px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.04);
    font-size: 14px;
}

.alert-banner.error {
    background: var(--danger-bg);
    border-color: rgba(248, 113, 113, 0.36);
    color: #fecaca;
}

.alert-banner.info {
    background: rgba(122, 162, 255, 0.12);
    border-color: rgba(122, 162, 255, 0.3);
    color: var(--text-soft);
}

/* Loading */
.loading-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 55vh;
    gap: 14px;
    color: var(--text-muted);
}

.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(122, 162, 255, 0.2);
    border-top-color: var(--accent-star);
    animation: spin 0.8s linear infinite;
}

/* 未登入 Hero */
.hero-card {
    max-width: 820px;
    margin: 44px auto 0;
    padding: 48px 38px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 999px;
    background: rgba(122, 162, 255, 0.12);
    border: 1px solid var(--border-glow);
    color: var(--accent-star);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
}

.hero-title {
    margin: 0 0 14px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.25;
    background: linear-gradient(120deg, #ffffff 10%, #c7d2fe 55%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    margin: 0 auto 28px;
    max-width: 580px;
    color: var(--text-muted);
    font-size: 15.5px;
}

.hero-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 34px;
    text-align: left;
}

.feature-chip {
    padding: 16px;
    border-radius: var(--radius-sm);
    background: rgba(10, 14, 28, 0.56);
    border: 1px solid var(--border-subtle);
}

.feature-chip h4 {
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 7px;
}

.feature-chip p {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* 擁有者橫幅 & 伺服器清單 */
.owner-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 26px;
    margin-bottom: 28px;
    background: linear-gradient(135deg, rgba(93, 124, 246, 0.18), rgba(167, 139, 250, 0.16));
    border: 1px solid var(--border-glow);
}

.owner-banner h2 {
    margin: 0 0 4px;
    font-size: 19px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.owner-banner p {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-soft);
}

.section-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.section-title {
    margin: 0;
    font-size: 19px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box {
    position: relative;
    min-width: 240px;
}

.search-box .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border-radius: 10px;
    background: rgba(9, 13, 24, 0.72);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    font-size: 13.5px;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent-star);
    box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.16);
}

.guild-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
    gap: 16px;
}

.guild-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.guild-card.manageable:hover {
    transform: translateY(-3px);
    border-color: var(--border-glow);
}

.guild-card.locked {
    opacity: 0.62;
}

.guild-card-head {
    display: flex;
    align-items: center;
    gap: 13px;
}

.guild-avatar {
    width: 52px;
    height: 52px;
    border-radius: 15px;
    object-fit: cover;
    background: rgba(122, 162, 255, 0.14);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: var(--accent-star);
    flex-shrink: 0;
}

.guild-meta {
    min-width: 0;
}

.guild-meta h3 {
    margin: 0 0 3px;
    font-size: 15.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.guild-meta span {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* 雙欄面板結構（Guild / Owner 共用基礎） */
.panel-layout {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 65px);
}

.sidebar {
    width: 268px;
    flex-shrink: 0;
    padding: 20px 16px;
    background: rgba(10, 14, 28, 0.68);
    backdrop-filter: blur(18px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sidebar-group-title {
    padding: 0 10px;
    margin: 4px 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--text-dim);
    font-weight: 700;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(122, 162, 255, 0.14);
    border-color: rgba(122, 162, 255, 0.34);
    color: var(--text-main);
}

.panel-content {
    flex: 1;
    min-width: 0;
    padding: 28px 30px 56px;
    max-width: 1220px;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
    font-size: 24px;
}

.page-header p {
    margin: 4px 0 0;
    font-size: 13.5px;
    color: var(--text-muted);
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.kpi-card {
    padding: 18px 20px;
}

.kpi-label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.kpi-sub {
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-dim);
}

/* 權限診斷 */
.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.perm-item {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: rgba(10, 14, 28, 0.56);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.perm-item h4 {
    margin: 0 0 3px;
    font-size: 13.5px;
}

.perm-item p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* 身分組多選清單 */
.role-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.role-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 13px;
    border-radius: 10px;
    background: rgba(10, 14, 28, 0.62);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.role-option.selected {
    background: rgba(122, 162, 255, 0.14);
    border-color: var(--accent-star);
}

.role-option.readonly {
    cursor: default;
}

.role-label-wrap {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.role-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
}

.role-name {
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 模組表格與終端機 */
.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.log-terminal {
    background: rgba(5, 8, 16, 0.88);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    height: 430px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
}

.log-line {
    display: flex;
    gap: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    word-break: break-word;
}

.log-line:hover {
    background: rgba(255, 255, 255, 0.04);
}

.log-ts {
    color: var(--text-dim);
    flex-shrink: 0;
}

.log-lvl {
    min-width: 64px;
    font-weight: 700;
    flex-shrink: 0;
}

.log-lvl.INFO {
    color: var(--accent-star);
}

.log-lvl.WARNING {
    color: var(--warning);
}

.log-lvl.ERROR,
.log-lvl.CRITICAL {
    color: var(--danger);
}

.log-msg {
    color: var(--text-soft);
    white-space: pre-wrap;
}

/* 手機抽屜選單切換 */
.mobile-drawer-btn {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 920px) {
    .topbar {
        padding: 12px 16px;
    }

    .mobile-drawer-btn {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        top: 61px;
        bottom: 0;
        left: 0;
        z-index: 45;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop.open {
        display: block;
        position: fixed;
        inset: 61px 0 0 0;
        background: rgba(4, 6, 15, 0.65);
        z-index: 44;
    }

    .panel-content {
        padding: 22px 16px 48px;
    }

    .bot-status-pill {
        display: none;
    }
}

/* Toast 與 Modal */
.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--bg-panel-strong);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glow);
    box-shadow: var(--shadow-card);
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeSlideUp 0.2s ease-out;
}

.toast.success {
    border-color: rgba(74, 222, 128, 0.48);
}

.toast.error {
    border-color: rgba(248, 113, 113, 0.55);
}

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(4, 7, 16, 0.72);
    backdrop-filter: blur(6px);
}

.modal-root.open {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 440px;
    padding: 24px;
}

.modal-box h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.modal-box p {
    margin: 0 0 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== 擴充功能分頁表單與星夜開關樣式 ===== */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field-label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.field-hint {
    font-size: 12px;
    color: var(--text-dim);
}

.field-input,
.field-select,
.field-textarea {
    width: 100%;
    padding: 10px 13px;
    border-radius: 10px;
    background: rgba(9, 13, 24, 0.78);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field-textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.55;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
    border-color: var(--accent-star);
    box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.16);
}

.field-select option {
    background: #10162b;
    color: var(--text-main);
}

.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* 星夜滑桿開關 */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(10, 14, 28, 0.56);
    border: 1px solid var(--border-subtle);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.35);
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    border-radius: 50%;
    background: #eef2ff;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #5d7cf6, #8b5cf6);
    border-color: rgba(167, 139, 250, 0.7);
    box-shadow: 0 0 14px rgba(122, 162, 255, 0.35);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* 模組開關卡片格線 */
.module-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.module-card {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.16s ease, opacity 0.16s ease;
}

.module-card.disabled {
    opacity: 0.65;
}

.module-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.module-card-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15.5px;
    font-weight: 700;
    margin: 0 0 5px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-chip {
    font-size: 11.5px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(122, 162, 255, 0.1);
    border: 1px solid rgba(122, 162, 255, 0.22);
    color: var(--text-soft);
    font-family: var(--font-mono);
}

/* 歡迎系統雙欄與即時卡片預覽 */
.welcome-split {
    display: grid;
    grid-template-columns: minmax(300px, 1.1fr) minmax(300px, 0.9fr);
    gap: 18px;
    align-items: start;
}

@media (max-width: 1020px) {
    .welcome-split {
        grid-template-columns: 1fr;
    }
}

.discord-preview {
    background: #1e212a;
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 16px 18px;
}

.discord-msg-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.discord-bot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5d7cf6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.discord-bot-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: #5865f2;
    color: #fff;
    margin-left: 4px;
}

.discord-msg-body {
    font-size: 14px;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 12px;
}

.discord-mention {
    background: rgba(88, 101, 242, 0.3);
    color: #c9cdfb;
    padding: 0 4px;
    border-radius: 4px;
    font-weight: 600;
}

.welcome-card-canvas {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(135deg, #1b254b, #2a1d4a);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-card-canvas img.welcome-bg-img {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.welcome-card-avatar {
    position: relative;
    z-index: 2;
    width: 24%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid rgba(255, 255, 255, 0.88);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
    background: #2b3252;
}

.welcome-card-avatar.masked {
    border: none;
    box-shadow: none;
}

.welcome-card-canvas img.welcome-mask-img {
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
}

/* 2:1 互動裁切視窗（2560×1280） */
.cropper-modal-box {
    width: 100%;
    max-width: 780px;
    padding: 24px;
}

.cropper-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 1;
    border-radius: 12px;
    overflow: hidden;
    background: #0a0e1b;
    border: 1px solid var(--border-glow);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.cropper-stage:active {
    cursor: grabbing;
}

.cropper-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.cropper-guide-mask {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    opacity: 0.92;
}

.cropper-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 16px;
}

.cropper-zoom-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 220px;
}

.cropper-zoom-wrap input[type="range"] {
    flex: 1;
    accent-color: var(--accent-star);
}

.role-option.unassignable {
    opacity: 0.55;
    cursor: not-allowed;
    border-style: dashed;
}

/* ===== AI 角色與聊天中心／審核中心樣式 ===== */
.subtab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 6px;
    border-radius: 12px;
    background: rgba(10, 14, 28, 0.65);
    border: 1px solid var(--border-subtle);
}

.subtab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.subtab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.subtab-btn.active {
    background: rgba(122, 162, 255, 0.18);
    border-color: rgba(122, 162, 255, 0.4);
    color: var(--text-main);
}

.nav-count-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.55);
}

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

.char-card {
    padding: 15px 16px;
    border-radius: 12px;
    background: rgba(10, 14, 28, 0.62);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    transition: border-color 0.16s ease, transform 0.16s ease;
}

.char-card:hover {
    border-color: var(--border-glow);
}

.char-card.active-char {
    background: rgba(122, 162, 255, 0.12);
    border-color: var(--accent-star);
    box-shadow: 0 0 18px rgba(122, 162, 255, 0.18);
}

.char-card-snippet {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.md-editor-area {
    width: 100%;
    min-height: 260px;
    padding: 14px;
    border-radius: 10px;
    background: rgba(6, 9, 18, 0.88);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
    resize: vertical;
    outline: none;
}

.md-editor-area:focus {
    border-color: var(--accent-star);
    box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.16);
}

.md-preview-box {
    max-height: 360px;
    overflow-y: auto;
    padding: 14px 16px;
    border-radius: 10px;
    background: rgba(6, 9, 18, 0.85);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--text-soft);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.submission-card {
    padding: 18px 20px;
    border-radius: 12px;
    background: rgba(10, 14, 28, 0.65);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.submission-card.pending {
    border-color: rgba(251, 191, 36, 0.42);
}

.modal-box-lg {
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

/* ===== 外部推播與社群互動專屬元件樣式 ===== */
.alert-banner {
    padding: 13px 16px;
    border-radius: 12px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fde68a;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.alert-banner.danger {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.4);
    color: #fecaca;
}

.alert-banner.info {
    background: rgba(122, 162, 255, 0.1);
    border-color: rgba(122, 162, 255, 0.35);
    color: #dbeafe;
}

.quick-chip-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(122, 162, 255, 0.12);
    border: 1px solid rgba(122, 162, 255, 0.28);
    color: var(--text-soft);
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.quick-chip:hover {
    background: rgba(122, 162, 255, 0.24);
    border-color: var(--accent-star);
    color: var(--text-main);
}

.discord-embed-card {
    background: #2b2d31;
    border-left: 4px solid #5865f2;
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 12px;
}

.discord-embed-title {
    font-size: 15px;
    font-weight: 700;
    color: #f2f3f5;
    margin: 0 0 6px;
    word-break: break-word;
}

.discord-embed-desc {
    font-size: 13.5px;
    color: #dbdee1;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    line-height: 1.5;
}

.discord-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.discord-btn-preview {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    user-select: none;
}

.discord-btn-preview.primary { background: #5865f2; }
.discord-btn-preview.secondary { background: #4e5058; }
.discord-btn-preview.success { background: #248046; }
.discord-btn-preview.danger { background: #da373c; }

.vote-bar-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.vote-bar-head {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-soft);
}

.vote-bar-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    overflow: hidden;
}

.vote-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #5d7cf6, #a78bfa);
    transition: width 0.25s ease;
}

.voice-preview-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 10px;
    background: rgba(9, 13, 24, 0.82);
    border: 1px solid rgba(122, 162, 255, 0.35);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
}

.color-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-swatch-input {
    width: 44px;
    height: 38px;
    padding: 2px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: rgba(9, 13, 24, 0.78);
    cursor: pointer;
}

.role-builder-item {
    display: grid;
    grid-template-columns: minmax(120px, 1.1fr) minmax(70px, 0.55fr) minmax(110px, 0.7fr) auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(10, 14, 28, 0.6);
    border: 1px solid var(--border-subtle);
}

@media (max-width: 720px) {
    .role-builder-item {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===== 星蝶幣簽到月曆、里程碑時間表與轉帳試算樣式 ===== */
.milestone-timeline {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

@media (max-width: 760px) {
    .milestone-timeline {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.milestone-node {
    padding: 14px 14px;
    border-radius: 12px;
    background: rgba(10, 14, 28, 0.65);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.milestone-node.reached {
    background: rgba(74, 222, 128, 0.1);
    border-color: rgba(74, 222, 128, 0.45);
    box-shadow: 0 0 14px rgba(74, 222, 128, 0.12);
}

.milestone-day {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.milestone-reward {
    font-size: 17px;
    font-weight: 800;
    color: var(--accent-star);
}

.milestone-node.reached .milestone-reward {
    color: #86efac;
}

.checkin-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.checkin-cal-weekdays,
.checkin-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.checkin-cal-weekdays {
    margin-bottom: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.cal-cell {
    min-height: 76px;
    padding: 8px 9px;
    border-radius: 10px;
    background: rgba(10, 14, 28, 0.56);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
    text-align: left;
    color: var(--text-main);
    transition: transform 0.12s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.cal-cell.outside {
    opacity: 0.28;
}

.cal-cell.checked {
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.42);
}

.cal-cell.makeup {
    background: rgba(167, 139, 250, 0.14);
    border-color: rgba(167, 139, 250, 0.45);
}

.cal-cell.today_pending {
    background: rgba(122, 162, 255, 0.16);
    border-color: var(--accent-star);
    box-shadow: 0 0 12px rgba(122, 162, 255, 0.22);
}

.cal-cell.missed.can-makeup {
    background: rgba(248, 113, 113, 0.08);
    border-color: rgba(248, 113, 113, 0.36);
    cursor: pointer;
}

.cal-cell.missed.can-makeup:hover {
    transform: translateY(-2px);
    background: rgba(167, 139, 250, 0.18);
    border-color: rgba(167, 139, 250, 0.7);
}

.cal-day-num {
    font-size: 13px;
    font-weight: 700;
}

.cal-day-tag {
    font-size: 11px;
    line-height: 1.25;
    color: var(--text-muted);
    word-break: break-word;
}

.cal-cell.checked .cal-day-tag {
    color: #86efac;
    font-weight: 600;
}

.cal-cell.makeup .cal-day-tag {
    color: #d8b4fe;
    font-weight: 600;
}

.cal-cell.missed.can-makeup .cal-day-tag {
    color: #fca5a5;
}

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.cal-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: middle;
}

.transfer-quote-box {
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(10, 14, 28, 0.72);
    border: 1px solid rgba(122, 162, 255, 0.3);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13.5px;
}

.recipient-picker-panel {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(8, 12, 24, 0.56);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recipient-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--text-muted);
}

.recipient-picker-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.recipient-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: rgba(16, 22, 42, 0.72);
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease;
    font: inherit;
    min-width: 0;
}

.recipient-chip:hover {
    border-color: rgba(122, 162, 255, 0.55);
    background: rgba(24, 34, 66, 0.85);
    transform: translateY(-1px);
}

.recipient-chip.selected {
    border-color: rgba(122, 162, 255, 0.9);
    background: rgba(93, 124, 246, 0.22);
    box-shadow: 0 0 0 2px rgba(122, 162, 255, 0.2);
}

.recipient-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(122, 162, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-star);
}

.recipient-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.recipient-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recipient-sub {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640px) {
    .cal-cell {
        min-height: 60px;
        padding: 6px;
    }
    .cal-day-tag {
        font-size: 10px;
    }
}

.badge-danger {
    background: rgba(248, 113, 113, 0.16);
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.36);
}
