/*
 * NexaMed Tools — standalone UI.
 * Uses the same visual language as the main NexaMed dashboard while keeping
 * selectors scoped under nx-* so the new feature cannot casually overwrite
 * the existing application.
 */

:root {
    --nx-bg: #080f0a;
    --nx-deep: #0b1410;
    --nx-card: #0f1a12;
    --nx-card-2: #101e15;
    --nx-border: #1a3022;
    --nx-accent: #5fd46b;
    --nx-accent-2: #2f9c49;
    --nx-gold: #f4c542;
    --nx-text: #e6f0e9;
    --nx-muted: #72907f;
    --nx-muted-2: #4d6758;
    --nx-danger: #ff4d6d;
    --nx-shadow: 0 20px 80px rgba(0, 0, 0, 0.38);
    --nx-radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    background: var(--nx-bg);
}

body.nx-tools-page {
    margin: 0;
    min-height: 100vh;
    color: var(--nx-text);
    background:
        radial-gradient(circle at 12% 0%, rgba(95, 212, 107, 0.075), transparent 32%),
        radial-gradient(circle at 88% 8%, rgba(48, 120, 67, 0.055), transparent 30%),
        var(--nx-bg);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}


.nx-skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2000;
    padding: 10px 13px;
    border-radius: 9px;
    color: #03150d;
    background: var(--nx-accent);
    transform: translateY(-160%);
    transition: transform 140ms ease;
    font-size: 0.8rem;
    font-weight: 900;
}

.nx-skip-link:focus {
    transform: translateY(0);
}

.nx-tools-page a {
    color: inherit;
    text-decoration: none;
}

.nx-tools-page button,
.nx-tools-page input,
.nx-tools-page select,
.nx-tools-page textarea {
    font: inherit;
}

.nx-tools-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid rgba(26, 48, 34, 0.9);
    background: rgba(8, 15, 10, 0.88);
    backdrop-filter: blur(18px);
}

.nx-tools-nav-inner {
    width: min(1240px, calc(100% - 32px));
    min-height: 68px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.nx-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    font-size: 1.02rem;
    font-weight: 900;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.nx-brand-mark {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--nx-accent);
    box-shadow: 0 0 18px rgba(0, 201, 106, 0.65);
}

.nx-nav-tools {
    display: flex;
    align-items: center;
    gap: 9px;
}

.nx-nav-link {
    min-height: 38px;
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--nx-muted);
    transition: 160ms ease;
}

.nx-nav-link:hover,
.nx-nav-link:focus-visible {
    color: var(--nx-text);
    border-color: var(--nx-border);
    background: var(--nx-card);
    outline: none;
}

.nx-nav-link.is-primary {
    color: #03150d;
    background: var(--nx-accent);
    font-weight: 800;
}

.nx-tools-main {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 36px 0 72px;
}

.nx-tools-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
    gap: 24px;
    align-items: stretch;
}

.nx-tools-hero-copy,
.nx-tools-hero-stats {
    border: 1px solid var(--nx-border);
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(15, 26, 18, 0.96), rgba(10, 20, 14, 0.92));
    box-shadow: var(--nx-shadow);
}

.nx-tools-hero-copy {
    padding: 34px;
}

