/* ============================================
   xingcha-guide-library — Global Styles
   Light Glassmorphism (Apple-style) Design
   ============================================ */

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
html, body {
    touch-action: manipulation;
}

/* --- Body --- */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: radial-gradient(ellipse at 20% 20%,rgba(120,100,255,0.3) 0%,transparent 50%),radial-gradient(ellipse at 80% 80%,rgba(60,180,255,0.25) 0%,transparent 50%),radial-gradient(ellipse at 60% 10%,rgba(200,130,255,0.2) 0%,transparent 40%),radial-gradient(ellipse at 30% 70%,rgba(80,200,220,0.15) 0%,transparent 45%),radial-gradient(ellipse at 75% 45%,rgba(160,100,255,0.18) 0%,transparent 40%),linear-gradient(160deg,#e8dff5 0%,#d4e4f7 30%,#c8e6f5 50%,#dce9fc 70%,#e6e0f3 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Links --- */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dim);
}

/* --- App Container --- */
#app {
    min-height: 100vh;
    padding: 0;
}

/* --- Glass Card --- */
.card,
.glass-card {
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--glass-radius);
    box-shadow: var(--glass-shadow);
    transition: all var(--transition);
}

.card:hover,
.glass-card:hover {
    background: var(--bg-card-hover);
    box-shadow: 0 8px 32px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04), inset 0 0.5px 0 rgba(255,255,255,0.9), inset 0 -0.5px 0 rgba(0,0,0,0.04);
}

.card {
    padding: 24px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    -webkit-user-select: none;
    user-select: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn--primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.btn--primary:hover {
    background: var(--primary-dim);
    box-shadow: 0 6px 20px rgba(0,122,255,0.4);
}

.btn--secondary {
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    color: var(--text-primary);
    box-shadow: var(--glass-shadow);
}

.btn--secondary:hover {
    background: var(--bg-card-hover);
}

.btn--danger {
    background: var(--danger);
    color: #fff;
}

.btn--danger:hover {
    background: #d32f2f;
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn--ghost:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.btn--sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    border-radius: 100px;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

.badge--blue {
    background: rgba(0,122,255,0.12);
    color: var(--primary);
}

.badge--green {
    background: rgba(52,199,89,0.12);
    color: var(--success);
}

.badge--orange {
    background: rgba(255,159,10,0.12);
    color: var(--accent);
}

.badge--purple {
    background: rgba(120,100,255,0.12);
    color: #7864ff;
}

/* --- Form Elements --- */
input,
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--input-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 0.5px solid var(--border-light);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.15), var(--shadow-sm);
    background: rgba(255,255,255,0.5);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(0,0,0,0.5)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 16px;
}

/* --- Layout Helpers --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

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

.justify-center {
    justify-content: center;
}

.gap-8 {
    gap: 8px;
}

.gap-12 {
    gap: 12px;
}

.gap-16 {
    gap: 16px;
}

.gap-24 {
    gap: 24px;
}

.grid {
    display: grid;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* --- Spacing --- */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-16 { padding: 16px; }
.p-24 { padding: 24px; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }

.font-medium { font-weight: 500; }
.font-bold { font-weight: 600; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: var(--text-tertiary);
}

.empty-state__icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state__text {
    font-size: 15px;
    margin-bottom: 8px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.2);
}

/* --- Toast Notification --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toast-in .35s cubic-bezier(.25,.1,.25,1) forwards;
    max-width: 380px;
}

.toast--success {
    border-left: 3px solid var(--success);
}

.toast--error {
    border-left: 3px solid var(--danger);
}

.toast--warning {
    border-left: 3px solid var(--warning);
}

.toast--info {
    border-left: 3px solid var(--primary);
}

.toast--out {
    animation: toast-out .3s cubic-bezier(.25,.1,.25,1) forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
    }
}

/* --- Loading Spinner --- */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

.spinner--lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* --- Loading Skeleton --- */
.skeleton {
    background: rgba(0,0,0,0.06);
    border-radius: var(--radius-sm);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton--text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton--title {
    height: 20px;
    margin-bottom: 12px;
    width: 60%;
}

.skeleton--card {
    height: 120px;
    border-radius: var(--radius-md);
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* --- Table --- */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--table-header-bg);
    border-bottom: 0.5px solid var(--border-subtle);
    font-size: 13px;
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    border-bottom: 0.5px solid var(--border-subtle);
    color: var(--text-primary);
}

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

table tr:hover td {
    background: rgba(0,0,0,0.02);
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
}

.pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.pagination__btn:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.pagination__btn--active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.pagination__btn--active:hover {
    background: var(--primary-dim);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: modal-overlay-in .2s ease;
}

.modal {
    background: var(--bg-card-solid);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-in .3s cubic-bezier(.25,.1,.25,1);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal__header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    transition: all var(--transition);
}

