/* --- NEUROSPICY MIND: GLOBAL WRAPPER & TYPOGRAPHY --- */
/* Palette: Near-black #1d1c1d, Accent #4A154B (aubergine), Whites, Light grays */
.nsm-tool-wrapper, .nsm-dashboard-wrapper {
    max-width: 800px;
    margin: 20px auto;
    padding: 30px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    position: relative;
    box-sizing: border-box;
    font-size: 16px;
    color: #1d1c1d;
    line-height: 1.6;
}

/* Wider wrapper when game panel is present (Soul Scan) */
.nsm-tool-wrapper:has(.nsm-split-game) {
    max-width: 1080px;
    padding: 0;
    overflow: hidden;
}

/* Prevent iOS double-tap zoom on interactive elements */
.nsm-tool-wrapper,
.nsm-dashboard-wrapper {
    touch-action: manipulation;
}

/* ============================== */
/* --- SPLIT LAYOUT (Desktop) --- */
/* ============================== */
.nsm-split-container {
    display: flex;
    /* No fixed min-height — container sizes to form content,
       game panel stretches to match via flex align-items: stretch (default) */
}

.nsm-split-form {
    flex: 3;
    padding: 30px;
    overflow-y: auto;
}

.nsm-split-game {
    flex: 1;
    min-width: 240px;
    max-width: 280px;
    background: #87CEEB;
    position: relative;
    border-left: 1px solid rgba(0,0,0,0.06);
    border-radius: 0 12px 12px 0;
    overflow: hidden;
}

.nsm-split-game canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.nsm-tool-wrapper *, .nsm-dashboard-wrapper * {
    box-sizing: border-box;
}

.nsm-tool-wrapper .nsm-step { display: none !important; }
.nsm-tool-wrapper .nsm-step.active { display: block !important; animation: nsmFadeIn 0.4s ease; }

