/* ─────────────────────────────────────────
   CSS VARIABLES — light theme tokens
   Legacy var names kept so JS-injected
   inline styles continue to work
───────────────────────────────────────── */
:root {
    /* ── Calculator display ── */
    --c-bg:          #f5f9f8;
    --c-surface:     #ffffff;
    --c-panel:       #f5f9f8;
    --c-raised:      #eaf4f1;
    --c-border:      rgba(78,179,154,0.15);
    --c-border-mid:  rgba(78,179,154,0.3);

    /* ── Semantic colours (used by button classes + JS) ── */
    --c-accent:      #0e2d27;       /* = sign dark text on green key */
    --c-accent-key:  #4eb39a;       /* = key background */
    --c-text:        #1a2e2b;
    --c-muted:       #5f7a74;
    --c-danger:      #dc2626;
    --c-danger-dim:  rgba(220,38,38,0.08);
    --c-info:        #2563eb;
    --c-info-dim:    rgba(37,99,235,0.08);
    --c-orange:      #d97706;
    --c-purple:      #7c3aed;
    --c-purple-dim:  rgba(124,58,237,0.08);

    /* ── Answer / result highlight ── */
    --c-answer:      #3a9b83;
}

/* ─────────────────────────────────────────
   PAGE WRAPPER
───────────────────────────────────────── */
.adv-page-wrap {
    background: var(--c-bg);
    padding: 2.5rem 1.5rem 5rem;
    min-height: 80vh;
}

/* ─────────────────────────────────────────
   TWO-COLUMN LAYOUT
───────────────────────────────────────── */
.adv-page-inner {
    max-width: 960px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 520px 1fr;
    gap: 2.5rem;
    align-items: start;
}