.nx-kicker {
    margin: 0 0 12px;
    color: var(--nx-accent);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.nx-tools-hero h1 {
    max-width: 780px;
    margin: 0;
    font-size: clamp(2.7rem, 7vw, 5.6rem);
    line-height: 0.9;
    letter-spacing: -0.06em;
}

.nx-tools-hero h1 span {
    color: var(--nx-accent);
}

.nx-tools-hero-copy > p {
    max-width: 720px;
    margin: 18px 0 0;
    color: var(--nx-muted);
    font-size: 1.04rem;
    line-height: 1.75;
}

.nx-tools-hero-stats {
    padding: 18px;
    display: grid;
    align-content: center;
    gap: 10px;
}

.nx-stat {
    padding: 15px;
    border: 1px solid var(--nx-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.018);
}

.nx-stat-value {
    color: var(--nx-text);
    font-size: 1.8rem;
    font-weight: 900;
}

.nx-stat-label {
    margin-top: 4px;
    color: var(--nx-muted);
    font-size: 0.83rem;
}

.nx-tools-control-panel {
    position: sticky;
    top: 80px;
    z-index: 30;
    margin-top: 18px;
    padding: 16px;
    border: 1px solid var(--nx-border);
    border-radius: 18px;
    background: rgba(11, 20, 16, 0.92);
    backdrop-filter: blur(18px);
}

.nx-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nx-search-wrap {
    position: relative;
    flex: 1;
}

.nx-search-icon {
    position: absolute;
    top: 50%;
    left: 16px;
    color: var(--nx-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.nx-tools-search {
    width: 100%;
    min-height: 48px;
    padding: 0 48px;
    border: 1px solid var(--nx-border);
    border-radius: 14px;
    outline: none;
    color: var(--nx-text);
    background: var(--nx-card);
}

.nx-tools-search:focus {
    border-color: rgba(0, 201, 106, 0.62);
    box-shadow: 0 0 0 3px rgba(0, 201, 106, 0.09);
}

.nx-search-clear {
    min-width: 42px;
    min-height: 42px;
    border: 0;
    border-radius: 12px;
    color: var(--nx-muted);
    background: transparent;
    cursor: pointer;
}

.nx-search-clear:hover {
    color: var(--nx-text);
    background: rgba(255, 255, 255, 0.04);
}

.nx-filter-line {
    margin-top: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.nx-category-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 2px;
}

.nx-category-filter {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--nx-border);
    border-radius: 999px;
    color: var(--nx-muted);
    background: transparent;
    cursor: pointer;
    transition: 150ms ease;
}

.nx-category-filter:hover,
.nx-category-filter.is-active {
    color: var(--nx-text);
    border-color: rgba(0, 201, 106, 0.42);
    background: rgba(0, 201, 106, 0.09);
}

.nx-favorite-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--nx-muted);
    font-size: 0.87rem;
    white-space: nowrap;
}

.nx-favorite-toggle input {
    accent-color: var(--nx-accent);
}

.nx-results-summary {
    min-height: 20px;
    margin: 22px 2px 0;
    color: var(--nx-muted);
    font-size: 0.88rem;
}

.nx-tools-category-jumps {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 28px 0 34px;
}

.nx-category-jump {
    padding: 9px 13px;
    border: 1px solid var(--nx-border);
    border-radius: 11px;
    color: var(--nx-muted);
    background: var(--nx-card);
    cursor: pointer;
}

.nx-category-jump:hover {
    color: var(--nx-text);
    border-color: rgba(0, 201, 106, 0.35);
}

.nx-tools-recent {
    margin-top: 26px;
}

.nx-tools-recent h2 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.nx-recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nx-recent-chip {
    min-height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--nx-border);
    border-radius: 999px;
    color: var(--nx-muted);
    background: rgba(15, 26, 18, 0.72);
    cursor: pointer;
}

.nx-recent-chip:hover {
    color: var(--nx-text);
    border-color: rgba(0, 201, 106, 0.35);
}

.nx-recent-chip-icon {
    color: var(--nx-accent);
}

.nx-tools-category-section {
    scroll-margin-top: 150px;
    margin-top: 48px;
}

.nx-tools-category-heading {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 15px;
    margin-bottom: 16px;
}

.nx-tools-category-kicker {
    grid-column: 1 / -1;
    color: var(--nx-muted-2);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.18em;
}

.nx-tools-category-heading h2 {
    margin: 0;
    font-size: clamp(1.55rem, 3vw, 2.2rem);
    letter-spacing: -0.03em;
}

.nx-tools-category-count {
    color: var(--nx-muted);
    font-size: 0.85rem;
}