@keyframes nsmFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- HEADINGS --- */
.nsm-tool-wrapper h1 {
    font-size: 1.8em;
    color: #1d1c1d;
    margin-bottom: 20px;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

/* Question headings — lighter weight for readability */
.nsm-tool-wrapper h2 {
    font-size: 1.25em;
    color: #1d1c1d;
    margin-bottom: 15px;
    font-weight: 400;
    line-height: 1.45;
}

.nsm-dashboard-wrapper h2 {
    font-size: 1.4em;
    color: #1d1c1d;
    margin-bottom: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.nsm-dashboard-wrapper h3 {
    font-size: 1.2em;
    color: #1d1c1d;
    margin-bottom: 10px;
    font-weight: 700;
}

/* --- PHASE LABELS --- */
.nsm-phase-label {
    display: inline-block;
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #696969;
    margin-bottom: 10px;
}

/* --- FORM ELEMENTS --- */
.nsm-form-group {
    margin-bottom: 25px;
    position: relative;
}

.nsm-form-group label {
    display: block;
    margin-bottom: 8px;
    line-height: 1.4;
    color: #454245;
    font-weight: 500;
    font-size: 15px;
}

.nsm-desc {
    color: #454245;
    margin-bottom: 20px;
    font-size: 17px;
    line-height: 1.7;
}

.nsm-landing .nsm-desc p {
    margin-bottom: 16px;
}

.nsm-form-row {
    display: flex;
    gap: 15px;
}

.nsm-half {
    flex: 1;
}

.nsm-tool-wrapper input[type="email"],
.nsm-tool-wrapper input[type="text"],
.nsm-tool-wrapper input[type="number"],
.nsm-tool-wrapper select,
.nsm-tool-wrapper textarea,
.nsm-dashboard-wrapper input[type="email"],
.nsm-dashboard-wrapper input[type="text"],
.nsm-dashboard-wrapper select,
.nsm-dashboard-wrapper textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: inherit;
    color: #1d1c1d;
}

/* Identical box model for all single-line controls (select + inputs) */
.nsm-tool-wrapper input[type="email"],
.nsm-tool-wrapper input[type="text"],
.nsm-tool-wrapper input[type="number"],
.nsm-tool-wrapper select,
.nsm-dashboard-wrapper input[type="email"],
.nsm-dashboard-wrapper input[type="text"],
.nsm-dashboard-wrapper select {
    height: 50px;
    padding: 0 14px;
    line-height: 48px;
}

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

.nsm-tool-wrapper textarea,
.nsm-dashboard-wrapper textarea {
    padding: 14px;
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.nsm-tool-wrapper input:focus,
.nsm-tool-wrapper select:focus,
.nsm-tool-wrapper textarea:focus,
.nsm-dashboard-wrapper input:focus,
.nsm-dashboard-wrapper select:focus,
.nsm-dashboard-wrapper textarea:focus {
    outline: none;
    border-color: #4A154B;
    box-shadow: 0 0 0 3px rgba(74, 21, 75, 0.08);
    background: #fff;
}

.nsm-input-disabled {
    background-color: #f4f4f4 !important;
    color: #696969;
    cursor: not-allowed;
}

/* --- VALIDATION & MESSAGES --- */
.nsm-error-border {
    border-color: #D72B3F !important;
    background-color: #FFF5F6 !important;
}

.nsm-error-msg {
    color: #D72B3F;
    font-size: 0.85em;
    margin-top: 5px;
    display: block;
    font-weight: 500;
}

.nsm-otp-success {
    background: #E8F5E1;
    color: #1a5e1a;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 15px;
    border: 1px solid #C3E6CB;
    text-align: center;
}

/* --- PROGRESS BAR --- */
.nsm-progress-bar {
    height: 4px;
    background: #eee;
    border-radius: 2px;
    margin-bottom: 30px;
    overflow: hidden;
    max-width: 100%;
}

.nsm-progress-fill {
    height: 100%;
    background: #1d1c1d;
    border-radius: 2px;
    transition: width 0.3s ease;
    max-width: 100%;
}

/* ============================== */
/* --- BUTTONS: Primary CTA --- */
/* ============================== */
button.nsm-btn-cta,
button.nsm-btn-next,
#nsm-btn-verify,
#nsm-btn-dash-login,
#nsm-btn-start {
    background: #1d1c1d;
    color: #fff;
    border: none;
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.3;
}

button.nsm-btn-cta:hover,
button.nsm-btn-next:hover,
#nsm-btn-verify:hover,
#nsm-btn-dash-login:hover,
#nsm-btn-start:hover {
    background: #3d3c3d;
    transform: translateY(-1px);
}

button.nsm-btn-cta:active,
button.nsm-btn-next:active,
#nsm-btn-verify:active,
#nsm-btn-dash-login:active,
#nsm-btn-start:active {
    transform: translateY(0);
}

/* Arrow icon inside CTA buttons */
button .nsm-btn-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ============================== */
/* --- NAVIGATION LAYOUT ---      */
/* Continue centered top row,     */
/* Back bottom-right, underlined  */
/* ============================== */
.nsm-nav-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 30px;
    gap: 16px;
}

/* Back link: bottom-right, underlined */
button.nsm-btn-prev {
    background: none !important;
    border: none !important;
    color: #696969 !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    cursor: pointer;
    padding: 4px 0 !important;
    text-decoration: underline;
    transition: color 0.2s;
    order: 2;
    align-self: flex-end;
    margin-top: 0 !important;
}

button.nsm-btn-prev:hover {
    color: #1d1c1d !important;
    text-decoration: underline;
    background: none !important;
    transform: none !important;
}

/* Primary nav CTA (Continue) */
.nsm-nav-buttons .nsm-btn-next,
.nsm-nav-buttons #nsm-btn-verify {
    order: 1;
    min-width: 200px;
}

