@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* =========================================================
   AI Math Solver — redesign styles
   Scoped under #aiMathSolver to avoid global leakage.
   ========================================================= */

/* Reserve the scrollbar gutter so opening a modal (which locks body scroll)
   doesn't reflow the page sideways ("shaking"). */
html { scrollbar-gutter: stable; }

#aiMathSolver {
    --ams-blue: #1670a7;
    --ams-blue-grad: linear-gradient(90deg, #19A4F9 0%, #197EBD 100%);
    --ams-border: #e6e9ee;
    --ams-muted: #A4A4A4;
    --ams-text: #2b2f36;
    --ams-soft: #f6f8fb;
    /* max-width: 1000px; */
    margin: 0 auto;
    font-family: 'Inter', sans-serif;
}
/* apply Inter across the whole tool UI (overrides the global `* { font: Lato }` reset).
   The modals are included outside #aiMathSolver in the blade, so scope them too. */
#aiMathSolver,
#aiMathSolver *,
.ams-canvas-modal,
.ams-canvas-modal *,
.adv-modal,
.adv-modal * {
    font-family: 'Inter', sans-serif;
}

/* ---------- Page title (rendered by layout, outside #aiMathSolver) ---------- */
.ams-page-title {
    color: #1d2127 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 36px !important;
    font-weight: 800;
}
/* the global `* { font: Lato }` reset hits every descendant directly,
   so force Inter on the title/description AND their inner nodes */
.ams-page-title,
.ams-page-title *,
#after_title_line,
#after_title_line * {
    font-family: 'Inter', sans-serif !important;
}
#after_title_line {
    color: #000;
    font-family: 'Inter', sans-serif !important;
    font-size: 16px !important;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

/* ---------- Heading ---------- */
.ams-head {
    text-align: center;
    margin-bottom: 22px;
}
.ams-head h1 {
    font-weight: 800;
    color: #1d2127;
    font-size: 40px;
    margin-bottom: 10px;
}
.ams-head p {
    color: #6b7280;
    font-size: 16px;
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ---------- Main card ---------- */
.ams-card {
    position: relative;
    border: 1px solid var(--ams-border);
    border-radius: 14px;
    background: #fff;
    padding: 24px;
    box-shadow: 0 3px 10px rgba(25, 164, 249, .08), 0 1px 3px rgba(25, 164, 249, .06);
}

/* ---------- QR scan-to-upload popover ---------- */
.ams-qr {
    position: absolute;
    top: 64px;
    left: 20px;
    z-index: 60;
    width: 200px;
    padding: 16px 14px 12px;
    background: #fff;
    border: 1px solid var(--ams-border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .18);
    text-align: center;
}
.ams-qr-close {
    position: absolute;
    top: 6px;
    right: 9px;
    cursor: pointer;
    color: var(--ams-muted);
    font-size: 12px;
    line-height: 1;
}
.ams-qr-close:hover { color: var(--ams-text); }
.ams-qr-imgwrap {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 4px auto 0;
}
.ams-qr-img {
    width: 150px;
    height: 150px;
    object-fit: contain;
}
.ams-qr-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}
.ams-qr-loader.d-none { display: none; }
.ams-qr p {
    font-size: 12px;
    color: var(--ams-muted);
    margin: 10px 0 0;
    line-height: 1.4;
}
@media (max-width: 600px) {
    .ams-qr { left: 50%; transform: translateX(-50%); }
}

.ams-card-top {
    display: flex;
    align-items: stretch;
    gap: 18px;
}

/* ---------- Drop zone ---------- */
.ams-dropzone {
    flex: 0 0 208px;
    width: 208px;
    border: 1.5px dashed #c7d0db;
    border-radius: 12px;
    background: #fcfdff;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    transition: border-color .2s, background .2s;
    cursor: pointer;
}
.ams-dropzone.dragover,
.ams-dropzone:hover {
    border-color: var(--ams-blue);
    background: #f3f9ff;
}
.ams-dropzone-icons {
    display: flex;
    gap: 14px;
}
/* vertical divider between the two icon buttons */
.ams-dropzone-icons .ams-icon-btn + .ams-icon-btn::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 22px;
    background: #EBEBEB;
}
.ams-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    border: 1px solid var(--ams-border);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
}
.ams-icon-btn:hover {
    border-color: var(--ams-blue);
    background: #f3f9ff;
}
.ams-icon-btn  img {
    width: 12.61px;
    height: 11.59px;
    object-fit: contain;
}

