/* ========================================
   Aniimax - Minimalist Production Optimizer
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0e1013;
    --surface: #16191e;
    --surface-2: #1e2229;
    --text: #e9eaec;
    --text-muted: #9aa0a8;
    --border: #2a2f37;
    --accent: #6cc5a4;
    --on-accent: #0e1013;
    --success: #6cc5a4;
    --error: #ef6b68;
    --warning: #f0b35a;
    --radius: 12px;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Courier New", Courier, monospace;
}

.light {
    --bg: #f5f4ef;
    --surface: #ffffff;
    --surface-2: #f0eee8;
    --text: #1d1f22;
    --text-muted: #666a70;
    --border: #e2dfd7;
    --accent: #2e7d65;
    --on-accent: #ffffff;
    --success: #2e7d65;
    --error: #c62828;
    --warning: #b8660b;
}

body {
    accent-color: var(--accent);
    font-family: var(--font-body);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.55;
    max-width: 880px;
    margin: 2.5rem auto;
    padding: 0 1rem;
    transition: background-color 0.3s, color 0.3s;
    font-variant-numeric: tabular-nums;
}

a {
    color: inherit;
    text-decoration: underline;
}

a:hover {
    color: inherit;
}

/* Header */
header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

header h1 {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: normal;
    letter-spacing: -0.02em;
}

.header-buttons {
    display: flex;
    gap: 1rem;
}

.toggle-button {
    cursor: pointer;
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: normal;
    text-decoration: underline;
}

.toggle-button:hover {
    opacity: 0.7;
}

#language-switch option {
    background: var(--surface);
    color: var(--text);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.disclaimer {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    margin-bottom: 2rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    background: transparent;
}

/* Typography */
h2 {
    font-size: 1.2rem;
    font-weight: normal;
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1rem;
    font-weight: normal;
    margin-bottom: 0.75rem;
}