/* --- Secondary Buttons --- */
button.nsm-btn-secondary {
    background: #fff;
    color: #1d1c1d;
    border: 1px solid #ddd;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

button.nsm-btn-secondary:hover {
    background: #f4f4f4;
    border-color: #bbb;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- LOGIN LINK --- */
.nsm-login-link {
    text-align: center;
    margin-top: 25px;
    font-size: 14px;
}

.nsm-login-link a {
    color: #696969;
    text-decoration: none;
    font-weight: 400;
}

.nsm-login-link a:hover {
    color: #1d1c1d;
    text-decoration: underline;
}

/* --- LANDING PAGE --- */
.nsm-landing {
    text-align: center;
    padding: 20px 0;
}

.nsm-landing .nsm-desc {
    text-align: left;
    max-width: 600px;
    margin: 0 auto 30px auto;
}

/* --- RESEND OTP --- */
.nsm-resend-wrap {
    text-align: center;
    margin-top: 14px;
    font-size: 14px;
    color: #696969;
}

.nsm-resend-wrap a {
    color: #4A154B;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.nsm-resend-wrap a:hover {
    text-decoration: underline;
}

.nsm-resend-wrap .nsm-resend-timer {
    color: #999;
}

/* --- DASHBOARD STYLES --- */
.nsm-dashboard-login {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.nsm-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.nsm-user-info {
    font-size: 0.9em;
    color: #696969;
}

#nsm-btn-logout {
    margin-left: 15px;
    color: #696969;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
}

#nsm-btn-logout:hover {
    color: #1d1c1d;
    text-decoration: underline;
}

.nsm-empty-state {
    text-align: center;
    padding: 40px;
    background: #f9f9f9;
    border-radius: 8px;
    color: #696969;
    font-size: 16px;
}

.nsm-empty-state a {
    color: #4A154B;
    font-weight: 600;
}

/* --- SECTIONS --- */
.nsm-section {
    margin-bottom: 30px;
    padding: 25px;
    background: #fafafa;
    border-radius: 10px;
    border: 1px solid #eee;
}

.nsm-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.nsm-section-header h3 {
    margin: 0;
}

.nsm-section-header button {
    margin-top: 0;
}

/* --- GENERATOR SECTION --- */
.nsm-generator-section {
    background: #1d1c1d;
    color: #fff;
    border: none;
    text-align: center;
}

.nsm-generator-section h3 {
    color: #fff;
    font-size: 1.4em;
}

.nsm-generator-section p {
    color: #fff;
    max-width: 540px;
    margin: 0 auto 20px auto;
    line-height: 1.6;
}

.nsm-generator-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.nsm-generator-section .nsm-btn-cta {
    background: #fff;
    color: #1d1c1d;
    margin-top: 0;
}

.nsm-generator-section .nsm-btn-cta:hover {
    background: #e0e0e0;
}

.nsm-generator-section .nsm-btn-secondary {
    border-color: rgba(255,255,255,0.5);
    color: #fff;
    background: transparent;
    margin-top: 0;
}

.nsm-generator-section .nsm-btn-secondary:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.7);
}

/* --- CORE IDENTITY GRID --- */
.nsm-identity-grid {
    display: grid;
    gap: 1px;
    background: #eee;
    border-radius: 8px;
    overflow: hidden;
}

.nsm-identity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #fff;
}

.nsm-identity-label {
    font-weight: 600;
    font-size: 0.85em;
    color: #696969;
    min-width: 180px;
    flex-shrink: 0;
}

.nsm-identity-value {
    flex: 1;
    color: #1d1c1d;
    font-size: 0.95em;
    word-break: break-word;
}

.nsm-btn-edit {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.3;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.nsm-identity-item:hover .nsm-btn-edit {
    opacity: 1;
}

/* --- LIFE LORE --- */
.nsm-lore-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid #1d1c1d;
}

.nsm-lore-main {
    flex: 1;
}

.nsm-lore-type {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    color: #696969;
    margin-right: 8px;
    letter-spacing: 0.04em;
}

.nsm-lore-impact {
    display: inline-block;
    font-size: 0.7em;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    background: #f4f4f4;
    color: #696969;
}