.ams-qr-icon img {
    width: 9.75px;
    height: 16.5px;
    object-fit: contain;
}


.ams-dropzone-text {
    font-size: 13px;
    color: #374151;
    line-height: 1.45;
}
.ams-dropzone-text .ams-link {
    color: var(--ams-blue);
}

/* uploaded files preview inside dropzone */
.ams-uploaded {
    display: none;
    width: 100%;
}
.ams-dropzone.has-file {
    border-style: solid;
    border-color: var(--ams-border);
    background: #fff;
    padding: 8px;
    cursor: default;
}
.ams-dropzone.has-file:hover {
    border-color: var(--ams-border);
    background: #fff;
}
.ams-dropzone.has-file .ams-uploaded {
    display: block;
}

.ams-preview {
    position: relative;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(16, 24, 40, .12);
}
.ams-preview-img {
    display: block;
    width: 100%;
    height: 150px;
    object-fit: contain;
    border-radius: 10px;
    background: var(--ams-soft);
}
.ams-preview-img.pdf {
    padding: 16px;
}
.ams-preview-crop,
.ams-preview-remove {
    position: absolute;
    top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.ams-preview-crop {
    left: 6px;
}
.ams-preview-remove {
    right: 6px;
    border-radius: 50%;
    background: #e53935;   /* red remove button */
}
.ams-preview-remove:hover {
    background: #c62828;
}
.ams-preview-crop img,
.ams-preview-remove img {
    width: 11px;
    height: 11px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* PDF multi-page notice */
.ams-pdf-note {
    margin: 10px 2px 0;
    padding: 8px 12px;
    background: #fff8e6;
    border: 1px solid #ffe2a8;
    border-radius: 8px;
    color: #8a6d1a;
    font-size: 12.5px;
    line-height: 1.45;
}
.ams-pdf-note.d-none { display: none; }

/* ---------- Divider ---------- */
.ams-divider {
    width: 1px;
    background: var(--ams-border);
    align-self: stretch;
}

/* ---------- Question / input ---------- */
.ams-input-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
}
.ams-input {
    flex: 1 1 auto;
    min-height: 120px;
    outline: 0;
    border: none;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ams-text);
    overflow: auto;
    resize: none;
    padding: 4px 2px;
    padding-right: 80px;
}
.ams-clear-btn {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 6;
    padding: 4px 14px;
    border: 1px solid var(--ams-border);
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    color: var(--ams-text);
    cursor: pointer;
    transition: all .2s;
}
.ams-clear-btn:hover {
    border-color: var(--ams-blue);
    color: var(--ams-blue);
}
.ams-clear-btn.d-none { display: none; }
.ams-sample-btn {
    display: inline-flex;
    align-items: center;
    gap: 5.63px;
    margin-left: 6px;
    padding: 5.63px 11.26px;
    border: 0.94px solid #E5E7EB;
    border-radius: 5px;
    background: #F3F4F6;
    font-size: 13px;
    color: var(--ams-text);
    cursor: pointer;
    vertical-align: middle;
    transition: all .2s;
}
.ams-sample-btn:hover {
    border-color: var(--ams-blue);
    color: var(--ams-blue);
}