.nx-tools-category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.nx-tool-card-shell {
    min-height: 222px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius);
    background: linear-gradient(145deg, rgba(15, 26, 18, 0.98), rgba(12, 22, 16, 0.95));
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.nx-tool-card-shell:hover {
    transform: translateY(-3px);
    border-color: rgba(0, 201, 106, 0.3);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

.nx-tool-card-top,
.nx-tool-card-footer,
.nx-button-row,
.nx-search-row,
.nx-inline-controls {
    display: flex;
    align-items: center;
}

.nx-tool-card-top {
    justify-content: space-between;
    gap: 12px;
}

.nx-tool-card-icon,
.nx-tool-title-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 201, 106, 0.2);
    border-radius: 12px;
    color: var(--nx-accent);
    background: rgba(0, 201, 106, 0.08);
    font-weight: 900;
}

.nx-tool-card-category {
    color: var(--nx-muted-2);
    font-size: 0.67rem;
    font-weight: 900;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.nx-tool-card-title {
    margin: 18px 0 8px;
    font-size: 1.08rem;
    letter-spacing: -0.015em;
}

.nx-tool-card-description {
    margin: 0;
    color: var(--nx-muted);
    font-size: 0.9rem;
    line-height: 1.65;
}

.nx-tool-card-tags {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.nx-tool-tag {
    padding: 5px 8px;
    border-radius: 7px;
    color: var(--nx-muted-2);
    background: rgba(255, 255, 255, 0.028);
    font-size: 0.68rem;
}

.nx-tool-card-footer {
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 22px;
}

.nx-tool-open-button,
.nx-primary-button,
.nx-secondary-button {
    min-height: 42px;
    padding: 0 14px;
    border-radius: 11px;
    cursor: pointer;
    transition: 150ms ease;
}

.nx-tool-open-button,
.nx-primary-button {
    border: 1px solid rgba(0, 201, 106, 0.35);
    color: #03150d;
    background: var(--nx-accent);
    font-weight: 800;
}

.nx-tool-open-button:hover,
.nx-primary-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

.nx-secondary-button {
    border: 1px solid var(--nx-border);
    color: var(--nx-text);
    background: var(--nx-card-2);
}

.nx-secondary-button:hover:not(:disabled) {
    border-color: rgba(0, 201, 106, 0.34);
    background: rgba(0, 201, 106, 0.07);
}

.nx-primary-button:disabled,
.nx-secondary-button:disabled,
.nx-tool-open-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nx-card-favorite-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--nx-border);
    border-radius: 11px;
    color: var(--nx-gold);
    background: transparent;
    cursor: pointer;
    font-size: 1.2rem;
}

.nx-card-favorite-button:hover {
    background: rgba(244, 197, 66, 0.08);
}

.nx-tools-empty-state {
    margin-top: 60px;
    padding: 70px 20px;
    text-align: center;
    border: 1px dashed var(--nx-border);
    border-radius: 20px;
}

.nx-empty-icon {
    font-size: 3rem;
    color: var(--nx-accent);
}

.nx-tools-empty-state h2 {
    margin: 15px 0 7px;
}

.nx-tools-empty-state p {
    margin: 0;
    color: var(--nx-muted);
}

.nx-tools-footer {
    border-top: 1px solid var(--nx-border);
    padding: 28px 0;
    color: var(--nx-muted);
}

