/* NMR Analysis tab (simulator). All classes are prefixed nt- so they cannot collide with the
   density-matrix views that share nmr.css. Colours come from the simulator theme tokens. */

.nt-host {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.nt-root {
    --nt-pad: 8px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    background: var(--background);
    color: var(--text-primary);
    font-size: 12px;
    overflow: hidden;
}

.nt-root.nt-fs {
    position: fixed;
    inset: 0;
    z-index: 10000;
    height: 100vh;
    padding: 6px;
}

body.nt-body-lock {
    overflow: hidden;
}

/* toolbar */
.nt-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 6px var(--nt-pad);
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
    flex-shrink: 0;
}

.nt-tool {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.nt-tool > span {
    font-weight: 600;
    color: var(--text-primary);
}

.nt-tool em {
    font-style: normal;
    color: var(--text-muted);
}

.nt-tool small {
    color: var(--text-muted);
    font-size: 10px;
}

.nt-tool--sample {
    min-width: 200px;
}

.nt-toolbar-spacer {
    flex: 1;
}

.nt-select,
.nt-num {
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 12px;
    font-family: inherit;
    min-height: 26px;
}

.nt-select:focus,
.nt-num:focus,
.nt-cell:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 0;
}

.nt-select--sm {
    max-width: 150px;
}

.nt-tool--sample .nt-select {
    flex: 1;
    max-width: 260px;
}

.nt-num {
    width: 60px;
    font-variant-numeric: tabular-nums;
}

.nt-num--w {
    width: 70px;
}

.nt-btn {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    min-height: 26px;
}

.nt-btn:hover,
.nt-btn:focus-visible {
    border-color: var(--primary-color);
}

.nt-btn--icon {
    padding: 2px 8px;
    font-size: 14px;
    line-height: 1;
}

/* body */
.nt-body {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    gap: var(--nt-pad);
    padding: var(--nt-pad);
    flex: 1;
    min-height: 0;
}

.nt-side {
    display: flex;
    flex-direction: column;
    gap: var(--nt-pad);
    min-height: 0;
    overflow: auto;
}

.nt-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 10px;
    flex-shrink: 0;
}

.nt-card-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.nt-card-sub {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
}

.nt-card-hint {
    margin-top: 6px;
    font-size: 10.5px;
    line-height: 1.4;
    color: var(--text-muted);
}

.nt-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    text-transform: none;
    letter-spacing: 0;
}

.nt-sample-name {
    font-weight: 700;
    font-size: 13px;
}

.nt-sample-formula {
    color: var(--text-secondary);
    font-size: 12px;
}