/* inline placeholder row (text + sample chip) overlaid at the top, shown when empty */
.ams-input-hint {
    position: absolute;
    top: 4px;
    left: 2px;
    right: 2px;
    color: var(--ams-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    pointer-events: none;
}
.ams-input-hint .ams-sample-btn {
    pointer-events: auto;
}

/* ---------- Toolbar ---------- */
.ams-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--ams-border);
    margin-top: 30px;
    padding-top: 24px;
    flex-wrap: wrap;
}
.ams-tools-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ams-tool-btn {
    display: inline-flex;       /* hug content — no fixed width */
    align-items: center;
    gap: 5.85px;
    height: 37.05px;            /* keep every toolbar button the same height */
    padding: 0 14.04px;
    box-sizing: border-box;
    border: 1.2px solid #DEE0E3;
    border-radius: 5px;
    background: #FFFFFF;
    color: var(--ams-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    position: relative;
}
/* project .d-none lacks !important, so it loses to .ams-tool-btn's display — force it */
.ams-tool-btn.d-none { display: none !important; }
.ams-tool-btn:hover {
    border-color: #c7d0db;
    background: var(--ams-soft);
}
.ams-tool-btn.active {
    border-color: #4495FB;      /* keep 1.2px width — only the colour changes */
    background: #EFF6FF;
    color: var(--ams-blue);
    font-size: 14px !important;
    font-weight: 700;
}
.ams-tool-btn .ams-tb-icon {
    object-fit: contain;
}
/* per-icon sizes — desktop (from the original img width/height) */
.ams-tb-icon--math     { width: 15.45px; height: 12.07px; }
.ams-tb-icon--canvas   { width: 12.06px; height: 12.07px; }
.ams-tb-icon--tools    { width: 12.82px; height: 10.42px; }
.ams-tb-icon--language { width: 12.82px; height: 12.82px; }
.ams-tb-icon--advance  { width: 21.06px; height: 21.06px; }
/* per-icon sizes — small screens */
@media (max-width: 767px) {
    .ams-tb-icon--math     { width: 15.45px; height: 12.07px; }
    .ams-tb-icon--canvas   { width: 12.06px; height: 12.07px; }
    .ams-tb-icon--tools    { width: 12.82px; height: 10.42px; }
    .ams-tb-icon--language { width: 12.82px; height: 12.82px; }
    .ams-tb-icon--advance  { width: 18px;    height: 18px; }
}
.ams-tb-label {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ams-tool-btn .ams-caret {
    font-size: 10px;
    opacity: .6;
}
.ams-tool-btn--icon {
    padding: 0 10px;
}

/* tooltips (dark bubble with downward caret, shown above the element) */
.ams-has-tip { position: relative; }
.ams-tool-btn .ams-tip,
.ams-has-tip .ams-tip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #4b4b4b;
    color: #fff;
    text-align: center;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45;
    border-radius: 12px;
    padding: 9px 13px;
    width: max-content;
    max-width: 220px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
    transition: opacity .18s ease, transform .18s ease;
    z-index: 1000;
    pointer-events: none;
}
.ams-tool-btn .ams-tip::after,
.ams-has-tip .ams-tip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #4b4b4b;
}
.ams-tool-btn:hover .ams-tip,
.ams-has-tip:hover .ams-tip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
/* toolbar (tools-left) tooltip — larger, rounder bubble with the tail on the RIGHT */
.ams-tools-left .ams-tip {
    left: auto;
    right: 0;
    transform: translateY(4px);
    background: #4d4d4d;
    text-align: left;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    border-radius: 10px;
    padding: 10px 8px;
    max-width: 130px;
}
.ams-tools-left .ams-tool-btn:hover .ams-tip {
    transform: translateY(0);
}
.ams-tools-left .ams-tip::after {
    left: auto;
    right: 30px;             /* tail near the right, pointing down at the button */
    transform: none;
    border-width: 11px;
    border-top-color: #4d4d4d;
}
/* the icon-only (tips/advanced) button is narrow — centre its tooltip + caret over it */
.ams-tools-left .ams-tool-btn--icon .ams-tip {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(4px);
}
.ams-tools-left .ams-tool-btn--icon:hover .ams-tip {
    transform: translateX(-50%) translateY(0);
}
.ams-tools-left .ams-tool-btn--icon .ams-tip::after {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}
/* right-aligned variant (for elements near the right edge, e.g. Solve) */
.ams-tip--right {
    left: auto !important;
    right: 0;
    transform: translateY(4px) !important;
}
/* caret over the button centre (specificity must beat the base .ams-has-tip .ams-tip::after) */
.ams-has-tip .ams-tip--right::after {
    left: auto;
    right: 46px;
    transform: none;
}
.ams-has-tip:hover .ams-tip--right { transform: translateY(0) !important; }
/* downward variant (for elements inside overflow-hidden boxes, e.g. result actions) */
.ams-tip--down {
    bottom: auto;
    top: calc(100% + 12px);
    transform: translateX(-50%) translateY(-4px);
}
.ams-tip--down::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #4b4b4b;
}
.ams-has-tip:hover .ams-tip--down { transform: translateX(-50%) translateY(0); }