.nx-tools-footer-inner {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.nx-tools-footer a:hover {
    color: var(--nx-text);
}


/* Study-platform hub enhancements ------------------------------------------ */
.nx-hero-points {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nx-hero-points span {
    padding: 7px 10px;
    border: 1px solid var(--nx-border);
    border-radius: 999px;
    color: var(--nx-muted);
    background: rgba(255, 255, 255, 0.018);
    font-size: 0.72rem;
    font-weight: 700;
}

.nx-stat-primary {
    border-color: rgba(95, 212, 107, 0.25);
    background: rgba(95, 212, 107, 0.055);
}

.nx-subsection-heading {
    margin-bottom: 10px;
}

.nx-section-kicker {
    margin: 0 0 6px;
    color: var(--nx-accent);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.nx-subsection-heading h2,
.nx-tool-intro h2 {
    margin: 0;
    letter-spacing: -0.025em;
}

.nx-tool-intro {
    margin-top: 44px;
    padding: 20px 0 4px;
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 28px;
    align-items: end;
    border-top: 1px solid rgba(26, 48, 34, 0.55);
}

.nx-tool-intro > p {
    margin: 0;
    color: var(--nx-muted);
    line-height: 1.7;
    font-size: 0.88rem;
}

.nx-tools-category-heading {
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(26, 48, 34, 0.35);
}

.nx-tools-category-kicker {
    color: var(--nx-accent);
}

.nx-tools-category-heading h2 {
    font-family: "DM Sans", Inter, system-ui, sans-serif;
    font-weight: 700;
}

.nx-tool-card-shell {
    border-radius: 15px;
    background: rgba(15, 26, 18, 0.78);
}

.nx-tool-card-shell:hover {
    transform: translateY(-2px);
    border-color: rgba(95, 212, 107, 0.28);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.nx-tool-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
}

.nx-tool-open-button {
    min-width: 104px;
}

.nx-tools-footer-inner {
    align-items: center;
}

.nx-tools-footer-inner > div {
    display: grid;
    gap: 4px;
}

.nx-tools-footer-inner strong {
    color: var(--nx-text);
    font-size: 0.9rem;
}

.nx-tools-footer-inner > div > span {
    font-size: 0.78rem;
}

.nx-tools-footer-inner nav {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.78rem;
}

/* Tool dialog -------------------------------------------------------------- */

.nx-tool-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(3, 8, 5, 0.78);
    backdrop-filter: blur(10px);
}

.nx-tool-dialog {
    width: min(1120px, 100%);
    max-height: min(900px, calc(100vh - 52px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(49, 85, 60, 0.9);
    border-radius: 22px;
    background: var(--nx-deep);
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.55);
}

.nx-tool-dialog-header {
    min-height: 72px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--nx-border);
    background: rgba(15, 26, 18, 0.95);
}

.nx-dialog-action {
    min-height: 40px;
    border: 1px solid var(--nx-border);
    border-radius: 10px;
    color: var(--nx-muted);
    background: transparent;
    cursor: pointer;
}

.nx-back-button {
    padding: 0 12px;
}

.nx-close-button,
.nx-favorite-button {
    width: 40px;
    padding: 0;
    font-size: 1.2rem;
}

.nx-close-button {
    font-size: 1.6rem;
}

.nx-dialog-action:hover,
.nx-dialog-action:focus-visible {
    color: var(--nx-text);
    border-color: rgba(0, 201, 106, 0.32);
    outline: none;
}

.nx-tool-title-wrap {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 11px;
}

.nx-tool-dialog-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
    font-weight: 900;
}

.nx-tool-dialog-category {
    grid-column: 2;
    margin-top: -5px;
    color: var(--nx-muted-2);
    font-size: 0.67rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.nx-tool-dialog-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    transform: translateX(-8px);
}

.nx-tool-toolbar {
    min-height: 52px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    border-bottom: 1px solid rgba(26, 48, 34, 0.75);
}

.nx-toolbar-button {
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid var(--nx-border);
    border-radius: 9px;
    color: var(--nx-muted);
    background: transparent;
    cursor: pointer;
}

.nx-toolbar-button:hover:not(:disabled) {
    color: var(--nx-text);
    background: rgba(255, 255, 255, 0.03);
}

.nx-tool-status {
    min-height: 34px;
    margin-right: auto;
    padding: 0 4px;
    display: flex;
    align-items: center;
    color: var(--nx-muted);
    font-size: 0.8rem;
}

.nx-tool-status[data-tone="success"] {
    color: var(--nx-accent);
}

.nx-tool-status[data-tone="error"] {
    color: var(--nx-danger);
}

.nx-tool-dialog-body {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
}

.nx-tool-dialog-content {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 22px;
}

.nx-tool-card {
    padding: 20px;
    border: 1px solid var(--nx-border);
    border-radius: 17px;
    background: rgba(15, 26, 18, 0.86);
}

.nx-tool-card + .nx-tool-card {
    margin-top: 15px;
}

.nx-card-title,
.nx-result-heading,
.nx-section-label,
.nx-help-block {
    font-weight: 900;
}

.nx-card-title {
    margin-bottom: 15px;
    font-size: 1rem;
}

.nx-stack {
    display: grid;
    gap: 14px;
}

.nx-inline-fields,
.nx-two-column-fields,
.nx-three-column-fields,
.nx-four-column-fields,
.nx-vector-grid,
.nx-form-dynamic-grid {
    display: grid;
    gap: 12px;
}

.nx-inline-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.nx-two-column-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.nx-three-column-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.nx-four-column-fields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.nx-form-dynamic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.nx-field {
    min-width: 0;
}

.nx-label {
    display: block;
    margin-bottom: 7px;
    color: var(--nx-muted);
    font-size: 0.8rem;
    font-weight: 800;
}

.nx-input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--nx-border);
    border-radius: 10px;
    outline: none;
    color: var(--nx-text);
    background: #0b160f;
}