.nt-sample-desc {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.nt-sample-meta {
    margin-top: 5px;
    font-size: 10.5px;
    color: var(--text-muted);
}

.nt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.nt-table th,
.nt-table td {
    padding: 3px 4px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.nt-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 10px;
}

.nt-table tbody tr:last-child td {
    border-bottom: none;
}

.nt-table tr[data-q] {
    cursor: pointer;
}

.nt-table tr[data-q]:hover td {
    background: var(--surface-light);
}

.nt-row-dim td {
    opacity: 0.55;
}

.nt-row-flash td {
    background: color-mix(in srgb, var(--primary-color) 25%, transparent);
}

.nt-cell {
    width: 62px;
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 1px 4px;
    font: inherit;
    font-variant-numeric: tabular-nums;
}

.nt-cell:hover {
    border-color: var(--border-color);
}

.nt-mono {
    font-family: 'Consolas', 'Menlo', monospace;
    font-variant-numeric: tabular-nums;
}

.nt-neg {
    color: var(--nmr-negative, #ef4444);
}

.nt-muted {
    color: var(--text-muted);
    white-space: normal !important;
    font-size: 10.5px;
}

.nt-iso {
    display: inline-block;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    color: var(--iso, var(--primary-color));
    border: 1px solid var(--iso, var(--primary-color));
    line-height: 15px;
}

.nt-kv {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    padding: 2px 0;
    color: var(--text-secondary);
}

.nt-kv b {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* main */
.nt-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.nt-views {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.nt-views button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.nt-views button:hover {
    color: var(--text-primary);
    background: var(--surface-light);
}

.nt-views button[aria-selected="true"] {
    color: var(--text-primary);
    background: var(--surface);
    border-color: var(--border-color);
}

.nt-stage {
    flex: 1;
    min-height: 0;
    display: grid;
    gap: var(--nt-pad);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}

.nt-stage--dashboard {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.15fr) minmax(0, 1fr);
}

.nt-stage--dashboard .nt-panel[data-panel="spectrum"] {
    grid-column: 1;
    grid-row: 1;
}

.nt-stage--dashboard .nt-panel[data-panel="structure"] {
    grid-column: 2;
    grid-row: 1;
}

.nt-stage--dashboard .nt-panel[data-panel="pulses"] {
    grid-column: 1;
    grid-row: 2;
}

.nt-stage--dashboard .nt-panel[data-panel="fid"] {
    grid-column: 2;
    grid-row: 2;
}

.nt-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.nt-panel[hidden] {
    display: none !important;
}

.nt-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 28px;
}

.nt-panel-title {
    font-weight: 600;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nt-panel-title small {
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 6px;
}

.nt-panel-tools {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.nt-stage--dashboard .nt-panel-tools .nt-tbtn:not(.nt-expand):not([data-axis]),
.nt-stage--dashboard .nt-panel-tools .nt-seg {
    display: none;
}

.nt-tbtn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 2px 6px;
    font-size: 11px;
    cursor: pointer;
    line-height: 1.3;
}

.nt-tbtn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.nt-tbtn[aria-pressed="true"] {
    background: color-mix(in srgb, var(--primary-color) 22%, transparent);
    color: var(--text-primary);
    border-color: color-mix(in srgb, var(--primary-color) 55%, transparent);
}

.nt-seg {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.nt-seg button {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 2px 7px;
    font-size: 11px;
    cursor: pointer;
}

.nt-seg button.active {
    background: var(--primary-color);
    color: #fff;
}

.nt-panel-body {
    position: relative;
    flex: 1;
    min-height: 0;
    min-width: 0;
}

.nt-panel-body--scroll {
    overflow: auto;
}

.nt-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.nt-panel[data-panel="spectrum"] .nt-canvas {
    cursor: crosshair;
}

.nt-readout {
    position: absolute;
    right: 8px;
    bottom: 6px;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 10.5px;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    padding: 1px 6px;
    border-radius: 4px;
    pointer-events: none;
}

.nt-readout[hidden] {
    display: none;
}

.nt-pulse-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.nt-pulse-svg {
    display: block;
}

.nt-pe {
    cursor: pointer;
    outline: none;
}

.nt-pe:hover path,
.nt-pe:hover rect,
.nt-pe:focus-visible path,
.nt-pe:focus-visible rect {
    filter: brightness(1.2);
}

.nt-pe--inactive {
    opacity: 0.35;
}

/* tooltip */
.nt-tip {
    position: absolute;
    z-index: 20;
    max-width: 280px;
    background: var(--subpage-panel-solid, var(--surface));
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    font-size: 11px;
    line-height: 1.45;
    pointer-events: none;
}

.nt-tip[hidden] {
    display: none;
}

.nt-tip-title {
    font-weight: 700;
    font-size: 12px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nt-tip-title small {
    font-weight: 400;
    color: var(--text-muted);
}

.nt-tip-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-secondary);
}

.nt-tip-row b {
    color: var(--text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.nt-tip-sub {
    margin-top: 4px;
    font-weight: 600;
    color: var(--text-secondary);
}

.nt-tip-line {
    color: var(--text-secondary);
}

.nt-tip-env {
    margin-top: 5px;
    color: var(--text-muted);
    font-style: italic;
}

/* reference modal */
.nt-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.nt-modal {
    width: min(960px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.nt-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 14px;
}

.nt-modal-body {
    overflow: auto;
    padding: 12px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.nt-modal-body h4 {
    margin: 0 0 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.nt-table-scroll {
    max-height: 300px;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.nt-table--wide th,
.nt-table--wide td {
    padding: 4px 8px;
}

.nt-table--wide thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
}

.nt-list {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.nt-sample-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.nt-sample-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-family: inherit;
}

.nt-sample-card:hover:not(:disabled) {
    border-color: var(--primary-color);
}

.nt-sample-card:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.nt-sample-card b {
    font-size: 12px;
}

.nt-sample-card span {
    font-size: 11px;
    color: var(--text-secondary);
}

.nt-sample-card small {
    font-size: 10px;
    color: var(--text-muted);
}

/* responsive */
@media (max-width: 1100px) {
    .nt-body {
        grid-template-columns: 200px minmax(0, 1fr);
    }
}

@media (max-width: 820px) {
    .nt-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        overflow: auto;
    }

    .nt-side {
        flex-direction: row;
        flex-wrap: wrap;
        overflow: visible;
    }

    .nt-side .nt-card {
        flex: 1 1 200px;
    }

    .nt-stage--dashboard {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: repeat(4, minmax(180px, 1fr));
    }

    .nt-stage--dashboard .nt-panel[data-panel="spectrum"],
    .nt-stage--dashboard .nt-panel[data-panel="structure"],
    .nt-stage--dashboard .nt-panel[data-panel="pulses"],
    .nt-stage--dashboard .nt-panel[data-panel="fid"] {
        grid-column: 1;
        grid-row: auto;
    }

    .nt-main {
        min-height: 520px;
    }
}