/* ─────────────────────────────────────────
   CALCULATOR WRAPPER
───────────────────────────────────────── */
.adv-calc-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* ── Chrome bar (dots + mode tabs) ── */
.adv-header {
    background: #fff;
    border: 1px solid var(--c-border);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.adv-dots span {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}
.adv-dots .dr { background: #ff5f57; }
.adv-dots .dy { background: #ffbd2e; }
.adv-dots .dg { background: #28ca41; }

.adv-mode-tabs {
    margin-left: auto;
    display: flex;
    background: #eaf4f1;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}
.adv-mode-tab {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #5f7a74;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px 14px;
    border-radius: 6px;
    transition: all 0.15s;
}
.adv-mode-tab.active {
    background: #4eb39a;
    color: #fff;
}
.adv-mode-tab:not(.active):hover {
    background: rgba(78,179,154,0.15);
    color: #3a9b83;
}

/* ── Display ── */
.adv-display {
    background: #fff;
    border-left: 1px solid var(--c-border);
    border-right: 1px solid var(--c-border);
    padding: 20px 22px 16px;
    position: relative;
    min-height: 120px;
    border-top: 1px solid rgba(78,179,154,0.08);
}
.adv-expr-line {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    font-weight: 400;
    color: #94aaa6;
    min-height: 20px;
    margin-bottom: 10px;
    word-break: break-all;
    letter-spacing: 0.02em;
    line-height: 1.5;
}
.adv-result-line {
    font-family: 'DM Mono', monospace;
    font-size: 2.4rem;
    font-weight: 500;
    color: #1a2e2b;
    text-align: right;
    letter-spacing: -0.03em;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s;
}
.adv-result-line.is-error  { color: #dc2626; font-size: 0.95rem; padding-top: 12px; white-space: normal; }
.adv-result-line.is-answer { color: #3a9b83; }

/* Memory badge */
.adv-mem-badge {
    position: absolute;
    top: 14px; right: 18px;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(124,58,237,0.08);
    color: #7c3aed;
    border: 1px solid rgba(124,58,237,0.22);
    display: none;
}
.adv-mem-badge.show { display: inline-block; }

/* ── Keypad ── */
.adv-keypad {
    background: #f5f9f8;
    border: 1px solid var(--c-border);
    border-top: none;
    border-radius: 0 0 14px 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.adv-key-grid { display: grid; gap: 6px; }
.adv-key-grid.g5 { grid-template-columns: repeat(5, 1fr); }
.adv-key-grid.g4 { grid-template-columns: repeat(4, 1fr); }

/* Scientific panel */
.sci-panel { display: none; }
.sci-panel.show { display: block; margin-bottom: 4px; }

/* ── Base key ── */
button.k {
    font-family: 'DM Mono', monospace;
    font-size: 0.95rem;
    font-weight: 400;
    color: #1a2e2b;
    background: #ffffff;
    border: 1px solid rgba(78,179,154,0.18);
    border-radius: 10px;
    padding: 13px 6px;
    cursor: pointer;
    transition: background 0.12s, transform 0.08s, border-color 0.12s, box-shadow 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    line-height: 1;
}
button.k:hover {
    background: #eaf4f1;
    border-color: rgba(78,179,154,0.35);
}
button.k:active { transform: scale(0.94); }

/* Operator keys */
button.k.op {
    color: #d97706;
    background: rgba(217,119,6,0.06);
    border-color: rgba(217,119,6,0.18);
    font-size: 1.1rem;
}
button.k.op:hover { background: rgba(217,119,6,0.12); border-color: rgba(217,119,6,0.3); }

/* Equals key */
button.k.eq {
    background: #4eb39a;
    color: #fff;
    font-size: 1.35rem;
    font-weight: 600;
    border: none;
    box-shadow: 0 2px 8px rgba(78,179,154,0.3);
}
button.k.eq:hover { background: #3a9b83; box-shadow: 0 4px 14px rgba(78,179,154,0.4); }

/* Clear keys */
button.k.clr {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: #dc2626;
    background: rgba(220,38,38,0.06);
    border-color: rgba(220,38,38,0.15);
}
button.k.clr:hover { background: rgba(220,38,38,0.12); }

/* Function keys */
button.k.fn {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: #2563eb;
    background: rgba(37,99,235,0.06);
    border-color: rgba(37,99,235,0.15);
}
button.k.fn:hover { background: rgba(37,99,235,0.12); }

/* Memory keys */
button.k.mem {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #7c3aed;
    background: rgba(124,58,237,0.06);
    border-color: rgba(124,58,237,0.15);
}
button.k.mem:hover { background: rgba(124,58,237,0.12); }

/* ── History panel ── */
.adv-history {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    margin-top: 10px;
    overflow: hidden;
}
.adv-hist-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, background 0.15s;
}
.adv-hist-head:hover { background: #f5f9f8; }
.adv-hist-head.open { border-color: var(--c-border); }
.adv-hist-head span {
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    font-weight: 600;
    color: #5f7a74;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.adv-hist-head .h-toggle { font-size: 0.8rem; color: #5f7a74; transition: transform 0.2s; }
.adv-hist-head.open .h-toggle { transform: rotate(180deg); }

.adv-hist-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.adv-hist-body.open { max-height: 220px; overflow-y: auto; }

.adv-hist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid rgba(78,179,154,0.08);
}
.adv-hist-item:last-child { border-bottom: none; }
.adv-hist-item:hover { background: #f5f9f8; }
.adv-hist-item .h-expr {
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    color: #94aaa6;
}
.adv-hist-item .h-val {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1a2e2b;
}
.adv-hist-empty {
    padding: 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    color: #94aaa6;
    text-align: center;
}

/* ─────────────────────────────────────────
   SEO SIDEBAR — matches site light style
───────────────────────────────────────── */
.adv-seo-col {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    padding-top: 4px;
}

.adv-seo-section { }

.adv-seo-section h1, .adv-seo-section h2.adv-seo-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #0e2d27;
    line-height: 1.3;
    margin-bottom: 0.6rem;
}
.adv-seo-section h2 {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #3a9b83;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}
.adv-seo-section p {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    color: #5f7a74;
    line-height: 1.8;
}
.adv-seo-section strong { color: #1a2e2b; }

.adv-feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 4px;
}
.adv-feature-list li {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    color: #5f7a74;
    line-height: 1.55;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.adv-feature-list li::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    min-width: 6px;
    border-radius: 50%;
    background: #4eb39a;
    margin-top: 6px;
}

.adv-faq-item {
    border-top: 1px solid rgba(78,179,154,0.12);
    padding-top: 14px;
    margin-top: 14px;
}
.adv-faq-item:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.adv-faq-item h3 {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    color: #1a2e2b;
    margin-bottom: 5px;
    line-height: 1.4;
}
.adv-faq-item p {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    color: #5f7a74;
    line-height: 1.75;
}
.adv-faq-item code {
    font-family: 'DM Mono', monospace;
    font-size: 0.78rem;
    color: #3a9b83;
    background: #e1f5ee;
    padding: 1px 5px;
    border-radius: 4px;
}

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */
@media (max-width: 820px) {
    .adv-page-inner { grid-template-columns: 1fr; max-width: 520px; }
    .adv-seo-col { padding-top: 1rem; }
}
@media (max-width: 560px) {
    .adv-page-wrap { padding: 1.5rem 1rem 4rem; }
    .adv-result-line { font-size: 1.9rem; }
    button.k { padding: 11px 4px; font-size: 0.85rem; border-radius: 9px; }
    button.k.op { font-size: 1rem; }
}
