/* Investment Thesis section + dialog (#521, redesigned per design 5A "Debate").
   Apple-minimal: no borders, no shadows — the 2px bull/bear accent top-rules
   are the design's one deliberate exception. */

/* --- Section --- */

.ij-thesis-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 4px 0 8px;
}

/* --- Judgment strip: verdict chip · $target · review chip --- */

.ij-thesis-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.ij-thesis-strip-spacer {
    flex: 1;
}

.ij-thesis-target {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
}

.ij-thesis-target-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.ij-thesis-target-caption {
    font-size: 12.5px;
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-verdict-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ij-thesis-verdict-chip--green {
    background: color-mix(in srgb, var(--mud-palette-success) 14%, transparent);
    color: var(--mud-palette-success);
}

.ij-thesis-verdict-chip--neutral {
    background: color-mix(in srgb, var(--mud-palette-text-secondary) 14%, transparent);
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-verdict-chip--red {
    background: color-mix(in srgb, var(--mud-palette-error) 14%, transparent);
    color: var(--mud-palette-error);
}

.ij-thesis-review-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 980px;
    font-size: 12px;
    font-weight: 600;
}

.ij-thesis-review-chip--neutral {
    color: var(--mud-palette-text-secondary);
    background: color-mix(in srgb, var(--mud-palette-text-secondary) 12%, transparent);
}

.ij-thesis-review-chip--warning {
    color: var(--mud-palette-warning);
    background: color-mix(in srgb, var(--mud-palette-warning) 15%, transparent);
}

.ij-thesis-review-chip--overdue {
    color: var(--mud-palette-error);
    background: color-mix(in srgb, var(--mud-palette-error) 14%, transparent);
}

.ij-thesis-review-icon {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

/* --- Price → target rail --- */

.ij-thesis-rail {
    margin: 0 0 22px;
}

.ij-thesis-rail-track {
    position: relative;
    height: 5px;
    border-radius: 980px;
    background: color-mix(in srgb, var(--mud-palette-text-primary) 8%, transparent);
}

.ij-thesis-rail-span {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    border-radius: 980px;
    background: color-mix(in srgb, var(--mud-palette-success) 35%, transparent);
}

.ij-thesis-rail--down .ij-thesis-rail-span {
    background: color-mix(in srgb, var(--mud-palette-error) 35%, transparent);
}

.ij-thesis-rail-tick {
    position: absolute;
    top: -3.5px;
    width: 3px;
    height: 12px;
    border-radius: 980px;
    background: var(--mud-palette-success);
}

.ij-thesis-rail--down .ij-thesis-rail-tick {
    background: var(--mud-palette-error);
    transform: translateX(-50%);
}

.ij-thesis-rail-dot {
    position: absolute;
    top: -4.5px;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--mud-palette-background);
    border: 2.5px solid var(--mud-palette-text-secondary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.ij-thesis-rail-labels {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.ij-thesis-rail-today {
    font-size: 11.5px;
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-rail-upside {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--mud-palette-success);
}

.ij-thesis-rail--down .ij-thesis-rail-upside {
    color: var(--mud-palette-error);
}

/* --- Bull vs bear, facing columns --- */

.ij-thesis-debate {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.ij-thesis-case {
    /* Grid items default to min-width: auto, so a long unbreakable line inside
       .ij-thesis-prose (e.g. an indented code block) floors this track at its
       min-content width and blows out the grid — and the page — instead of
       scrolling inside the prose's own overflow-x containers. */
    min-width: 0;
    border-top: 2px solid;
    padding-top: 12px;
}

.ij-thesis-case--bull {
    border-top-color: var(--mud-palette-success);
}

.ij-thesis-case--bear {
    border-top-color: var(--mud-palette-error);
}

.ij-thesis-case-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 7px;
}

.ij-thesis-case--bull .ij-thesis-case-label {
    color: var(--mud-palette-success);
}

.ij-thesis-case--bear .ij-thesis-case-label {
    color: var(--mud-palette-error);
}

.ij-thesis-prose {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--mud-palette-text-primary);
}

.ij-thesis-prose > :first-child {
    margin-top: 0;
}

.ij-thesis-prose > :last-child {
    margin-bottom: 0;
}

.ij-thesis-prose p {
    margin: 0 0 10px;
}

.ij-thesis-prose ul,
.ij-thesis-prose ol {
    margin: 0 0 10px;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.ij-thesis-prose li {
    padding-left: 2px;
}

/* A loose list ("- one\n\n- two") makes Markdig wrap each item's text in its
   own <p>. Without this, the <ul>'s 7px flex gap stacks on top of that <p>'s
   10px bottom margin, giving 17px between loose items vs 7px between tight
   ones (which have no <p>). Zeroing the <li>'s own paragraph margins lets the
   flex gap be the only spacer, so loose and tight lists read the same — and,
   as a side effect, this also fixes a trailing <p> in the LAST <li> of the
   whole prose block, which `.ij-thesis-prose > :last-child` can't reach
   because it only matches direct children of the prose container. */
.ij-thesis-prose li > p:first-child {
    margin-top: 0;
}

.ij-thesis-prose li > p:last-child {
    margin-bottom: 0;
}

.ij-thesis-prose strong {
    font-weight: 600;
}

.ij-thesis-prose em {
    font-style: italic;
}

.ij-thesis-prose a {
    color: var(--mud-palette-primary);
    text-decoration: none;
}

.ij-thesis-prose a:hover {
    text-decoration: underline;
}

/* Inline code only — a block <code> inside <pre> gets its own treatment
   below so the pill background/padding doesn't apply there. */
.ij-thesis-prose code {
    font-size: 12.5px;
    background: var(--mud-palette-background-grey);
    padding: 1px 5px;
    border-radius: 4px;
}

.ij-thesis-prose h1,
.ij-thesis-prose h2,
.ij-thesis-prose h3,
.ij-thesis-prose h4,
.ij-thesis-prose h5,
.ij-thesis-prose h6 {
    margin: 14px 0 6px;
    font-weight: 700;
    line-height: 1.3;
}

.ij-thesis-prose h1 {
    font-size: 19px;
}

.ij-thesis-prose h2 {
    font-size: 17px;
}

.ij-thesis-prose h3 {
    font-size: 15.5px;
}

.ij-thesis-prose h4,
.ij-thesis-prose h5,
.ij-thesis-prose h6 {
    font-size: 13.5px;
}

.ij-thesis-prose hr {
    margin: 14px 0;
    border: none;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.ij-thesis-prose img,
.ij-thesis-prose video {
    max-width: 100%;
    height: auto;
}

.ij-thesis-prose iframe {
    max-width: 100%;
}

/* A 4-space-indented line (or a fenced block) can be arbitrarily wide with no
   wrap points — scroll it inside its own container rather than blowing out
   the narrow two-column facts grid or the page. */
.ij-thesis-prose pre {
    margin: 0 0 10px;
    padding: 8px 10px;
    max-width: 100%;
    overflow-x: auto;
    border-radius: 6px;
    background: var(--mud-palette-background-grey);
}

.ij-thesis-prose pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.ij-thesis-prose blockquote {
    margin: 0 0 10px;
    padding-left: 12px;
    border-left: 2px solid var(--mud-palette-lines-default);
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-prose table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 12.5px;
    margin: 0 0 10px;
}

.ij-thesis-prose th,
.ij-thesis-prose td {
    border: 1px solid var(--mud-palette-lines-default);
    padding: 4px 8px;
    text-align: left;
}

/* --- Assumptions + catalysts --- */

.ij-thesis-facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    border-top: 1px solid var(--mud-palette-lines-default);
    padding-top: 16px;
    margin-bottom: 4px;
}

.ij-thesis-fact {
    /* Same min-content-floor fix as .ij-thesis-case above, for the facts grid. */
    min-width: 0;
}

.ij-thesis-fact-label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 7px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ij-thesis-fact-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.ij-thesis-fact--assumptions .ij-thesis-fact-label {
    color: var(--mud-palette-secondary);
}

.ij-thesis-fact--catalysts .ij-thesis-fact-label {
    color: var(--mud-palette-primary);
}

.ij-thesis-delete-btn {
    color: var(--mud-palette-error);
}

.ij-thesis-history-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 12px;
}

/* --- Revision timeline --- */

.ij-thesis-revisions {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
}

.ij-thesis-revision {
    display: flex;
    gap: 12px;
}

.ij-thesis-rev-gutter {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: none;
    width: 10px;
}

.ij-thesis-rev-node {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
    margin-top: 4px;
}

.ij-thesis-rev-node--green {
    background: var(--mud-palette-success);
}

.ij-thesis-rev-node--neutral {
    background: var(--mud-palette-text-secondary);
}

.ij-thesis-rev-node--red {
    background: var(--mud-palette-error);
}

.ij-thesis-rev-node--none {
    background: var(--mud-palette-text-disabled);
}

.ij-thesis-rev-rail {
    width: 1px;
    flex: 1;
    background: var(--mud-palette-lines-default);
}

.ij-thesis-rev-body {
    flex: 1;
    min-width: 0;
    padding-bottom: 14px;
}

.ij-thesis-revision:last-child .ij-thesis-rev-body {
    padding-bottom: 0;
}

.ij-thesis-rev-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
    margin-bottom: 2px;
}

.ij-thesis-rev-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-rev-current {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 980px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent);
}

.ij-thesis-revision .ij-thesis-verdict-chip {
    padding: 1px 9px;
    font-size: 10.5px;
}

.ij-thesis-rev-target {
    font-size: 12px;
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-rev-delta {
    font-size: 11px;
    font-weight: 700;
}

.ij-thesis-rev-delta--up {
    color: var(--mud-palette-success);
}

.ij-thesis-rev-delta--down {
    color: var(--mud-palette-error);
}

.ij-thesis-rev-excerpt {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Dialog (mirrors the published layout — design 5A) --- */

.ij-thesis-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.ij-thesis-dialog-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.ij-thesis-dialog-close {
    border: none;
    background: transparent;
    padding: 2px;
    cursor: pointer;
    color: var(--mud-palette-text-secondary);
    display: inline-flex;
}

.ij-thesis-dialog-hint {
    margin: 0 0 18px;
    font-size: 12.5px;
    color: var(--mud-palette-text-disabled);
}

.ij-thesis-editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.ij-thesis-field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
}

.ij-thesis-field-caps {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ij-thesis-field-caps--bull {
    color: var(--mud-palette-success);
}

.ij-thesis-field-caps--bear {
    color: var(--mud-palette-error);
}

.ij-thesis-field-caps--assumptions {
    color: var(--mud-palette-secondary);
}

.ij-thesis-field-caps--catalysts {
    color: var(--mud-palette-primary);
}

.ij-thesis-field-prompt {
    font-size: 11.5px;
    color: var(--mud-palette-text-disabled);
    text-align: right;
}

.ij-thesis-field-prompt--lower {
    text-transform: lowercase;
}

.ij-thesis-field {
    margin-bottom: 14px;
}

.ij-thesis-textarea {
    width: 100%;
    resize: vertical;
    border: none;
    border-radius: 10px;
    padding: 11px 13px;
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--mud-palette-text-primary);
    background: color-mix(in srgb, var(--mud-palette-text-primary) 5%, transparent);
    outline: none;
    /* Auto-grow with the content (Chromium 123+); resize: vertical is the fallback. */
    field-sizing: content;
    min-height: 120px;
    max-height: 40vh;
}

.ij-thesis-textarea:focus {
    background: color-mix(in srgb, var(--mud-palette-text-primary) 8%, transparent);
}

/* The bull/bear accent rules run into the field: rule on top, rounded bottom only. */
.ij-thesis-textarea--bull {
    border-top: 2px solid var(--mud-palette-success);
    border-radius: 0 0 10px 10px;
}

.ij-thesis-textarea--bear {
    border-top: 2px solid var(--mud-palette-error);
    border-radius: 0 0 10px 10px;
}

.ij-thesis-textarea--short {
    min-height: 88px;
}

/* --- Judgment panel --- */

.ij-thesis-judgment {
    background: var(--mud-palette-background-gray);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.ij-thesis-judgment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.ij-thesis-judgment-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-disabled);
}

.ij-thesis-publishes {
    font-size: 12px;
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-publishes-verdict--green {
    color: var(--mud-palette-success);
}

.ij-thesis-publishes-verdict--neutral {
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-publishes-verdict--red {
    color: var(--mud-palette-error);
}

.ij-thesis-judgment-row {
    display: flex;
    align-items: flex-end;
    gap: 22px;
    flex-wrap: wrap;
}

.ij-thesis-cluster-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--mud-palette-text-disabled);
    margin-bottom: 6px;
}

.ij-thesis-upside-caption {
    font-weight: 700;
    color: var(--mud-palette-success);
}

.ij-thesis-upside-caption--down {
    color: var(--mud-palette-error);
}

.ij-thesis-review-caption {
    color: var(--mud-palette-text-secondary);
}

.ij-thesis-price-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 10px;
    padding: 8px 12px;
    background: color-mix(in srgb, var(--mud-palette-text-primary) 5%, transparent);
}