.modal__close:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.modal__body {
    padding: 20px 24px;
}

.modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 24px 20px;
}

@keyframes modal-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- Confirm Dialog --- */
.confirm-dialog {
    text-align: center;
    padding: 12px 0;
}

.confirm-dialog__icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.confirm-dialog__title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
}

.confirm-dialog__desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* --- Sidebar / Nav common --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border-right: var(--glass-border);
    box-shadow: var(--glass-shadow);
    z-index: 100;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.sidebar__logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 8px 12px;
    margin-bottom: 24px;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition);
    cursor: pointer;
}

.sidebar__link:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.sidebar__link--active {
    background: rgba(0,122,255,0.1);
    color: var(--primary);
    font-weight: 500;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 16px;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        flex-direction: row;
        padding: 8px 12px;
        border-right: none;
        border-top: var(--glass-border);
        border-radius: 0;
        overflow-x: auto;
    }

    .sidebar__logo {
        display: none;
    }

    .sidebar__nav {
        flex-direction: row;
        gap: 4px;
        justify-content: space-around;
    }

    .sidebar__link {
        flex-direction: column;
        padding: 6px 10px;
        font-size: 11px;
        gap: 2px;
        white-space: nowrap;
    }

    #app {
        padding-bottom: 64px;
    }

    .modal {
        width: 95%;
        max-width: 100%;
        margin: 16px;
    }
}

@media (max-width: 414px) {
    html {
        font-size: 15px;
    }

    .container {
        padding: 0 12px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .card {
        padding: 14px;
        border-radius: var(--radius-lg);
    }

    .page-header h1 {
        font-size: 18px;
    }

    .toast {
        max-width: calc(100vw - 32px);
        font-size: 13px;
        padding: 12px 16px;
    }

    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
    }

    table {
        font-size: 13px;
    }

    table th,
    table td {
        padding: 10px 12px;
    }

    /* Mobile table: horizontal scroll */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px;
    }

    /* Form elements mobile */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .form-group label {
        font-size: 14px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        flex: 1 1 100%;
    }

    .tb-input {
        font-size: 14px;
        padding: 8px 10px;
    }

    .btn--sm {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 375px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: 0 10px;
    }

    .card {
        padding: 12px;
        border-radius: var(--radius-md);
    }

    .sidebar__link {
        font-size: 10px;
        padding: 4px 6px;
    }
}

/* Fleet Formation Styles */
.fleet-formation { margin-bottom: 24px; }
.fleet-position { margin-bottom: 20px; }
.fleet-position__header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.3);
    border-radius: 12px;
    backdrop-filter: blur(8px);
}
.fleet-position__ships {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.ship-card {
    background: rgba(255,255,255,0.5);
    border-radius: 14px;
    padding: 0;
    border: 0.5px solid rgba(255,255,255,0.8);
    transition: transform .2s, box-shadow .2s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ship-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.ship-card__img-wrap {
    width: 100%;
    height: 100px;
    background: rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 0.5px solid rgba(0,0,0,0.04);
}
.ship-card__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}
.ship-card__img-placeholder {
    background: rgba(0,122,255,0.04);
    color: var(--text-tertiary);
}
.ship-card__body {
    padding: 10px 12px 12px;
}
.ship-card__name { font-size: 13px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.ship-card__meta { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; align-items: center; }
.ship-card__role { font-size: 11px; color: var(--text-secondary); background: rgba(0,0,0,0.04); padding: 2px 8px; border-radius: 6px; }
.ship-card__count { font-size: 12px; color: var(--primary); font-weight: 600; margin-left: auto; }
.ship-card__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-tertiary);
}
.ship-card__stats span {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(0,0,0,0.03);
    padding: 1px 6px;
    border-radius: 4px;
}
.ship-card__skill { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.fleet-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: rgba(255,255,255,0.3);
    border-radius: 16px;
    backdrop-filter: blur(8px);
}
.fleet-stat { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-secondary); }
.fleet-stat__value { font-weight: 600; color: var(--text-primary); }
.fleet-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 100px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}
@media (max-width: 480px) {
    .fleet-position__ships { grid-template-columns: 1fr 1fr; }
}

/* --- Utility: hide scrollbar for nav --- */
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* --- Selection --- */
::selection {
    background: rgba(0,122,255,0.2);
    color: var(--text-primary);
}