/* dropdown menu */
.ams-dropdown {
    position: relative;
}
.ams-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--ams-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
    padding: 6px;
    z-index: 50;
    display: none;
}
.ams-menu.open {
    display: block;
}
.ams-menu-item {
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 14px;
    color: var(--ams-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.ams-menu-item:hover {
    background: var(--ams-soft);
}
.ams-menu-item.active {
    color: var(--ams-blue);
    background: #eef7ff;
}
/* "Clear" button at the bottom of the Tools dropdown (math-gpt style) */
.ams-menu-clear {
    display: block;
    width: calc(100% - 8px);
    margin: 6px 4px 2px;
    padding: 8px 10px;
    border: 1px solid var(--ams-border);
    border-radius: 8px;
    background: #fff;
    color: var(--ams-text);
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
}
.ams-menu-clear:hover {
    border-color: var(--ams-blue);
    color: var(--ams-blue);
    background: var(--ams-soft);
}

/* searchable language menu — right-aligned (it's the rightmost dropdown) */
.ams-menu--lang {
    min-width: 240px;
    padding: 8px;
    left: auto;
    right: 0;
}
.ams-menu-search {
    padding: 2px 2px 8px;
    position: sticky;
    top: 0;
    background: #fff;
}
.ams-menu-search input {
    width: 100%;
    border: 1px solid var(--ams-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    outline: 0;
    color: var(--ams-text);
}
.ams-menu-search input:focus {
    border-color: var(--ams-blue);
}
.ams-menu-list {
    max-height: 240px;
    overflow-y: auto;
}
.ams-menu-list::-webkit-scrollbar { width: 8px; }
.ams-menu-list::-webkit-scrollbar-thumb {
    background: #d6dbe2;
    border-radius: 8px;
}
.ams-menu-empty {
    padding: 12px 10px;
    font-size: 13px;
    color: var(--ams-muted);
    text-align: center;
}

/* ---------- Solve button ---------- */
.ams-solve-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10.71px;
    height: 45px;
    padding: 11.79px 28px;
    border: none;
    border-radius: 5px;
    background: #2277AB;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-sizing: border-box;
    transition: filter .2s, transform .05s;
    width: 105px !important;
}
.ams-solve-btn:hover {
    filter: brightness(1.05);
}
.ams-solve-btn:active {
    transform: translateY(1px);
}
.ams-solve-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    filter: none;
    transform: none;
}
.ams-solve-btn img {
    width: 18px;
    height: 18px;
}

/* ---------- Examples ---------- */
.ams-examples {
    margin-top: 20px;
}
.ams-examples-title {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: center;
    color: var(--ams-muted);
    font-size: 16px;
    margin-bottom: 18px;
}
.ams-examples-title::before,
.ams-examples-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--ams-border);
}
.ams-example-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.ams-example-card {
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f6f7f9;
    padding: 10px 12px;
    cursor: pointer;
    transition: box-shadow .2s, transform .2s, background .2s;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ams-example-card:hover {
    background: #eef1f5;
    box-shadow: 0 6px 18px rgba(16, 24, 40, .06);
    transform: translateY(-2px);
}
.ams-tag {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    height: 24px;
    background: #2277AB33;
    color: #2277AB;
    font-size: 12px;
    font-weight: 400;
    padding: 0 8px;
    border-radius: 5px;
}
.ams-example-body {
    background: #fff;          /* white content box inside the gray card */
    border-radius: 12px;
    padding: 10px 15px;
    font-size: 14px;
    color: #4b5563;
    line-height: 1.55;
    flex: 1;
    display: flex;
    align-items: flex-start;   /* text starts at the top */
}
.ams-example-body.center {
    padding: 12px 10px;             /* white space around the image on all sides */
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ams-example-body img {
    width: 100%;
    height: auto;
    display: block;
}

/* ---------- Crop modal (matches the shared design used in all AI tools) ---------- */
#cropModal .modal-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
#croppie-element {
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}
#croppie-element img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.new-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    flex-direction: column;
}
.new-loader-spinner {
    width: 70px;
    height: 70px;
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-top: 5px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.new-loader-text {
    margin-top: 10px;
    text-align: center;
    font-size: 18px;
    color: #333;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
#cropModalActions button.calculate {
    padding: 9px 15px;
    font-size: 12px;
}
/* Crop button to bottom-right (this tool only) */
#cropModalActions {
    justify-content: flex-end !important;
}
#cropModalActions > div {
    text-align: right !important;
}
@media only screen and (max-width: 600px) {
    .new-loader {
        left: 50%;
        top: 25%;
        transform: translateX(-50%);
    }
}
@media only screen and (max-width: 768px) {
    button.imageCrop {
        padding: 5px;
        font-size: 12px;
        height: 30px;
    }
}