.ij-thesis-price-wrap:focus-within {
    background: color-mix(in srgb, var(--mud-palette-text-primary) 8%, transparent);
}

.ij-thesis-price-prefix {
    color: var(--mud-palette-text-disabled);
    font-size: 0.84375rem;
}

/* Single-line sibling of the textarea look — used by the price target. */
.ij-thesis-input {
    width: 160px;
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font: inherit;
    font-size: 0.875rem;
    color: var(--mud-palette-text-primary);
    background: color-mix(in srgb, var(--mud-palette-text-primary) 5%, transparent);
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.ij-thesis-input:focus {
    background: color-mix(in srgb, var(--mud-palette-text-primary) 8%, transparent);
}

/* Variant inside the $-prefixed wrapper: the wrapper carries the chrome. */
.ij-thesis-input--bare {
    width: 90px;
    padding: 0;
    border-radius: 0;
    background: transparent;
    font-weight: 600;
}

.ij-thesis-input--bare:focus {
    background: transparent;
}

.ij-thesis-footer-note {
    font-size: 12px;
    color: var(--mud-palette-text-disabled);
    margin-right: auto;
}

.ij-thesis-footer-actions {
    display: inline-flex;
    align-items: center;
    gap: 16px;
}

/* Shared with the MAUI head — stack the facing columns on narrow widths.
   Must stay LAST: the grids' base 1fr 1fr rules have equal specificity, so
   source order is what lets these win inside the media query. */
@media (max-width: 640px) {
    .ij-thesis-debate,
    .ij-thesis-facts,
    .ij-thesis-editor-grid {
        grid-template-columns: 1fr;
    }
}

.ij-thesis-input::-webkit-outer-spin-button,
.ij-thesis-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ij-thesis-seg {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--mud-palette-text-primary) 5%, transparent);
}