.nx-textarea {
    min-height: 150px;
    padding: 12px;
    resize: vertical;
}

.nx-input:focus {
    border-color: rgba(0, 201, 106, 0.52);
    box-shadow: 0 0 0 3px rgba(0, 201, 106, 0.07);
}

.nx-input:disabled {
    opacity: 0.46;
    cursor: not-allowed;
}

.nx-field-hint,
.nx-help {
    color: var(--nx-muted-2);
    font-size: 0.76rem;
    line-height: 1.55;
}

.nx-help {
    margin: 0;
}

.nx-notice {
    padding: 12px 14px;
    border: 1px solid var(--nx-border);
    border-radius: 11px;
    color: var(--nx-muted);
    background: rgba(255, 255, 255, 0.018);
    font-size: 0.8rem;
    line-height: 1.6;
}

.nx-notice-warn {
    border-color: rgba(244, 197, 66, 0.24);
    color: #bdac72;
}

.nx-btn {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--nx-border);
    border-radius: 10px;
    color: var(--nx-text);
    background: var(--nx-card-2);
    cursor: pointer;
}

.nx-btn:hover:not(:disabled) {
    border-color: rgba(0, 201, 106, 0.32);
}

.nx-result-body {
    display: grid;
    gap: 15px;
}

.nx-result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.nx-result-metric {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--nx-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.018);
}

.nx-result-label {
    color: var(--nx-muted-2);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nx-result-value {
    margin-top: 7px;
    overflow-wrap: anywhere;
    color: var(--nx-text);
    font-size: 1.04rem;
    font-weight: 900;
}

.nx-result-unit {
    margin-top: 2px;
    color: var(--nx-muted);
    font-size: 0.74rem;
}

.nx-copyable-result {
    display: grid;
    gap: 4px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(0, 201, 106, 0.055);
}

.nx-copy-line {
    color: var(--nx-muted);
    font-size: 0.78rem;
    line-height: 1.55;
}

.nx-formula {
    padding: 12px 18px;
    border-top: 1px solid var(--nx-border);
    border-bottom: 1px solid var(--nx-border);
    color: var(--nx-muted);
    background: rgba(255, 255, 255, 0.01);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.76rem;
}

.nx-tool-error {
    padding: 10px 18px;
    color: var(--nx-danger);
    background: rgba(255, 77, 109, 0.055);
    font-size: 0.8rem;
}

.nx-tool-dialog-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--nx-border);
    color: var(--nx-muted-2);
    font-size: 0.74rem;
}

.nx-history-pane {
    min-height: 0;
    overflow: auto;
    border-left: 1px solid var(--nx-border);
    background: rgba(255, 255, 255, 0.012);
}

.nx-history-heading {
    padding: 18px 15px 12px;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nx-history-list {
    display: grid;
    gap: 7px;
    padding: 0 10px 10px;
}

.nx-history-item {
    width: 100%;
    padding: 10px;
    display: grid;
    gap: 3px;
    text-align: left;
    border: 1px solid var(--nx-border);
    border-radius: 10px;
    color: var(--nx-muted);
    background: rgba(15, 26, 18, 0.68);
    cursor: pointer;
}

.nx-history-input {
    color: var(--nx-text);
    font-size: 0.76rem;
}

.nx-history-result {
    color: var(--nx-accent);
    font-size: 0.77rem;
    font-weight: 800;
}

.nx-history-time {
    color: var(--nx-muted-2);
    font-size: 0.65rem;
}

.nx-history-empty {
    padding: 16px 8px;
    color: var(--nx-muted-2);
    font-size: 0.76rem;
}

.nx-history-clear {
    width: calc(100% - 20px);
    margin: 0 10px 12px;
    min-height: 36px;
    border: 1px solid rgba(255, 77, 109, 0.16);
    border-radius: 9px;
    color: var(--nx-muted);
    background: transparent;
    cursor: pointer;
}

.nx-history-clear:hover {
    color: var(--nx-danger);
    background: rgba(255, 77, 109, 0.045);
}

/* Scientific calculator ---------------------------------------------------- */

.nx-two-column-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.65fr);
    gap: 14px;
}