/* ---------- Canvas (draw) modal ---------- */
.ams-canvas-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000000000;
    background: rgba(0, 0, 0, .55);
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.ams-canvas-modal.open {
    display: flex;
}
.ams-canvas-dialog {
    background: #141414;
    border: 1px solid #2a2a2a;
    border-radius: 14px;
    width: 920px;
    max-width: 100%;
    padding: 18px 20px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
    color: #e7e7e7;
}
.ams-canvas-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.ams-canvas-head h3 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin: 0;
}
.ams-canvas-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #cfcfcf;
    font-size: 13px;
}
.ams-canvas-close:hover {
    background: #262626;
    color: #fff;
}
.ams-canvas-stage {
    background: #000;
    border-radius: 10px;
    border: 1px solid #2a2a2a;
    height: 440px;
    overflow: hidden;
    touch-action: none;
}
#amsCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}
.ams-canvas-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.ams-canvas-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ams-canvas-center {
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
}
.ams-canvas-label {
    font-size: 13px;
    color: #b6b6b6;
}
.ams-canvas-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
    background: #222;
    color: #e7e7e7;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}
.ams-canvas-btn:hover {
    background: #2d2d2d;
}
.ams-canvas-cancel {
    background: #2a2a2a;
}
.ams-canvas-confirm {
    background: var(--ams-blue-grad);
    border-color: #197EBD;
    background-color: #197EBD;
    color: #fff;
    font-weight: 600;
    padding: 8px 22px;
}
.ams-canvas-confirm:hover {
    filter: brightness(1.06);
    background-color: #197EBD;

}

.ams-canvas-colors {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ams-swatch {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px #3a3a3a;
    display: inline-block;
    position: relative;
}
.ams-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 1px #fff;
}
.ams-swatch-custom {
    overflow: hidden;
}
.ams-swatch-custom input[type="color"] {
    position: absolute;
    inset: -4px;
    width: 140%;
    height: 140%;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    opacity: 0;
}
.ams-canvas-range {
    accent-color: #19A4F9;
    width: 120px;
}
.ams-canvas-wval {
    font-size: 13px;
    color: #e7e7e7;
    min-width: 14px;
    text-align: center;
}
@media (max-width: 600px) {
    .ams-canvas-stage { height: 320px; }
    .ams-canvas-tools { gap: 10px; }
    .ams-canvas-center { order: 3; width: 100%; }
}