/* Quill.js Editor Styles */
.ql-toolbar {
    border-radius: 12px 12px 0 0;
    background: #fafafa;
    border: 0.5px solid rgba(0,0,0,0.08);
    border-bottom: 0.5px solid rgba(0,0,0,0.1);
    padding: 8px 12px;
    position: relative;
    z-index: 10;
}
/* Ensure toolbar dropdowns (color picker, header select) are not clipped */
.ql-toolbar .ql-picker-options {
    z-index: 100;
    background: #fff;
    border: 0.5px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.ql-toolbar .ql-picker.ql-expanded .ql-picker-options {
    top: 100%;
    margin-top: 4px;
}
#editor-container {
    min-height: 480px;
    max-height: 70vh;
    background: #fff;
    border-radius: var(--radius-md, 12px);
    border: 0.5px solid rgba(0,0,0,0.08);
    overflow-y: auto;
    margin-bottom: 16px;
}
.ql-editor {
    min-height: 460px;
    font-size: 15px;
    line-height: 1.8;
    padding: 20px 24px;
    color: #1a1a1a;
}
.ql-editor h1 { font-size: 24px; font-weight: 600; margin: 8px 0; }
.ql-editor h2 { font-size: 20px; font-weight: 600; margin: 8px 0; }
.ql-editor h3 { font-size: 17px; font-weight: 600; margin: 8px 0; }
.ql-editor p { margin: 4px 0; }
.ql-editor img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.ql-editor blockquote { border-left: 3px solid var(--primary); padding-left: 16px; color: #666; }
.ql-editor code { background: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.ql-container {
    border-radius: 0 0 12px 12px;
    border: 0.5px solid rgba(0,0,0,0.08);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}
/* Make the editor wrapper look like a glass card */
.editor-wrapper {
    background: rgba(255,255,255,0.45);
    backdrop-filter: blur(24px) saturate(1.8);
    border-radius: var(--glass-radius, 20px);
    padding: 20px;
    border: 0.5px solid rgba(255,255,255,0.7);
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

/* ============================================================
   Team Builder Styles
   ============================================================ */
.tb-builder {
    background: rgba(255,255,255,0.3);
    border-radius: 16px;
    border: 0.5px solid rgba(255,255,255,0.5);
    overflow: hidden;
    font-size: 13px;
}
.tb-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: rgba(255,255,255,0.5);
    border-bottom: 0.5px solid rgba(0,0,0,0.06);
    flex-wrap: wrap;
}
.tb-input {
    background: rgba(255,255,255,0.8);
    border: 0.5px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    color: #333;
    outline: none;
    transition: border-color .2s;
}
.tb-input:focus { border-color: var(--primary); }
.tb-input--sm { width: 60px; }
.tb-input--xs { width: 40px; }

.tb-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 400px;
}
@media (max-width: 720px) {
    .tb-layout { grid-template-columns: 1fr; }
    .tb-toolbar { padding: 8px; }
    .tb-toolbar input { flex: 1 1 100%; }
    .tb-toolbar select { flex: 1 1 calc(50% - 4px); min-width: 0; }
    .tb-panel__body { max-height: 60vh; padding: 6px; }
    .tb-ship-item { padding: 10px 8px; min-height: 44px; }
    .tb-fleet-item__header { padding: 10px 8px; }
    .tb-fleet-item__body { padding: 8px; }
    .tb-fleet-item__row { flex-direction: column; align-items: stretch; }
    .tb-fleet-item__row .tb-input--xs { width: 100%; }
    .tb-carried-item { flex-wrap: wrap; }
    .tb-carried-item .tb-input--xs { width: 100%; }
    .tb-carried-add { flex-direction: column; }
    .tb-carried-add select { width: 100%; }
}
.tb-panel {
    display: flex;
    flex-direction: column;
}
.tb-panel--ships { border-right: 0.5px solid rgba(0,0,0,0.06); }
@media (max-width: 720px) {
    .tb-panel--ships { border-right: none; border-bottom: 1px solid rgba(0,0,0,0.06); }
}
.tb-panel__header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.02);
    border-bottom: 0.5px solid rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.tb-panel__body {
    flex: 1;
    overflow-y: auto;
    max-height: 500px;
    padding: 8px;
}
.tb-count { font-size: 11px; color: var(--text-tertiary); font-weight: 400; }