h4 {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

p {
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.hint.small {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Sections */
.config-section,
.results-section {
    margin-bottom: 2rem;
}

/* Input Fields */
.config-group {
    margin-bottom: 1.5rem;
}

.input-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.input-field {
    flex: 1;
}

.input-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.input-field input,
.input-field select {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.input-field input:focus,
.input-field select:focus {
    outline: none;
    border-color: var(--text);
}

.input-field input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.input-field input[type="number"]::-webkit-outer-spin-button,
.input-field input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-field select {
    cursor: pointer;
}

/* Checkbox Field */
.checkbox-field {
    display: flex;
    align-items: center;
}

.checkbox-field label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-field input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Radio Group (currency selector) */
.radio-group {
    display: flex;
    gap: 1.5rem;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.radio-group input[type="radio"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Facilities Grid */
.facilities-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.facility-category-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.facilities-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.facility-card {
    border: 1px solid var(--border);
    padding: 1rem;
}

.facility-card h4 {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

/* Info icon and tooltip styles */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    font-size: 0.65rem;
    font-weight: bold;
    border: 1px solid var(--text-muted);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: help;
    margin-left: 0.25rem;
    vertical-align: middle;
    position: relative;
}

.info-icon:hover {
    border-color: var(--text);
    color: var(--text);
}

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: normal;
    white-space: pre-line;
    border: 1px solid var(--border);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    margin-bottom: 0.5rem;
    min-width: 180px;
    max-width: 280px;
    text-align: left;
    line-height: 1.4;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

.facility-tiers {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.facility-inputs {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.facility-inputs .input-field {
    flex: 1;
}

.facility-inputs .input-field label {
    font-size: 0.7rem;
}

.facility-inputs input {
    padding: 0.4rem;
    font-size: 0.85rem;
}

/* Simple / advanced input mode switch. */
.mode-switch {
    display: flex;
    gap: 1.5rem;
    margin: 1rem 0;
}

.mode-switch label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* One owned tier's remove button, sitting inline at the end of its Count/Level row. */
.tier-remove-btn {
    cursor: pointer;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0.4rem 0.6rem;
}

.tier-remove-btn:hover {
    color: var(--text);
    border-color: var(--text);
}

/* Adds one more owned tier (e.g. "+ Add level") below a facility's tier rows. */
.add-tier-btn {
    cursor: pointer;
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: 0.75rem;
    text-decoration: underline;
    padding: 0;
    margin-top: 0.5rem;
    align-self: flex-start;
}

.add-tier-btn:hover {
    opacity: 0.7;
}

/* Modules Grid */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.module-card {
    border: 1px solid var(--border);
    padding: 1rem;
}

.module-card h4 {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.module-card .input-field {
    max-width: 100px;
}

.module-card .input-field label {
    font-size: 0.7rem;
}

.module-card input {
    padding: 0.4rem;
    font-size: 0.85rem;
}

/* Optimize Button */
.optimize-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--text);
    color: var(--bg);
    border: 1px solid var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.optimize-btn:hover {
    opacity: 0.8;
}

.optimize-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Progress bar shown while find_plan runs in the worker (see worker.js); fill width is driven by
   the solver's own real trial-solve count (see `trialCountToPercent` in app.js), not a decorative
   animation, so it actually reflects work happening. */
.progress-bar-container {
    width: 100%;
    height: 4px;
    margin-top: 0.6rem;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--text);
    border-radius: 2px;
    transition: width 0.15s ease-out;
}

/* Error Message */
.error-message {
    border: 1px solid var(--error);
    color: var(--error);
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Results Summary */
.result-summary {
    margin-bottom: 1.5rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.summary-item {
    border: 1px solid var(--border);
    padding: 1rem;
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-value {
    display: block;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--success);
}

.rate-unit-select {
    margin-top: 0.5rem;
    padding: 0.2rem 0.4rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.rate-unit-select:focus {
    outline: none;
    border-color: var(--text);
}

/* Byproduct bonus rows, appended to the bottom of the Product Breakdown table */
#product-breakdown-table tbody tr.byproduct-row {
    color: var(--warning);
    font-style: italic;
}

#product-breakdown-table tbody tr.byproduct-row td {
    border-top: 1px dashed var(--warning);
}

/* Production Steps */
.production-steps {
    margin-bottom: 1.5rem;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.energy-info {
    border: 1px solid var(--success);
    padding: 1rem;
    margin-bottom: 1rem;
    color: var(--success);
    font-size: 0.85rem;
}

.energy-info strong {
    display: block;
    margin-bottom: 0.25rem;
}

.parallel-info {
    border: 1px solid #9f7aea;
    padding: 1rem;
    margin-bottom: 1rem;
    color: #9f7aea;
    font-size: 0.85rem;
}

.parallel-info strong {
    display: block;
    margin-bottom: 0.25rem;
}

.step-item {
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.step-number {
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.step-number.energy-step {
    border-color: var(--warning);
    color: var(--warning);
}

.step-number.profit-step {
    border-color: var(--success);
    color: var(--success);
}

.step-number.parallel-step {
    border-color: #9f7aea;
    color: #9f7aea;
    font-weight: bold;
}

/* Chain Groups for Parallel Mode */
.chain-group {
    border: 1px solid var(--border);
    margin-bottom: 0.5rem;
    background: var(--bg-lighter);
}

.chain-header {
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chain-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chain-number {
    background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%);
    color: white;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.chain-path {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.chain-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chain-step {
    border: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg-lighter);
}

.chain-step:last-child {
    border-bottom: none;
}

.step-indicator {
    width: 1.5rem;
    color: #9f7aea;
    font-weight: bold;
    flex-shrink: 0;
    text-align: center;
}

.step-details {
    flex: 1;
}

.step-name {
    font-size: 0.9rem;
}

.step-facility {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.step-allocation {
    font-size: 0.75rem;
    color: #9f7aea;
    margin-top: 0.25rem;
    font-style: italic;
}

.step-meta {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Options Table */
.all-options {
    margin-bottom: 1rem;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th,
td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border: 1px solid var(--border);
}

th {
    background: var(--bg);
    font-weight: bold;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr:first-child {
    background: transparent;
}

tbody tr:first-child td {
    color: var(--success);
    font-weight: bold;
}

/* Facility plan tables (one per category, see renderFacilityPlan in app.js): status reflects
   role (producing/idle/not needed), not row position, overriding the generic "highlight first
   row" rule above so it doesn't imply the first facility listed is special. */
.facility-plan-table tbody tr:first-child td {
    color: inherit;
    font-weight: normal;
}

.facility-plan-table tbody tr.status-not_needed td,
.facility-plan-table tbody tr.status-nothing_available td,
.facility-plan-table tbody tr.status-idle td {
    color: var(--text-muted);
}

/* Environment building layout diagram (see renderEnvironmentDiagram in app.js): a simple SVG
   showing the solver's own chosen facility placements around one building instance, next to that
   instance's table. */
.env-unit {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.env-unit-table {
    flex: 1 1 320px;
    min-width: 0;
}

.env-diagram {
    flex: 0 0 auto;
    color: var(--text-muted);
}

.env-diagram svg {
    display: block;
    width: 280px;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

/* Whole-tile lines, a heavier major line every other tile, and faint quarter-tile lines. */
.env-grid line {
    stroke: currentColor;
    stroke-opacity: 0.2;
    stroke-width: 0.035;
}

.env-grid line.major {
    stroke-opacity: 0.38;
    stroke-width: 0.08;
}

.env-grid line.quarter {
    stroke-opacity: 0.05;
    stroke-width: 0.02;
}

.env-plot text {
    fill: #111;
    font-family: var(--font-body);
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.env-plot:hover rect,
.layout-piece:hover > rect {
    fill-opacity: 1;
    stroke: currentColor;
}

.env-building:hover > rect {
    stroke-opacity: 1;
}

.env-legend {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.5rem;
    max-width: 280px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.env-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.env-legend-swatch {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 3px;
}

.env-legend-swatch.coverage {
    border: 1px dashed;
}

/* Recipe reference tables (facility recipe modal): one table per facility, listed row order
   reflects level/name sort, not importance, same override as the facility-plan table above. */
.recipe-table tbody tr:first-child td {
    color: inherit;
    font-weight: normal;
}

.facility-recipe-table {
    margin-bottom: 1.5rem;
}

.facility-recipe-table h4 {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

.footer-note {
    margin-top: 0.35rem;
    font-size: 0.75rem;
}

/* Loading State */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        margin: 2rem auto;
        padding: 0 1rem;
    }

    header {
        flex-direction: column;
        gap: 0.5rem;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .toggle-button {
        align-self: flex-end;
    }

    .input-row {
        flex-direction: column;
        gap: 1rem;
    }

    .facilities-grid {
        grid-template-columns: 1fr;
    }

    .modules-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .step-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .step-meta {
        text-align: left;
    }

    th,
    td {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background-color: var(--bg);
    border: 1px solid var(--border);
    max-width: 600px;
    width: 100%;
    margin: 2rem auto;
}

.modal-content.wide {
    max-width: 1100px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

.close-button {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-button:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body p {
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.modal-body ul {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.modal-body li {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.modal-body li strong {
    color: var(--text);
}

.modal-wide {
    max-width: 750px;
}

.math-block {
    background: rgba(128, 128, 128, 0.1);
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    border-left: 2px solid var(--border);
}

.modal-body h4 {
    font-size: 0.9rem;
    font-weight: bold;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.modal-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.modal-body ol li {
    margin-bottom: 0.75rem;
}

.modal-body ol li ul {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.math-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.85rem;
}

.math-table th,
.math-table td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.math-table th {
    background: rgba(128, 128, 128, 0.1);
    font-weight: bold;
}

/* ========================================
   Cards, tabs and badges
   ======================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem 1.5rem;
    margin-bottom: 1.25rem;
}

.card h2 {
    margin: 0 0 0.75rem;
    padding: 0;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
}

.card h3 {
    font-weight: 600;
    margin-top: 1.25rem;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.card-head h2 {
    margin: 0;
}

.card-lead {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.toggle-button.small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.config-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.share-config-result {
    margin-bottom: 0.5rem;
}

.share-config-result[hidden] {
    display: none;
}

.share-config-result label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.share-config-result input {
    box-sizing: border-box;
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

#share-config-status:empty {
    display: none;
}

.subtitle {
    margin-top: -1.5rem;
}

.disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-style: normal;
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 45%, transparent);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--warning) 9%, var(--surface));
    margin-bottom: 1.5rem;
}

.disclaimer-icon {
    font-size: 0.95rem;
    line-height: 1.2;
}

/* Segmented tabs built from radio labels. */
.tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    margin-bottom: 1.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.tabs label {
    position: relative;
    padding: 0.4rem 1.1rem;
    border-radius: 7px;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s, color 0.15s;
}

.tabs label:hover {
    color: var(--text);
}

.tabs input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tabs label:has(input:checked) {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.tabs label:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.tabs.compact {
    margin-bottom: 0;
}

.tabs.compact label {
    padding: 0.3rem 0.85rem;
    font-size: 0.85rem;
}

/* Inputs */
.input-field input,
.input-field select {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
}

.input-field input:focus,
.input-field select:focus {
    border-color: var(--accent);
}

#simple-config .input-field {
    max-width: 16rem;
}

/* Simple mode: what the RV level assumes, as a grid of chips. */
.assume-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0 0.5rem;
}

.chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.4rem;
}

.chip {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.4rem 0.65rem;
    background: var(--surface-2);
    border-radius: 8px;
    font-size: 0.82rem;
}

.chip-count {
    font-weight: 600;
}

.chip-level {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Options and the main button */
.option-row {
    gap: 0.4rem;
    margin: 1.5rem 0 1rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.optimize-btn {
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.progress-bar-container {
    position: relative;
}

/* The exact planner doesn't report progress, so the bar just shows it's working. */
.progress-bar-fill.indeterminate {
    position: absolute;
    width: 35%;
    background: var(--accent);
    animation: progress-slide 1.1s ease-in-out infinite;
}

@keyframes progress-slide {
    from { left: -35%; }
    to { left: 100%; }
}

/* Results: the rate */
#rate-block .summary-label {
    margin-bottom: 0.1rem;
}

.rate-line {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.rate-line .summary-value {
    display: inline;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.rate-unit-select {
    margin-top: 0;
    border-radius: 6px;
    background: var(--surface-2);
}

.plan-proof {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.plan-unverified {
    margin: 0.6rem 0 0;
    font-size: 0.8rem;
    color: var(--warning);
}

.tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: 1px;
}

.tag.unverified {
    border: 1px solid var(--warning);
    color: var(--warning);
}

/* Collapsible explanations */
details.explain {
    margin-bottom: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

details.explain summary {
    cursor: pointer;
    width: fit-content;
    user-select: none;
}

details.explain summary:hover {
    color: var(--text);
}

details.explain p {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
}

/* Tables */
.card table {
    font-size: 0.85rem;
}

.card th,
.card td {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.55rem 0.6rem;
}

.card th {
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
}

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

.card tbody tr:first-child td {
    color: inherit;
    font-weight: normal;
}

.facility-category-title {
    font-weight: 600;
    border-bottom: none;
    padding-bottom: 0;
}

.facility-card,
.module-card {
    background: var(--surface-2);
    border: none;
    border-radius: 10px;
}

.summary-item {
    border-radius: 10px;
    background: var(--surface-2);
    border: none;
}

#goal-section .summary-value {
    color: var(--text);
}

.error-message {
    border-color: var(--error);
}

/* Inputs inside the Advanced tab's facility and module cards. */
.facility-card .input-field input,
.module-card .input-field input {
    background: var(--surface);
}

@media (max-width: 600px) {
    .card {
        padding: 1rem;
    }

    /* Plan tables become one labelled block per row on narrow screens. */
    .facility-plan-table thead {
        display: none;
    }

    .facility-plan-table tr {
        display: block;
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--border);
    }

    .facility-plan-table tbody tr:last-child {
        border-bottom: none;
    }

    .card .facility-plan-table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.15rem 0;
        border: none;
        text-align: right;
    }

    .facility-plan-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.75rem;
        text-align: left;
        white-space: nowrap;
    }

    .rate-line .summary-value,
    .level-up-card .summary-value {
        font-size: 1.6rem;
    }

    .chip-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* Aniimo team card: collapsed to a one-line summary until opened. */
.collapse-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0;
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.collapse-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

.collapse-toggle .chevron {
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(-45deg);
    transition: transform 0.15s;
}

.collapse-toggle[aria-expanded="true"] .chevron {
    transform: rotate(45deg);
}

.collapse-toggle:hover h2 {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.aniimo-card .card-head {
    margin-bottom: 0.35rem;
}

.collapsed-summary {
    margin: 0 0 0 1.05rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

#aniimo-body {
    margin-top: 1rem;
}

/* Aniimo abilities in their in-game colors. */
.ability {
    display: inline-block;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--ability);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.ability.dark {
    color: #1d1f22;
}

/* How many of each ability a plan needs, like the game's Abilities screen. */
.ability-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 1rem 0.35rem;
    margin: 0.85rem 0 0;
}

@media (min-width: 720px) {
    .ability-strip {
        grid-template-columns: repeat(13, minmax(0, 1fr));
        gap: 0.3rem;
    }
}

.ability-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0.4rem 0.2rem 0.35rem;
    border-radius: 8px;
    background: var(--surface-2);
    border-top: 3px solid var(--ability);
}

.ability-count {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ability);
}

.ability-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.ability-cell.zero {
    opacity: 0.35;
    border-top-color: var(--border);
}

.ability-cell.zero .ability-count {
    color: var(--text-muted);
}

/* The facility plan's Aniimo column: one colored circle per ability, level inside. */
.ability-dots {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    vertical-align: middle;
}

.ability-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--ability);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: help;
}

.ability-dot.dark {
    color: #1d1f22;
}

/* A ring marks an Aniimo that has the facility's personality bonus. */
.ability-dot.bonus {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ability);
}

/* The Aniimo behind each ability count, one circle each. */
/* One column per ability: its box, then its Aniimo circles below it. */
.ability-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.ability-col .ability-cell {
    width: 100%;
}

.ability-stack {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.ability-kind {
    position: relative;
    display: inline-flex;
}

/* Beside the circle without shifting it, so circles line up in their column. */
.ability-times {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0.15rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.ability-dot.small {
    width: 1.2rem;
    height: 1.2rem;
    font-size: 0.65rem;
}

.ability-dot.small.bonus {
    box-shadow: 0 0 0 1.5px var(--surface-2), 0 0 0 2.75px var(--ability);
}

/* Strategy: level up or most coins. */
.strategy {
    margin: 1.5rem 0 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.strategy h3 {
    margin-bottom: 0.6rem;
}

#level-up-config .input-field {
    max-width: 16rem;
}

#level-up-cost .chip-grid {
    margin-bottom: 0.75rem;
}

.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem 1rem;
    margin-top: 0.6rem;
}

#level-up-config .stock-grid .input-field {
    max-width: none;
}

.level-up-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.5rem 0 0;
}

/* Results: how soon the level-up is covered. */
.level-up-card .summary-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.level-up-lines {
    width: 100%;
    margin-top: 0.75rem;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.level-up-lines th {
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem 0.3rem 0;
}

.level-up-lines td {
    padding: 0.35rem 0.5rem 0.35rem 0;
    border-top: 1px solid var(--border);
}

/* The unit select, as the rate column's header. */
.level-up-lines th .rate-unit-select {
    font-size: 0.75rem;
    padding: 0.15rem 0.3rem;
}

/* A level-up that couldn't be planned: the coin rate follows its note. */
.level-up-card .level-up-note {
    margin-bottom: 1rem;
}

.level-up-lines .slowest td,
.rate-table .top td {
    font-weight: 600;
}

.level-up-coins {
    margin: 0.85rem 0 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.level-up-coins strong {
    color: var(--text);
}

/* Popups use more of a phone's width. */
@media (max-width: 600px) {
    .modal {
        padding: 0.5rem;
    }

    .modal-content {
        margin: 0.5rem auto;
    }

    .modal-body {
        padding: 1rem;
    }

    .math-block {
        padding: 0.75rem 0.4rem;
    }
}

/* Crop and tree jobs in the recipe list: "Sowing [Grass]". */
.job-list {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.job {
    white-space: nowrap;
}

.job-step {
    display: inline-block;
    min-width: 5.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.recipe-best {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Recipe tables become one labelled block per recipe on phones. */
@media (max-width: 600px) {
    .recipe-table thead {
        display: none;
    }

    .recipe-table tr {
        display: block;
        padding: 0.6rem 0.75rem;
        border-bottom: 1px solid var(--border);
    }

    .recipe-table td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        padding: 0.12rem 0;
        border: none;
        text-align: right;
    }

    .recipe-table td.recipe-name {
        justify-content: flex-start;
        gap: 0;
        font-weight: 600;
        text-align: left;
        padding-bottom: 0.3rem;
    }

    /* The "not checked" tooltip hangs from the name cell, not the icon, so a long name can't
       push it past the edge. */
    .recipe-table td.recipe-name {
        position: relative;
    }

    .recipe-table td.recipe-name .info-icon {
        position: static;
    }

    .recipe-table td.recipe-name [data-tooltip]::after {
        left: 0;
        transform: none;
    }

    .recipe-table td.empty {
        display: none;
    }

    .recipe-table td[data-label]::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.75rem;
        text-align: left;
        white-space: nowrap;
    }

    .recipe-table .job-list {
        align-items: flex-end;
    }

    .recipe-table .recipe-best {
        text-align: right;
    }
}

/* Table header tooltips open downward (a scrolling table would clip them above), and the last
   column's stays inside the table's right edge. */
.table-wrapper th [data-tooltip]::after {
    bottom: auto;
    top: 100%;
    margin-bottom: 0;
    margin-top: 0.5rem;
    text-transform: none;
    letter-spacing: normal;
}

.table-wrapper th:last-child [data-tooltip]::after {
    left: auto;
    right: 0;
    transform: none;
}

/* Time and Sell stay on one line; Inputs wraps instead. */
.recipe-table td:nth-child(5),
.recipe-table td:nth-child(6) {
    white-space: nowrap;
}

/* Recipes: special recipes and recipes to skip */
.recipes-section {
    margin: 0 0 1.25rem;
}

.recipes-section .assume-title:first-of-type {
    margin-top: 0.75rem;
}

.skip-count {
    color: var(--text-muted);
}

.skip-add {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
    max-width: 28rem;
}

.skip-add input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.7rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}

.skip-add input:focus {
    outline: none;
    border-color: var(--accent);
}

.skip-add-btn {
    padding: 0.5rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.skip-add-btn:hover {
    border-color: var(--accent);
}

.skip-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.skip-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.3rem 0.25rem 0.65rem;
    background: var(--surface-2);
    border-radius: 999px;
    font-size: 0.82rem;
}

.skip-chip-facility {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.skip-chip button,
.skip-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
}

.skip-chip button:hover,
.skip-row:hover {
    background: var(--border);
    color: var(--text);
}

.skip-row {
    margin-left: 0.3rem;
    vertical-align: middle;
    opacity: 0.55;
}

tr:hover .skip-row,
.skip-row:focus-visible {
    opacity: 1;
}

.plan-skipped {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Special recipes: one checkbox each. */
.special-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.4rem 1rem;
    margin-top: 0.6rem;
}

.special-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.tag.special {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    margin-left: 0.35rem;
}

/* "Fill from RV level" in advanced mode. */
.fill-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0 1.25rem;
}

.fill-row label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.fill-row select {
    padding: 0.4rem 0.6rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
}

.fill-row .hint {
    flex-basis: 100%;
    margin: 0;
}

/* Seeds a plan plants, in their own card. */
.seed-table {
    margin-top: 0.5rem;
}

.seed-table table {
    width: 100%;
    max-width: 32rem;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.seed-table th {
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.2rem 0.5rem 0.2rem 0;
}

.seed-table td {
    padding: 0.25rem 0.5rem 0.25rem 0;
    border-top: 1px solid var(--border);
}

.seed-table tfoot td {
    font-weight: 600;
}

/* Priorities: a ranked, draggable list. */
.priority-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    max-width: 26rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.priority {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: grab;
}

.priority.off .priority-name,
.priority.off .drag-handle {
    opacity: 0.55;
}

.priority.dragging {
    opacity: 0.4;
}

.priority.drop-target {
    border-color: var(--accent);
}

.priority-name {
    flex: 1;
}

/* On/off switch: a real checkbox, drawn as a sliding switch. */
.priority-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.priority-switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.switch-track {
    position: relative;
    width: 2.1rem;
    height: 1.2rem;
    border-radius: 999px;
    background: var(--border);
    transition: background 0.15s;
}

.switch-track::after {
    content: '';
    position: absolute;
    top: 0.15rem;
    left: 0.15rem;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.15s, background 0.15s;
}

.priority-switch input:checked + .switch-track {
    background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.priority-switch input:checked + .switch-track::after {
    transform: translateX(0.9rem);
    background: var(--accent);
}

.priority-switch input:focus-visible + .switch-track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.switch-text {
    min-width: 1.5rem;
}

.drag-handle {
    color: var(--text-muted);
    letter-spacing: -0.15em;
    user-select: none;
}

.priority-rank {
    min-width: 1rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
}

.priority-move {
    display: flex;
    gap: 0.2rem;
}

.priority-move button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    padding: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
}

.priority-move button:disabled {
    opacity: 0.3;
    cursor: default;
}

.priority-move button:not(:disabled):hover {
    border-color: var(--accent);
}

/* The coverage tint drawn over the plots, so it shows which part of each is covered; it lets
   hovers through to the plots underneath. */
.env-coverage-top {
    pointer-events: none;
}

/* Simple mode's facility list, collapsed by default. */
.simple-details {
    margin-top: 0.75rem;
}


/* A growing environment's name, in its own colour. */
.env-mode-tag {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--tint);
    background: color-mix(in srgb, var(--tint) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--tint) 40%, transparent);
    vertical-align: middle;
}

/* Between the parts of a paired environment's heading. */
.env-head-sep {
    margin: 0 0.6rem;
    color: var(--border);
}

/* Names the group of rows under it, so one table can cover a pair's three zones. */
.facility-plan-group td {
    padding: 0.85rem 0 0.35rem;
    border-top: none;
    text-align: left;
}

.facility-plan-group td::before {
    content: none; /* the band names itself; the stacked layout's labels don't apply */
}

.facility-plan-table tbody tr:first-child.facility-plan-group td {
    padding-top: 0.25rem;
}

/* Saying which Aniimo you have: ability levels under Best, the roster under My Aniimo. */
.aniimo-setup-panel {
    padding: 0.1rem 0 0.9rem;
}

.aniimo-setup-panel > .hint {
    margin: 0 0 0.6rem;
}

.ability-levels {
    display: grid;
    gap: 0.35rem;
}

.ability-levels {
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.ability-level {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ability-level .ability {
    min-width: 5.5rem;
    text-align: center;
}

/* A level, in the same segmented style as the tabs above but sized for a digit. */
.tabs.level-picker {
    margin: 0;
    padding: 2px;
    border-radius: 8px;
}

.tabs.level-picker label {
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

/* A `hidden` element stays hidden whatever else its class says about display. */
[hidden] {
    display: none !important;
}

/* How many Aniimo the plan wants, against how many the homeland holds. */
.aniimo-count {
    display: flex;
    align-items: baseline;
    gap: 0.15rem;
    margin: 0 0 0 1.05rem;
    font-size: 1.6rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.aniimo-count-of::before {
    content: '/';
    margin: 0 0.25rem 0 0.1rem;
    color: var(--text-muted);
    font-weight: 400;
}

.aniimo-count-of {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 500;
}

.aniimo-count.over {
    color: var(--danger, #e5484d);
}

/* A level the game isn't known to have an Aniimo at. */
.level-picker label.unheard-of {
    color: color-mix(in srgb, var(--text-muted) 70%, transparent);
}

.level-picker label.unheard-of::after {
    content: '*';
    font-size: 0.7em;
    vertical-align: super;
}

/* Harvest Moon Festival: a switch, then the season's inputs while it's on. */
.season {
    margin: 0 0 1.25rem;
}

.season-switch {
    font-size: 0.95rem;
    color: var(--text);
}

.season-title {
    font-weight: 600;
}

#season-config {
    margin-top: 0.75rem;
}

/* A column's unit under its name, e.g. "Profit" over "Home Coins/hour". */
.th-unit {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
}

/* Opportunities: one row per change, its gain beside it. */
.improve-list {
    margin: 0.75rem 0 0;
    padding-left: 0;
    list-style: none;
    display: grid;
    gap: 0.45rem;
}

.improve-list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
}

.improve-name {
    font-weight: 600;
}

.improve-gain {
    color: var(--accent);
}

/* Opportunities: everything the ranking tried. */
.improve-checked {
    margin-top: 0.5rem;
}

.improve-checked-list {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.improve-checked-list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.2rem 1rem;
}

.improve-none {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Homeland layout. */
.layout-diagram {
    margin-top: 0.75rem;
    overflow: auto;
}

.layout-svg {
    width: 100%;
    max-height: 90vh;
    display: block;
}

.layout-whole {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.layout-svg text {
    text-anchor: middle;
    dominant-baseline: central;
    fill: var(--text);
    font-weight: 600;
    pointer-events: none;
}

.layout-storage {
    fill: var(--accent);
    stroke: var(--text);
    stroke-width: 0.08;
}

.layout-svg .layout-storage-text {
    fill: var(--bg, #111);
}

/* Deliveries to the Storage Unit (see "Deliveries" in app.js): a piece's line shows once its
   first batch is in. */
.layout-flow-line {
    stroke: var(--accent);
    stroke-opacity: 0;
    stroke-width: 0.07;
    transition: stroke-opacity 0.4s;
}

.layout-flow-line.live {
    stroke-opacity: 0.35;
}

.layout-dot {
    fill: var(--accent);
}

/* A piece's batch: the fill goes round as it works, and the ring turns amber while it waits for
   materials. */
.layout-ring circle {
    fill: none;
    stroke-width: 0.12;
}

.layout-ring .ring-track {
    stroke: var(--bg);
    stroke-opacity: 0.55;
}

.layout-ring .ring-fill {
    stroke: var(--text);
}

.layout-ring.waiting .ring-track {
    stroke: var(--warning);
    stroke-opacity: 0.9;
}

.layout-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.layout-toggles {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
}

.layout-diagram.no-sim .layout-flows,
.layout-diagram.no-sim .layout-rings {
    display: none;
}

.layout-sim {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Progress card under the button: each step of working out a plan. */
.solve-progress {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
}

.progress-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.progress-step {
    display: grid;
    grid-template-columns: 1.1rem 1fr auto;
    align-items: center;
    gap: 0.5rem;
}

.progress-step.pending,
.progress-step.skipped {
    color: var(--text-muted);
}

.step-note {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.step-icon {
    text-align: center;
    font-weight: 700;
}

.step-icon.done {
    color: var(--accent);
}

.step-icon.fail {
    color: #ef4444;
}

.step-spinner {
    width: 0.8rem;
    height: 0.8rem;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: step-spin 0.8s linear infinite;
    justify-self: center;
}

@keyframes step-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .step-spinner {
        animation-duration: 2.4s;
    }
}

/* Homeland plots in the layout: open ones outlined and numbered, the rest hatched. */
.layout-plot rect {
    fill: none;
    stroke: var(--text-muted);
    stroke-opacity: 0.6;
    stroke-width: 0.12;
}

/* Locked plots: red, hatched, outlined and labelled in red. */
.layout-plot.locked rect {
    fill: url(#layout-locked);
    stroke: #ef4444;
    stroke-opacity: 1;
}

.layout-svg .layout-plot.locked text {
    fill: #ef4444;
}

.layout-svg .layout-plot text {
    text-anchor: start;
    dominant-baseline: hanging;
    fill: var(--text-muted);
    font-weight: 600;
}

.layout-hatch {
    stroke: #ef4444;
    stroke-opacity: 0.3;
    stroke-width: 0.12;
}

/* My Aniimo: one card per kind of Aniimo the player has. */
.roster-editor {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.roster-card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    display: grid;
    gap: 0.45rem;
}

.roster-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.roster-name {
    flex: 1;
    width: 0;
    min-width: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.2rem 0.35rem;
    color: var(--text);
    font-weight: 600;
}

.roster-name:hover,
.roster-name:focus {
    border-color: var(--border);
}

.roster-count {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.roster-count button,
.roster-x {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    min-width: 1.6rem;
    height: 1.6rem;
    line-height: 1;
}

.roster-count button:hover,
.roster-x:hover {
    color: var(--text);
}

.roster-abilities,
.roster-personalities {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
}

.roster-ability {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.roster-ability .roster-x {
    min-width: 1.3rem;
    height: 1.3rem;
    font-size: 0.7rem;
}

.roster-add-ability {
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 0.2rem 0.4rem;
}

.roster-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* A plan that failed shows only the Aniimo card, whose setup may be what to change. */
#results-content.setup-only > :not(#aniimo-card) {
    display: none !important;
}

/* While another Aniimo setup is worked out, the last one's results are dimmed. */
#results-content.stale > :not(#aniimo-card),
#results-content.stale #aniimo-body,
#results-content.stale #aniimo-abilities {
    opacity: 0.45;
    pointer-events: none;
}

/* Hover tips (see "Hover tips" in app.js). */
.tip-card {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    max-width: min(300px, calc(100vw - 24px));
    padding: 0.5rem 0.7rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-size: 0.8rem;
    line-height: 1.4;
    pointer-events: none;
}

.tip-card:not([hidden]) {
    animation: tip-in 90ms ease-out;
}

@keyframes tip-in {
    from {
        opacity: 0;
        transform: translateY(3px);
    }
}

.tip-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
}

.tip-swatch {
    flex: none;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.tip-detail {
    margin-top: 0.1rem;
}

.tip-stats {
    margin-top: 0.15rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.tip-card.has-swatch .tip-detail,
.tip-card.has-swatch .tip-stats {
    padding-left: 1.1rem;
}

@media (prefers-reduced-motion: reduce) {
    .tip-card:not([hidden]) {
        animation: none;
    }
}