/* ---------- Free-queries banner ---------- */
.ams-queries-banner {
    text-align: center;
    font-size: 14px;
    color: #5b6470;
    /* top-only shadow — negative spread keeps it from bleeding left/right/bottom */
    box-shadow: 0 -3px 4px -3px rgba(21, 143, 217, 0.18);
    margin: 16px 0 0;
    padding-top: 14px;
}
.ams-queries-banner.d-none { display: none !important; }
.ams-queries-banner .ams-q-count {
    color: #f59e0b;
    font-weight: 700;
}
.ams-queries-banner a {
    color: var(--ams-blue);
    font-weight: 600;
    text-decoration: none;
}
.ams-queries-banner a:hover { text-decoration: underline; }

/* ---------- Result card ---------- */
.ams-result {
    margin-top: 16px;
}
.ams-result-card {
    border: 1px solid var(--ams-border);
    border-radius: 14px;
    background: #FCFCFD;
    /* box-shadow: 0 6px 24px rgba(25, 164, 249, .08); */
    overflow: visible;   /* let action tooltips show without being clipped */
}

.ams-q-img .d-none{
    display: none !important;
}
/* question — its own white box inside the answer card */
.ams-question {
    margin: 26px 27px;
    padding: 14.2px;
    background: #fff;
    border: 1px solid var(--ams-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 100%;
}
.ams-q-tag {
    display: inline-flex;
    align-items: center;
    height: 25.89px;
    background: #1670A71A;
    color: #000000;
    font-size: 12px;
    font-weight: 600;
    padding: 0 11.89px;
    border-radius: 8px;
}
.ams-q-body {
    flex: 1;
    min-width: 0;
    font-size: 18px;
    color: var(--ams-text);
    line-height: 1.6;
    word-break: break-word;
}
.ams-q-text {
    font-size: 18px;
}
.ams-q-img {
    max-width: 220px;
    max-height: 160px;
    border-radius: 8px;
    margin-top: 8px;
    display: block;
}
.ams-q-img.d-none {
    display: none !important;
}

/* solutions */
.ams-solutions {
    padding: 0;
}
.ams-sol-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    position: relative;
    z-index: 6;            /* keep header (and its action tooltips) above the answer content */
}
/* inset bottom divider — leaves space on the left and right */
.ams-sol-head::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 0;
    height: 1px;
    background: var(--ams-border);
}
.ams-sol-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15.17px;
    color: var(--ams-text);
}
.ams-sol-icon { width: 32.8px; height: 32.8px; object-fit: contain; }
.ams-sol-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ams-act {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    transition: background .15s;
}
.ams-act:hover { background: var(--ams-soft); }
.ams-act img {
    width: 13.25px;
    height: 13.25px;
    object-fit: contain;
}
.ams-act-spinning { pointer-events: none; }
.ams-act-spinning img { animation: spin 0.8s linear infinite; }

/* answer body */
.ams-answer {
    padding: 16px 18px;
    font-size: 16px;
    line-height: 1.7;
    color: #2b2f36;
}
.ams-answer:empty { padding: 0; }
.ams-answer h1, .ams-answer h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 16px 0 8px;
}
.ams-answer h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 16px 0 8px;
}
.ams-answer p { margin: 10px 0; }
.ams-answer ul, .ams-answer ol { margin: 10px 0; padding-left: 22px; }
.ams-answer strong { font-weight: 700; }