/* Ship list */
.tb-ship-group { margin-bottom: 8px; }
.tb-ship-group__header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    padding: 4px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tb-ship-group__list { display: flex; flex-direction: column; gap: 4px; }
.tb-ship-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255,255,255,0.5);
    border-radius: 8px;
    border: 0.5px solid rgba(255,255,255,0.6);
    transition: background .2s;
    cursor: default;
}
.tb-ship-item:hover { background: rgba(255,255,255,0.8); }
.tb-ship-item--selected { background: rgba(0,122,255,0.08); border-color: rgba(0,122,255,0.2); }
.tb-ship-item__info { flex: 1; min-width: 0; }
.tb-ship-item__name { font-size: 13px; font-weight: 500; }
.tb-ship-item__meta { font-size: 11px; color: var(--text-tertiary); display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.tb-ship-item__actions { flex-shrink: 0; margin-left: 8px; }

/* Badges */
.bb {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}
.bb-carrier { background: rgba(0,122,255,0.1); color: var(--primary); }
.bb-fighter { background: rgba(52,199,89,0.1); color: #34c759; }
.bb-corvette { background: rgba(175,82,222,0.1); color: #af52de; }
.bb-fighter-sm { background: rgba(52,199,89,0.08); color: #34c759; font-size: 10px; padding: 1px 4px; border-radius: 3px; }
.bb-corvette-sm { background: rgba(175,82,222,0.08); color: #af52de; font-size: 10px; padding: 1px 4px; border-radius: 3px; }
.bb-module { background: rgba(255,149,0,0.1); color: #ff9500; font-size: 10px; padding: 1px 4px; border-radius: 3px; }

/* Fleet preview */
.tb-fleet-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(0,122,255,0.04);
    border-radius: 8px;
    margin-bottom: 8px;
}
.tb-stat { font-size: 12px; color: var(--text-secondary); }
.tb-stat strong { color: var(--text-primary); }

.tb-errors {
    background: rgba(255,59,48,0.06);
    border: 0.5px solid rgba(255,59,48,0.15);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
}
.tb-errors__title { font-size: 12px; font-weight: 600; color: #ff3b30; margin-bottom: 4px; }
.tb-errors__item { font-size: 11px; color: #ff3b30; padding: 2px 0; }

.tb-position { margin-bottom: 12px; }
.tb-position__header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px 8px;
    margin-bottom: 4px;
    border-left: 3px solid var(--primary);
    padding-left: 10px;
}
.tb-position__header--carrier { border-left-color: #af52de; }
.tb-position__ships { display: flex; flex-direction: column; gap: 6px; }

.tb-fleet-item {
    background: rgba(255,255,255,0.6);
    border-radius: 10px;
    border: 0.5px solid rgba(255,255,255,0.7);
    overflow: hidden;
}
.tb-fleet-item--carrier { border-color: rgba(175,82,222,0.3); background: rgba(175,82,222,0.04); }
.tb-fleet-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(0,0,0,0.02);
    border-bottom: 0.5px solid rgba(0,0,0,0.04);
}
.tb-fleet-item__name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}
.tb-fleet-item__img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
}
.tb-fleet-item__type { font-size: 10px; color: var(--text-tertiary); font-weight: 400; }
.tb-fleet-item__body { padding: 8px 10px; }
.tb-fleet-item__row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 4px;
}
.tb-fleet-item__row label { font-size: 11px; color: var(--text-tertiary); }

/* Carrier info */
.tb-carrier-info {
    display: flex;
    gap: 6px;
    margin: 4px 0;
}
.tb-carried-ships { margin-top: 6px; padding-top: 6px; border-top: 0.5px solid rgba(0,0,0,0.06); }
.tb-carried-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: rgba(255,255,255,0.5);
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 12px;
    flex-wrap: wrap;
}
.tb-carried-item__name { font-weight: 500; }
.tb-carried-item__type { font-size: 10px; color: var(--text-tertiary); }
.tb-carried-empty { font-size: 11px; color: var(--text-tertiary); padding: 4px 0; }
.tb-carried-actions { margin-top: 4px; }
.tb-carried-add { display: flex; gap: 4px; flex-wrap: wrap; }
.tb-carried-add select { flex: 1; min-width: 120px; }

/* Module toggle UI */
.tb-modules { margin-top: 8px; padding-top: 6px; border-top: 0.5px solid rgba(0,0,0,0.06); }
.tb-modules__header { font-size: 11px; font-weight: 600; color: var(--text-tertiary); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.tb-module-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    margin-bottom: 3px;
    background: rgba(255,255,255,0.3);
    border-radius: 6px;
    border: 0.5px solid rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all .15s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.tb-module-item:hover { background: rgba(255,255,255,0.6); }
.tb-module-item--active {
    background: rgba(0,122,255,0.06);
    border-color: rgba(0,122,255,0.2);
}
.tb-module-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 0.5px solid rgba(0,0,0,0.15);
    background: #fff;
    font-size: 11px;
    color: var(--primary);
    flex-shrink: 0;
}
.tb-module-item--active .tb-module-check {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.tb-module-name { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.tb-module-type { font-size: 10px; color: var(--text-tertiary); background: rgba(0,0,0,0.03); padding: 1px 5px; border-radius: 3px; }
.tb-module-bonus { font-size: 10px; color: #ff9500; margin-left: auto; white-space: nowrap; }

/* Button sizes */
.btn--xs { padding: 2px 8px; font-size: 11px; border-radius: 6px; }
.btn--icon { background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 14px; }
.btn--icon:hover { background: rgba(0,0,0,0.05); color: #ff3b30; }