/* =========================================================
   CAACO Freemium UI — modals, badges, paywall affordances.
   Shared across all entry points (index, word-skill, excel-skill,
   account). Loaded lazily by js/paywall.js the first time a
   modal is shown.
   ========================================================= */

/* ---------- Google “G” icon (sign-in / footer / avatar badge) ---------- */
.caaco-google-g {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.57 2.95-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z'/%3E%3C/svg%3E");
    vertical-align: middle;
}
.caaco-google-g--sm {
    width: 16px;
    height: 16px;
}

/* ---------- Start-menu user header tweaks ---------- */
.xp-start-menu__userblock {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    line-height: 1.15;
    min-width: 0;
    flex: 1;
}
.xp-start-menu__user-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    align-content: flex-start;
    gap: 6px;
    width: 100%;
    max-width: 100%;
}
.caaco-start-streak {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px 2px 6px;
    border-radius: 10px;
    background: linear-gradient(180deg, #fff2cc, #ffd97a);
    color: #8a4b00;
    border: 1px solid #d99a3a;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05) inset;
    line-height: 1;
    cursor: default;
    width: max-content;
    max-width: 100%;
    flex: 0 0 auto;
    align-self: flex-start;
}
.caaco-start-streak__flame {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transform: translateY(-0.5px);
}
.caaco-start-streak__count {
    line-height: 1.2;
    letter-spacing: 0.02em;
}
.xp-start-menu__username {
    display: block;
    width: 100%;
    max-width: 100%;
    font-weight: 600;
    font-size: 13px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}
.xp-start-menu__userbadge {
    display: inline-block;
    margin-top: 0;
    padding: 1px 6px;
    border-radius: 2px;
    font-size: 10px;
    letter-spacing: 0.5px;
    font-weight: 700;
    width: max-content;
}
.xp-start-menu__userbadge.is-pro {
    background: linear-gradient(180deg, #ffd944, #d8a300);
    color: #2d1f00;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
}
.xp-start-menu__userbadge.is-free {
    background: rgba(255,255,255,0.18);
    color: #fff;
}
.xp-start-menu__avatar {
    position: relative;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.xp-start-menu__signin-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: center;
    flex-shrink: 0;
    background: #fff;
    color: #1f4a8a;
    border: 1px solid #1f4a8a;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.xp-start-menu__auth-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    align-self: center;
    flex-shrink: 0;
}
.xp-start-menu__login-help {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.75);
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    font-family: Tahoma, "Microsoft JhengHei", sans-serif;
    flex-shrink: 0;
}
.xp-start-menu__login-help:hover {
    background: rgba(255,255,255,0.35);
    border-color: #fff;
}
.xp-start-menu__signin-btn:hover { background: #e7f0ff; }
.xp-start-menu__signin-btn[hidden] {
    display: none !important;
}
.xp-start-menu__auth-actions[hidden],
body.caaco-is-signed-in .xp-start-menu__auth-actions {
    display: none !important;
}
body.caaco-is-signed-in .xp-start-menu__signin-btn {
    display: none !important;
}
.xp-login-help__list {
    margin: 6px 0 10px;
    padding-left: 1.2em;
    font-size: 12px;
    line-height: 1.45;
}
.xp-login-help__list li { margin-bottom: 4px; }
.xp-start-menu__power-icon.caaco-google-g {
    font-size: 0;
    line-height: 0;
}

/* Taskbar auth toggle: 登入 ↔ 登出 */
.xp-systray__signin--logout {
    border-color: rgba(255, 200, 200, 0.55);
}
.xp-systray__signin--logout:hover {
    background: rgba(255, 80, 80, 0.22);
}
.xp-systray__signin[hidden] {
    display: none !important;
}
.xp-systray__user[hidden],
body:not(.caaco-is-signed-in) #xpTaskbarUser {
    display: none !important;
}

/* Pro upgrade entry in Start menu */
.xp-start-menu__place--pro {
    background: linear-gradient(180deg, #fff8d4 0%, #ffe78f 100%);
    color: #4a3500 !important;
    font-weight: 700;
    border: 1px solid #d8a300;
    box-shadow: inset 0 1px 0 #fff8d4;
}
.xp-start-menu__place--pro:hover {
    background: linear-gradient(180deg, #ffe78f 0%, #ffd944 100%) !important;
    color: #2d1f00 !important;
}

/* ---------- Lock badge for paywalled UI ---------- */
.caaco-lock-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 2px;
    background: linear-gradient(180deg, #ffd944, #d8a300);
    color: #2d1f00;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-left: 4px;
}
.caaco-lock-badge::before { content: '🔒'; font-size: 9px; }

.caaco-pro-only {
    position: relative;
    opacity: 0.65;
}
.caaco-pro-only:hover { opacity: 0.85; }

/* ---------- Upgrade modal ---------- */
.caaco-modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    padding: 16px;
    visibility: visible !important;
    animation: caaco-modal-fade 0.18s ease-out;
}
@keyframes caaco-modal-fade { from { opacity: 0; } to { opacity: 1; } }
.caaco-modal {
    background: #fff;
    border-radius: 6px;
    max-width: 520px;
    width: 100%;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 50px rgba(0,0,0,0.45);
    font-family: "Segoe UI", "Microsoft JhengHei", Tahoma, sans-serif;
    animation: caaco-modal-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes caaco-modal-pop {
    from { transform: translateY(12px) scale(0.96); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
.caaco-modal__head {
    background: linear-gradient(180deg, #2B579A 0%, #1d3f72 100%);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.caaco-modal__head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}
.caaco-modal__badge {
    display: inline-block;
    background: linear-gradient(180deg, #ffd944, #d8a300);
    color: #2d1f00;
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.6px;
}
.caaco-modal__close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
}
.caaco-modal__close:hover { color: #ffd944; }
.caaco-modal__body {
    padding: 18px 20px 20px;
    color: #222;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.55;
}
.caaco-modal__hint {
    background: #fff8d4;
    border-left: 3px solid #d8a300;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 3px;
    font-size: 12.5px;
}
.caaco-modal__warn {
    background: #fef1c0;
    border: 1px solid #c8a000;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 3px;
    font-size: 12px;
    color: #5a4000;
}
.caaco-modal__fineprint {
    font-size: 11.5px;
    color: #666;
    margin: 14px 0 0;
    line-height: 1.6;
}
.caaco-modal__fineprint a { color: #2B579A; }

/* ---------- In-site feedback form ---------- */
.caaco-modal--feedback .caaco-modal__body {
    overflow-y: auto;
}
.caaco-feedback-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.caaco-feedback-field {
    margin-bottom: 12px;
}
.caaco-feedback-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #444;
    margin-bottom: 4px;
}
.caaco-feedback-req { color: #c41e3a; }
.caaco-feedback-select,
.caaco-feedback-input,
.caaco-feedback-textarea {
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 13px;
    padding: 8px 10px;
    border: 1px solid #bbb;
    border-radius: 3px;
    background: #fff;
    color: #222;
}
.caaco-feedback-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}
.caaco-feedback-select:focus,
.caaco-feedback-input:focus,
.caaco-feedback-textarea:focus {
    outline: none;
    border-color: #2B579A;
    box-shadow: 0 0 0 2px rgba(43, 87, 154, 0.2);
}
.caaco-feedback-meta {
    font-size: 11px;
    color: #888;
    text-align: right;
    margin-top: 4px;
}
.caaco-feedback-signed-as {
    font-size: 12px;
    color: #555;
    margin: 0 0 12px;
    padding: 8px 10px;
    background: #f0f4fa;
    border-radius: 3px;
    line-height: 1.5;
}
.caaco-feedback-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}
.caaco-feedback-status {
    font-size: 12px;
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: 3px;
    line-height: 1.45;
}
.caaco-feedback-status.is-error {
    background: #fde8e8;
    color: #8a1f1f;
    border: 1px solid #e8a0a0;
}
.caaco-feedback-status.is-info {
    background: #e8f0fc;
    color: #234063;
}
.caaco-feedback-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.caaco-feedback-actions .caaco-btn--primary {
    flex: 1;
    min-width: 140px;
}

.caaco-feat-list {
    margin: 6px 0 14px;
    padding: 0;
    list-style: none;
}
.caaco-feat-list li {
    padding: 5px 0 5px 26px;
    position: relative;
    font-size: 13px;
}
.caaco-feat-list li::before {
    content: '✓';
    position: absolute;
    left: 4px;
    top: 5px;
    color: #107C41;
    font-weight: 700;
}

.caaco-price-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 4px 0 8px;
}
.caaco-btn {
    border: none;
    border-radius: 3px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: #f3f3f3;
    color: #222;
    border: 1px solid #ccc;
    transition: transform 0.12s, box-shadow 0.12s;
}
.caaco-btn:hover { background: #e7eef9; border-color: #2B579A; }
.caaco-btn--primary {
    flex: 1;
    min-width: 0;
    background: linear-gradient(180deg, #ffd944, #e8b900);
    color: #2d1f00;
    border-color: #b88c00;
}
.caaco-btn--primary:hover {
    background: linear-gradient(180deg, #ffe478, #f3c700);
    box-shadow: 0 4px 10px rgba(232, 185, 0, 0.35);
    transform: translateY(-1px);
}
.caaco-btn--year { position: relative; }
.caaco-save {
    background: #c41e3a;
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 2px;
    margin-left: 4px;
    font-weight: 700;
}

/* ---------- Tiny "Pro" indicator on desktop icons ---------- */
.xp-desktop__icon[data-requires="pro"] .xp-desktop__icon-label::after {
    content: '🔒';
    font-size: 10px;
    margin-left: 3px;
    opacity: 0.7;
}
body.caaco-is-pro .xp-desktop__icon[data-requires="pro"] .xp-desktop__icon-label::after {
    content: '';
}

/* ---------- Account page styling ---------- */
.caaco-account-shell {
    max-width: 720px;
    margin: 36px auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    padding: 28px 32px;
    font-family: "Segoe UI", "Microsoft JhengHei", Tahoma, sans-serif;
    color: #222;
}
.caaco-account-shell h1 {
    font-size: 22px;
    font-weight: 600;
    color: #2B579A;
    margin: 0 0 16px;
}
.caaco-account-row {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}
.caaco-account-row__avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #ddd; color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 22px;
    background-size: cover;
    background-position: center;
    overflow: hidden;
    /* While the photo loads, or if it can never load, js/caaco-avatar.js
       paints a deterministic gradient behind the initials so the slot is
       never an empty grey circle. */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.32);
}
.caaco-account-row__avatar.is-avatar-fallback,
.xp-start-menu__avatar.is-avatar-fallback,
.xp-systray__avatar.is-avatar-fallback,
.xp-login-welcome__avatar.is-avatar-fallback {
    color: #fff;
}
.caaco-account-row__main { flex: 1; min-width: 0; }
.caaco-account-row__name { font-weight: 600; font-size: 16px; }
.caaco-account-row__email { font-size: 12.5px; color: #666; }
.caaco-account-row__plan {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.caaco-account-row__plan.is-pro {
    background: linear-gradient(180deg, #ffd944, #d8a300);
    color: #2d1f00;
}
.caaco-account-row__plan.is-free {
    background: #eee;
    color: #555;
}
.caaco-account-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}
.caaco-danger-zone {
    border-top: 1px solid #ffd0d0;
    margin-top: 24px;
    padding-top: 14px;
}
.caaco-danger-zone h3 {
    color: #b00020;
    font-size: 13px;
    margin: 0 0 6px;
}
.caaco-btn--danger {
    background: #fff;
    border-color: #b00020;
    color: #b00020;
}
.caaco-btn--danger:hover {
    background: #b00020;
    color: #fff;
}

@media (max-width: 480px) {
    .caaco-modal { font-size: 12px; }
    .caaco-modal__head h2 { font-size: 14px; }
    .caaco-price-row { flex-direction: column; }
    .caaco-account-shell { margin: 12px; padding: 20px; }
}
