/** {box-sizing: border-box;}*/

.app {
    padding: 4px;
}

.top-row {
    display: flex;
	flex-direction: row;
    gap: 12px;
    min-height: 220px;
    max-height: none; /*320px;*/
    margin-bottom: 12px;
}

.panel {
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.input-panel {
    flex: 1 1 50%;
    min-width: 0;
	min-height: 250px;
}

.history-panel {
    flex: 1 1 50%;
    min-width: 0;
	max-height: 640px;
}

.panel-title {
    margin: 0 0 8px 0;
}

.formula-title {
    margin: 20px 0 8px 0;
}

.formula-info {
    margin: 0px 0 8px 0;
}

.query-textarea {
	font-size: 16px;
    flex: 1;
    width: 100%;
    border-radius: 2px;
    padding: 8px;
    resize: none;
	min-height: 70px;
}

.query-textarea:focus {
    outline: none;
}

.button-row {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
    flex-wrap: wrap;   /* on tight widths the formula display drops to a new line */
}

.formula-display {
	position: relative;
	padding-right: 52px;   /* room for the link button + the copy button */
}

.history-list {
	font-size: 16px;
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.history-turn {
    margin-bottom: 10px;
    padding-bottom: 8px;
}

.history-turn:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.history-answer {
    margin: 4px 0 0 0;
    word-wrap: break-word;
	padding: 4px 0px 4px 20px;
}

.history-answer .formula-block {
    padding: 8px 28px 8px 8px;   /* extra right padding for the copy button */
    margin: 4px 0;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    position: relative;
}

.copy-btn {
    background: transparent;
    border: 0;
    padding: 2px;
    margin: 0;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s;
    line-height: 0;
    border-radius: 2px;
}

.copy-btn:hover {
    opacity: 1;
}

.copy-btn:active {
    transform: scale(0.92);
}

.copy-btn img {
    width: 14px;
    height: 14px;
    display: block;
    pointer-events: none;        /* clicks go to the button, not the img */
}

.formula-block .copy-btn,
.formula-display .copy-btn {
    position: absolute;
    top: 3px;
    right: 3px;
}

/* The "open in formula screener" button sits one button-width to the left
   of the copy button (copy is at right: 3px; this one slots in at 27px so
   there's a small visual gap between them). */
.formula-block .formula-link-btn,
.formula-display .formula-link-btn {
    right: 27px;
}

.formula-display + .copy-btn {
    margin-left: 4px;
    vertical-align: middle;
}

.history-empty {
    color: #9ca3af;
    text-align: center;
    margin-top: 40px;
}

.error-banner {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: 2px;
    padding: 6px 10px;
    margin-bottom: 8px;
	margin-top: 2px;
    font-size: 13px;
}

@media (max-width: 1024px) {
	.top-row {
        flex-direction: column;
        max-height: none;
    }
}

/*@media (max-width: 640px) {
    .top-row {
        flex-direction: column;
        max-height: none;
    }
    .formula-display {
        max-width1: 100%;
    }
}*/

/* Markdown elements rendered by render_prose_markdown (in ai-screener.php). */
.history-answer h1,
.history-answer h2,
.history-answer h3,
.history-answer h4,
.history-answer h5,
.history-answer h6 {
    margin: 8px 0 4px;
    font-weight: 600;
    line-height: 1.25;
}
.history-answer h1 { font-size: 1.30em; }
.history-answer h2 { font-size: 1.20em; }
.history-answer h3 { font-size: 1.10em; }
.history-answer h4,
.history-answer h5,
.history-answer h6 { font-size: 1.00em; }

.history-answer ul {
    margin: 4px 0;
    padding-left: 22px;
}
.history-answer li {
    margin: 1px 0;
}

.history-answer code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0 4px;
    border-radius: 2px;
    font-family: Consolas, "Lucida Console", monospace;
    font-size: 0.92em;
}

.history-answer .md-code {
    background: #f6f8fa;
    border: 1px solid #d1d5da;
    border-radius: 3px;
    padding: 8px 10px;
    margin: 6px 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    font-family: Consolas, "Lucida Console", monospace;
    font-size: 0.92em;
    line-height: 1.4;
}
.history-answer .md-code code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

.history-answer .md-table {
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 0.95em;
}
.history-answer .md-table th,
.history-answer .md-table td {
    border: 1px solid #d1d5da;
    padding: 4px 8px;
    text-align: left;
    vertical-align: top;
}
.history-answer .md-table thead th {
    background: rgba(0, 0, 0, 0.04);
    font-weight: 600;
}

.history-answer a {
    color: #0366d6;
    text-decoration: underline;
}
.history-answer a:hover {
    text-decoration: none;
}

.history-answer .md-hr {
    border: 0;
    border-top: 1px solid #d1d5da;
    margin: 10px 0;
}