/* loading */
.ams-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px 18px;
}
.ams-spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #e8eef5;
    border-top-color: var(--ams-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.ams-loading p { color: #6b7280; font-size: 13px; margin: 0; }

/* footer */
.ams-result-foot {
    border-top: 1px solid var(--ams-border);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
}
/* keep it hidden until the answer is generated (project .d-none lacks !important) */
.ams-result-foot.d-none {
    display: none !important;
}
.ams-result-foot .ams-ask-more {
    align-self: center;
}
.ams-result-foot .ams-feedback {
    justify-content: flex-end;
}
.ams-ask-more {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: #FFFFFF;
    color: var(--ams-text);
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
    transition: box-shadow .15s, color .15s;
}
.ams-ask-more:hover {
    box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.3);
    color: var(--ams-blue);
}
.ams-feedback {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #000;
}
.ams-feedback strong {
    font-size: 16px;
    font-weight: 700;
    line-height: 18px;
    color: #000;
}
/* white rounded box around the Yes / No options */
.ams-fb-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 5px;
    background: #FFFFFF;
    box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.2);
}
.ams-fb {
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    line-height: 18px;
    color: #000;
    border-radius: 6px;
    transition: color .15s;
}
.ams-fb:hover { color: var(--ams-blue); }
.ams-fb.active { color: var(--ams-blue); font-weight: 600; }
.ams-fb-sep { color: #000; }
.ams-disclaimer {
    text-align: center;
    color: #aab2bd;
    font-size: 12px;
    margin: 12px 0 16px;
}

/* result-area buttons: ensure clear hover feedback (second-screen) */
.ams-act,
.ams-ask-more,
.ams-fb,
.ams-queries-banner a {
    transition: all .15s ease;
}
.ams-act:hover {
    background: #eaf4ff;
    color: var(--ams-blue);
}

/* ---------- "Unlock Advanced Model" modal ---------- */
.adv-modal {
    display: none;
    position: fixed;
    z-index: 100000000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgb(0 0 0 / .4);
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.adv-modal.d-none { display: none; }
.adv-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    width: 500px;
    max-width: 100%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
.adv-modal-content #advClose { cursor: pointer; }
.upgrade-pro {
    display: inline-block;
    text-decoration: none;
    background: #1670a7 !important;
    color: #fff;
    padding: 9px 18px;
    font-size: 14px;
    border-radius: 8px;
    transition: filter .2s;
}
.upgrade-pro:hover { filter: brightness(1.06); color: #fff; }

/* ---------- Text-selection floating toolbar (Reply / Copy) ---------- */
.ams-sel-toolbar {
    position: absolute;
    z-index: 100000;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: #1f2330;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.ams-sel-toolbar::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2330;
}
.ams-sel-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: background .15s;
}
.ams-sel-btn:hover {
    background: rgba(255, 255, 255, .14);
}
.ams-sel-btn span {
    font-size: 13px;
    opacity: .9;
}

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .ams-example-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 767px) {
    .ams-head h1 { font-size: 28px; }
    .ams-card { padding: 14px; }

    /* tighter side padding on the wrapper so the tool gets more width on phones */
    .calculator-box {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }

    /* stack drop-zone above the question, but make the drop-zone a compact bar */
    .ams-card-top {
        flex-direction: column;
        gap: 12px;
    }
    .ams-dropzone {
        flex: 0 0 auto;
        width: 100%;
        height: 59px;                /* Figma: compact drop-bar on mobile */
        box-sizing: border-box;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        padding: 12px;
        min-height: auto;
        border-radius: 10px;
    }
    /* once a file is uploaded the preview needs to grow, so drop the fixed height */
    .ams-dropzone.has-file {
        flex-direction: column;
        height: auto;
    }
    .ams-dropzone-text { font-size: 12px; }
    .ams-drop-dd { display: none; }          /* hide "Drag & drop or" on mobile */
    .ams-qr-icon { display: none; }          /* QR-from-mobile makes no sense on a phone */
    .ams-divider { display: none; }

    /* smaller input + compact Clear button (less reserved space) */
    .ams-input {
        font-size: 14px;
        padding-right: 54px;
    }
    .ams-clear-btn {
        padding: 3px 9px;
        font-size: 12px;
    }
    /* keep the placeholder + Sample from sliding under the Clear button,
       and keep them on a single line (Sample stays inline, text truncates) */
    .ams-input-hint {
        padding-right: 58px;
        flex-wrap: nowrap;
    }
    .ams-input-hint > span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .ams-input-hint .ams-sample-btn {
        flex: 0 0 auto;
    }
    .ams-q-tag { font-size: 8px; }
    .ams-q-text { font-size: 15px; }
    .ams-queries-banner { font-size: 12px; }
    .ams-sol-title { font-size: 8.68px; }
    .ams-sol-icon { width: 18.53px; height: 18.53px; }
    .ams-ask-more { font-size: 12px; }
    .ams-feedback strong { font-size: 10px; }
    .ams-fb-group, .ams-fb { font-size: 10px; }

    /* keep the toolbar on one row, icon-only tabs (Tools keeps its label) */
    .ams-toolbar {
        flex-wrap: wrap;          /* let Solve drop to the next row if it doesn't fit (no overlap) */
        gap: 6px;
        row-gap: 10px;
        padding-top: 12px;
    }
    .ams-tools-left {
        gap: 6px;
        flex: 0 1 auto;          /* content width — leave room for Solve, don't push it to wrap early */
        flex-wrap: nowrap;
        min-width: 0;
    }
    /* uniform tab height (Tools box matches the icon buttons) */
    .ams-tool-btn {
        height: 31.63px;
        box-sizing: border-box;
        padding: 0 9px;
    }
    .ams-tb-label:not(.ams-tb-label--keep) { display: none; }
    #amsToolsLabel { font-size: 12px; }
    .ams-tool-btn .ams-caret { font-size: 8px; }
    .ams-examples-title { font-size: 12px; }
    .ams-solve-btn {
        width: 76.68px !important;
        height: 31.63px;
        padding: 6.32px 16.84px;
        border-radius: 5.02px;
        gap: 8.37px;
        flex: 0 0 auto;
        box-sizing: border-box;
        white-space: nowrap;
    }

    /* tooltips are hover-only — disable on touch (they overflow tiny screens) */
    .ams-tool-btn .ams-tip { display: none !important; }

    /* QR popover centered on small screens */
    .ams-qr { top: 70px; }

    /* examples become a horizontal swipeable slider */
    .ams-example-grid {
        display: flex;
        grid-template-columns: none;
        overflow-x: auto;
        gap: 12px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
        scrollbar-width: none;
    }
    .ams-example-grid::-webkit-scrollbar { display: none; }
    .ams-example-card {
        flex: 0 0 145.31px;
        width: 145.31px;
        height: 116.57px;
        min-height: auto;
        border-radius: 6.01px;
        padding: 6.01px 7.21px;
        gap: 6.01px;
        scroll-snap-align: start;
    }
    .ams-example-body {
        border-radius: 3px;
        padding: 9.01px 6.01px;
        gap: 6.01px;
        font-size: 8.41px;
        line-height: 1.4;
        overflow: hidden;
    }
    /* text example: clamp to a few lines and show … when it overflows */
    .ams-example-body:not(.center) {
        display: -webkit-box;
        -webkit-line-clamp: 5;
        line-clamp: 5;
        -webkit-box-orient: vertical;
        text-overflow: ellipsis;
    }
    .ams-example-body.center {
        padding: 9.01px 6.01px;
    }
    .ams-tag {
        padding: 2.4px 4.81px;
        border-radius: 3px;
        background: rgba(34, 119, 171, 0.20);   /* #2277AB @ 20% */
        color: #2277AB;
        font-size: 8px;
    }

    /* language dropdown: center it in the viewport so it never runs off-screen */
    .ams-menu--lang {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        width: 86vw;
        max-width: 340px;
        min-width: 0;
        max-height: 70vh;
    }
    .ams-menu--lang .ams-menu-list {
        max-height: 50vh;
    }
}
@media (max-width: 480px) {
    /* keep tabs + Solve on one row (Solve hugs on the right) */
    .ams-toolbar {
        flex-wrap: wrap;          /* Solve drops below only when it can't fit */
        gap: 6px;
        row-gap: 10px;
    }
    .ams-tools-left {
        gap: 4px;
        flex: 0 1 auto;
        min-width: 0;
        justify-content: flex-start;
        flex-wrap: nowrap;
    }
    .ams-tool-btn { padding: 0 8px; }
    .ams-solve-btn {
        flex: 0 0 auto;
        width: 76.68px;
        justify-content: center;
        padding: 6.32px 16.84px;
    }

    /* keep the language dropdown inside the viewport on narrow phones
       (centered via the <=767px rule; just tighten the width here) */
    .ams-menu--lang {
        width: 88vw;
        max-width: 320px;
    }
    .ams-menu--lang .ams-menu-item {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 13px;
    }
    .ams-menu-search input { font-size: 13px; }
}