.nx-calc-display {
    padding: 16px;
    border: 1px solid var(--nx-border);
    border-radius: 13px;
    background: #07110b;
}

.nx-calc-expression-line {
    min-height: 22px;
    overflow-wrap: anywhere;
    color: var(--nx-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
}

.nx-calc-result-line {
    min-height: 44px;
    margin-top: 8px;
    overflow-wrap: anywhere;
    color: var(--nx-accent);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 2rem;
    font-weight: 900;
}

.nx-scientific-keypad {
    display: grid;
    gap: 7px;
}

.nx-calc-key-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
}

.nx-calc-key {
    min-height: 44px;
    border: 1px solid var(--nx-border);
    border-radius: 10px;
    color: var(--nx-text);
    background: #0b160f;
    cursor: pointer;
    font-weight: 800;
}

.nx-calc-key:hover {
    border-color: rgba(0, 201, 106, 0.35);
    background: rgba(0, 201, 106, 0.055);
}

.nx-calc-key.is-equals {
    color: #03150d;
    border-color: rgba(0, 201, 106, 0.32);
    background: var(--nx-accent);
}

.nx-code-line {
    display: block;
    padding: 7px 9px;
    border: 1px solid var(--nx-border);
    border-radius: 8px;
    color: var(--nx-accent);
    background: #07110b;
    font-size: 0.75rem;
}

.nx-proportion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto 1fr 1fr;
    align-items: end;
    gap: 10px;
}

.nx-equation-symbol {
    padding-bottom: 12px;
    color: var(--nx-muted);
    font-weight: 900;
}

.nx-section-label {
    color: var(--nx-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.nx-dynamic-rows {
    display: grid;
    gap: 10px;
}

.nx-dynamic-row {
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(110px, 0.7fr) minmax(110px, 0.7fr) auto;
    gap: 9px;
    align-items: end;
    border: 1px solid var(--nx-border);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.015);
}

.nx-remove-row {
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--nx-danger);
    border-color: rgba(255, 77, 109, 0.16);
}

.nx-timer-panel {
    display: grid;
    gap: 18px;
}

.nx-big-timer {
    text-align: center;
    color: var(--nx-accent);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(3.2rem, 12vw, 6rem);
    font-weight: 900;
    letter-spacing: -0.05em;
}

.nx-timer-phase,
.nx-timer-cycle,
.nx-timer-status {
    text-align: center;
}

.nx-timer-phase {
    color: var(--nx-gold);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.18em;
}

.nx-timer-cycle,
.nx-timer-status {
    color: var(--nx-muted);
    font-size: 0.8rem;
}

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

@media (max-width: 980px) {
    .nx-tool-intro { grid-template-columns: 1fr; align-items: start; }
    .nx-tools-hero,
    .nx-two-column-layout {
        grid-template-columns: 1fr;
    }

    .nx-tools-category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .nx-tool-dialog-body {
        grid-template-columns: 1fr;
    }

    .nx-history-pane {
        display: none;
    }
}