.ij-thesis-seg-btn {
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
    cursor: pointer;
}

/* --- Mobile full-screen editor (design 6A) — scoped by the dialog variant class,
   set when the MAUI head opens the editor with ThesisVariant.Mobile. --- */

/* The nav bar owns the top edge; the body wrapper carries the padding. */
.ij-thesis-dialog--mobile .mud-dialog-content {
    padding: 0;
}

/* Cancel · title · Save — sticky so Save survives scrolling; the top position
   (not the footer) is what keeps it reachable with the keyboard open. */
.ij-thesis-dialog--mobile .ij-thesis-nav {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(env(safe-area-inset-top) + 8px) 16px 10px;
    background: var(--mud-palette-surface);
    border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 10%, transparent);
}

.ij-thesis-nav-title {
    font-size: 16.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-align: center;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ij-thesis-nav-save {
    border: none;
    background: transparent;
    padding: 4px 2px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    color: var(--mud-palette-primary);
    cursor: pointer;
}

.ij-thesis-nav-save:disabled {
    color: var(--mud-palette-text-disabled);
    cursor: default;
}

.ij-thesis-dialog--mobile .ij-thesis-dialog-body {
    padding: 16px 18px calc(env(safe-area-inset-bottom) + 16px);
}

/* Single column at phone width (the ≤640px query also applies — this keeps the
   layout correct even in wide simulators/iPads). */
.ij-thesis-dialog--mobile .ij-thesis-editor-grid {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 0;
}

/* 16px inputs prevent the iOS focus auto-zoom; 6A min-heights. */
.ij-thesis-dialog--mobile .ij-thesis-textarea {
    font-size: 16px;
    min-height: 84px;
}

.ij-thesis-dialog--mobile .ij-thesis-textarea--bear {
    min-height: 66px;
}

.ij-thesis-dialog--mobile .ij-thesis-textarea--short {
    min-height: 48px;
}

.ij-thesis-dialog--mobile .ij-thesis-input {
    font-size: 16px;
}

/* Judgment clusters stack full-width; segments become ≥44pt thumb targets. */
.ij-thesis-dialog--mobile .ij-thesis-judgment-row {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
}

.ij-thesis-dialog--mobile .ij-dcf-verdict-toggle,
.ij-thesis-dialog--mobile .ij-thesis-seg {
    display: flex;
    width: 100%;
}

.ij-thesis-dialog--mobile .ij-dcf-verdict-btn,
.ij-thesis-dialog--mobile .ij-thesis-seg-btn {
    flex: 1;
    min-height: 44px;
}

.ij-thesis-dialog--mobile .ij-thesis-judgment-publishes {
    margin-top: 12px;
    line-height: 1.45;
}

.ij-thesis-footer-note--mobile {
    margin: 12px 2px 0;
}

/* 6A "Delete Contact" pattern — the destructive action at the editor's very
   bottom, full width, on an error wash. */
.ij-thesis-delete-row {
    display: block;
    width: 100%;
    min-height: 46px;
    margin-top: 16px;
    border: none;
    border-radius: 12px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--mud-palette-error);
    background: color-mix(in srgb, var(--mud-palette-error) 10%, transparent);
    cursor: pointer;
}

.ij-thesis-seg-btn--active {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