.nsm-lore-text {
    margin: 8px 0 4px 0;
    color: #1d1c1d;
    font-size: 0.95em;
    line-height: 1.5;
}

.nsm-lore-date {
    font-size: 0.8em;
    color: #999;
}

.nsm-btn-delete-lore {
    background: none;
    border: 1px solid #eee;
    color: #D72B3F;
    font-size: 1.2em;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    margin-left: 10px;
    transition: all 0.2s;
}

.nsm-btn-delete-lore:hover {
    background: #D72B3F;
    color: #fff;
    border-color: #D72B3F;
}

.nsm-lore-empty {
    padding: 25px;
    margin: 0;
}

/* --- MODAL --- */
.nsm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9998;
}

.nsm-modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    z-index: 9999;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.nsm-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: #f4f4f4;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #696969;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.nsm-modal-close:hover {
    background: #e5e5e5;
}

/* Modal CTA buttons — explicit color on hover to prevent theme overrides */
.nsm-modal-content .nsm-btn-cta {
    background: #1d1c1d;
    color: #fff !important;
}

.nsm-modal-content .nsm-btn-cta:hover {
    background: #3d3c3d;
    color: #fff !important;
}

/* --- SAVING ANIMATION --- */
.nsm-saving-overlay {
    text-align: center;
    padding: 60px 20px;
}

.nsm-saving-overlay h3 {
    color: #1d1c1d;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.nsm-saving-overlay p {
    color: #696969;
    font-size: 16px;
}

.nsm-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top-color: #1d1c1d;
    border-radius: 50%;
    animation: nsmSpin 0.8s linear infinite;
    margin-bottom: 20px;
}

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

/* --- Tablet & Mobile: game becomes horizontal strip --- */
@media (max-width: 768px) {
    .nsm-split-container {
        display: flex;
        flex-direction: column;
        min-height: auto;
    }
    .nsm-split-game {
        order: -1;
        flex: none;
        min-width: 100%;
        max-width: 100%;
        height: 150px;
        border-left: none;
        border-bottom: 1px solid rgba(0,0,0,0.06);
        border-radius: 12px 12px 0 0;
    }
    .nsm-split-form {
        flex: none;
    }
    .nsm-tool-wrapper:has(.nsm-split-game) {
        max-width: 800px;
        padding: 0;
    }
}

/* --- Mobile Adjustments --- */
@media (max-width: 600px) {
    .nsm-tool-wrapper, .nsm-dashboard-wrapper { padding: 20px; }
    .nsm-tool-wrapper:has(.nsm-split-game) { padding: 0; }
    .nsm-split-form { padding: 20px; }
    .nsm-tool-wrapper h1 { font-size: 1.4em; }
    .nsm-form-row { flex-direction: column; gap: 0; }
    .nsm-dashboard-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    #nsm-btn-logout { margin-left: 0; }
    .nsm-nav-buttons { flex-wrap: wrap; }
    .nsm-modal-content { width: 95%; padding: 20px; }
    .nsm-identity-item { flex-wrap: wrap; }
    .nsm-identity-label { min-width: 100%; margin-bottom: 2px; }
    .nsm-generator-actions { flex-direction: column; align-items: center; }
    .nsm-lore-item { flex-direction: column; }
    .nsm-btn-delete-lore { margin-left: 0; margin-top: 10px; align-self: flex-end; }

    /* Prevent iOS auto-zoom: all focusable fields must be ≥16px */
    .nsm-tool-wrapper input[type="text"],
    .nsm-tool-wrapper input[type="email"],
    .nsm-tool-wrapper input[type="number"],
    .nsm-tool-wrapper input[type="tel"],
    .nsm-tool-wrapper select,
    .nsm-tool-wrapper textarea,
    .nsm-dashboard-wrapper input[type="text"],
    .nsm-dashboard-wrapper input[type="email"],
    .nsm-dashboard-wrapper select,
    .nsm-dashboard-wrapper textarea {
        font-size: 16px !important;
        touch-action: manipulation;
    }
}