@media (max-width: 720px) {
    .nx-tools-main {
        width: min(100% - 20px, 1240px);
        padding-top: 24px;
    }

    .nx-tools-nav-inner,
    .nx-tools-footer-inner {
        width: calc(100% - 20px);
    }

    .nx-nav-tools .nx-nav-link:not(.is-primary) {
        display: none;
    }

    .nx-tools-hero-copy {
        padding: 28px 22px;
    }

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

    .nx-tools-control-panel {
        top: 65px;
    }

    .nx-filter-line {
        align-items: flex-start;
        flex-direction: column;
    }

    .nx-tools-category-grid {
        grid-template-columns: 1fr;
    }

    .nx-tool-overlay {
        padding: 0;
    }

    .nx-tool-dialog {
        width: 100%;
        max-height: 100vh;
        min-height: 100vh;
        border-radius: 0;
    }

    .nx-tool-dialog-header {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .nx-back-button {
        width: 40px;
        padding: 0;
        overflow: hidden;
        text-indent: -999px;
        position: relative;
    }

    .nx-back-button::after {
        content: '←';
        position: absolute;
        inset: 0;
        display: grid;
        place-items: center;
        text-indent: 0;
    }

    .nx-tool-dialog-content {
        padding: 14px;
    }

    .nx-two-column-fields,
    .nx-three-column-fields,
    .nx-four-column-fields,
    .nx-form-dynamic-grid,
    .nx-inline-fields,
    .nx-vector-grid {
        grid-template-columns: 1fr;
    }

    .nx-dynamic-row {
        grid-template-columns: 1fr;
    }

    .nx-remove-row {
        width: 100%;
    }

    .nx-result-grid {
        grid-template-columns: 1fr;
    }

    .nx-proportion-grid {
        grid-template-columns: 1fr 1fr;
    }

    .nx-equation-symbol {
        display: none;
    }

    .nx-tools-footer-inner {
        flex-direction: column;
    }
}

/* ========================================================================== */
/* NexaMed Tools — results workspace refinement                              */
/* ========================================================================== */

/* The calculator window is intentionally divided into two clear work areas:
   inputs/work on the left, answer/output on the right. This keeps results from
   becoming a loose block below the form and gives every tool the same visual
   rhythm regardless of how much content its calculator produces. */
.nx-tool-dialog-body {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 370px);
    overflow: hidden;
    background: #09130d;
}

.nx-tool-dialog-content {
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    scrollbar-gutter: stable;
}

.nx-tool-dialog-content > .nx-tool-card:first-child {
    margin-top: 0;
}

.nx-tool-side-pane {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding: 18px;
    border-left: 1px solid var(--nx-border);
    background:
        linear-gradient(180deg, rgba(15, 26, 18, 0.96), rgba(9, 18, 13, 0.98));
}

.nx-result-pane,
.nx-history-pane {
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 18px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--nx-border);
    border-radius: 17px;
    background: rgba(11, 22, 15, 0.88);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.018);
    scrollbar-gutter: stable;
}

.nx-result-pane[hidden],
.nx-history-pane[hidden] {
    display: none !important;
}

.nx-side-pane-header {
    display: grid;
    gap: 4px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(26, 48, 34, 0.72);
}

.nx-side-pane-kicker {
    color: var(--nx-accent);
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.nx-side-pane-title {
    margin: 0;
    color: var(--nx-text);
    font-size: 1.2rem;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.nx-result-placeholder {
    padding: 18px;
    border: 1px dashed rgba(95, 212, 107, 0.20);
    border-radius: 13px;
    color: var(--nx-muted);
    background: rgba(95, 212, 107, 0.025);
    font-size: 0.82rem;
    line-height: 1.6;
}

.nx-tool-result {
    min-width: 0;
    margin-top: 0;
}

.nx-result-body {
    min-width: 0;
    display: grid;
    gap: 14px;
}

.nx-result-heading {
    color: var(--nx-text);
    font-size: 1.05rem;
    line-height: 1.3;
}

.nx-result-grid {
    grid-template-columns: 1fr;
    gap: 9px;
}

.nx-result-metric {
    padding: 14px 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.017);
}

.nx-result-label {
    line-height: 1.35;
}

.nx-result-value {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: clamp(1.02rem, 2vw, 1.25rem);
    line-height: 1.2;
}

.nx-result-unit {
    line-height: 1.35;
}

.nx-copyable-result {
    margin-top: 2px;
    padding: 13px;
    border: 1px solid rgba(95, 212, 107, 0.12);
    border-radius: 11px;
}

.nx-copy-line {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* The shell uses nx-tool-formula while the reusable formula() helper uses
   nx-formula. Keep both visually identical. */
.nx-tool-formula,
.nx-formula {
    margin-top: 14px;
    padding: 13px 14px;
    border: 1px solid var(--nx-border);
    border-radius: 11px;
    color: var(--nx-muted);
    background: rgba(255, 255, 255, 0.015);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.nx-tool-error {
    margin-top: 12px;
    padding: 12px 13px;
    border: 1px solid rgba(255, 77, 109, 0.18);
    border-radius: 11px;
    color: #ff8da1;
    background: rgba(255, 77, 109, 0.055);
    font-size: 0.8rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.nx-tool-dialog-footer {
    min-height: 50px;
    display: flex;
    align-items: center;
}

.nx-tool-title-wrap {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.nx-tool-title-meta {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.nx-tool-dialog-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--nx-text);
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.2;
}

.nx-tool-dialog-category {
    margin: 0;
    color: var(--nx-muted-2);
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    line-height: 1.2;
    text-transform: uppercase;
}

.nx-tool-toolbar {
    flex-wrap: wrap;
}

.nx-toolbar-button.is-active {
    color: var(--nx-text);
    border-color: rgba(95, 212, 107, 0.32);
    background: rgba(95, 212, 107, 0.08);
}

.nx-history-pane {
    border-left: 0;
}

.nx-history-heading {
    display: none;
}

.nx-history-list {
    gap: 8px;
    padding: 0 0 10px;
}

.nx-history-item {
    padding: 12px;
    border-radius: 11px;
}

.nx-history-input,
.nx-history-result,
.nx-history-time {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.nx-history-clear {
    width: 100%;
    margin: 0;
}

/* Keep common multi-column input groups from becoming cramped in the work
   area. They collapse earlier than the result pane so the calculator remains
   readable on tablet-sized viewports. */
@media (max-width: 1080px) {
    .nx-tool-dialog-body {
        grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
    }
}

@media (max-width: 900px) {
    .nx-tool-dialog {
        max-height: calc(100vh - 28px);
    }

    .nx-tool-dialog-body {
        grid-template-columns: 1fr;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .nx-tool-dialog-content {
        overflow: visible;
        padding: 18px;
    }

    .nx-tool-side-pane {
        min-height: 360px;
        border-left: 0;
        border-top: 1px solid var(--nx-border);
        padding: 16px;
    }

    .nx-result-pane,
    .nx-history-pane {
        height: auto;
        max-height: 520px;
    }
}

@media (max-width: 720px) {
    .nx-tool-dialog-body {
        overflow-y: auto;
    }

    .nx-tool-side-pane {
        min-height: 0;
    }

    .nx-result-pane,
    .nx-history-pane {
        max-height: none;
    }

    .nx-tool-dialog-footer {
        min-height: 0;
        padding-top: 11px;
        padding-bottom: 11px;
    }
}

/* Keep the output/history panel available on tablets. The legacy responsive
   rule hid history unconditionally; the tool shell now controls visibility via
   the hidden attribute, so only the explicit hidden state should collapse it. */
@media (max-width: 980px) {
    .nx-history-pane:not([hidden]) {
        display: block;
    }
}


/* ===== Micro-polish: tool header alignment ===== */

/* Keep the category label on the same visual line as the tool title,
   with a small amount of breathing room and a slightly lowered baseline. */
.nx-tool-title-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.nx-tool-dialog-title {
    flex: 0 1 auto;
    min-width: 0;
}

.nx-tool-dialog-category {
    flex: 0 0 auto;
    margin: 0;
    white-space: nowrap;
    transform: translateY(2px);
}

/* Give the close/favorite controls just a little more air from the dialog
   edge without changing the rest of the header geometry. */

.nx-tool-dialog-header {
    padding-right: 28px;
}

@media (max-width: 560px) {
    .nx-tool-title-meta {
        align-items: flex-start;
        gap: 2px;
        flex-direction: column;
    }

    .nx-tool-dialog-category {
        transform: none;
    }
}

/* Better-positioned dropdown chevrons across the entire Tools suite */
.nx-tools-page select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 42px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2385a18e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 14px 14px;
}
