html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f4f5f7;
    color: #1f2328;
}

.top-nav {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: #1f2937;
    border-bottom: 1px solid #111827;
}

.top-nav .nav-link {
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.top-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.top-nav .nav-link.active {
    color: #fff;
    background: #1971c2;
}

#app {
    min-height: 100vh;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem;
}

.loading-progress circle {
    fill: none;
    stroke: #e5e7eb;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    text-align: center;
    font-weight: 600;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Načítání…");
}

#blazor-error-ui {
    background: #ffe3e3;
    border-top: 1px solid #f5c2c7;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 6px;
}

.blazor-error-boundary::after {
    content: "Došlo k chybě.";
}

/* App layout */
.app-shell {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.app-shell header {
    margin-bottom: 1.5rem;
}

.app-shell header h1 {
    font-size: 1.5rem;
    margin: 0;
}

.app-shell header p {
    margin: 0.25rem 0 0;
    color: #57606a;
    font-size: 0.9rem;
}

.panel {
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.panel h2 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #57606a;
    margin: 0 0 0.75rem;
    font-weight: 600;
}

.panel textarea {
    width: 100%;
    min-height: 6rem;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.95rem;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    resize: vertical;
    box-sizing: border-box;
}

.panel .empty {
    color: #8c959f;
    font-style: italic;
    font-size: 0.9rem;
}

.preview-target {
    min-height: 3rem;
    font-size: 1.05rem;
}

.panel .error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

table.variables {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

table.variables th,
table.variables td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #eaecef;
    text-align: left;
    vertical-align: middle;
}

table.variables th {
    font-weight: 600;
    color: #57606a;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table.variables td.symbol {
    font-size: 1.1rem;
    min-width: 6rem;
}

table.variables select,
table.variables input[type="number"] {
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid #d0d7de;
    border-radius: 5px;
    background: #fff;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.variables-scroll {
    overflow-x: auto;
}

table.variables td:nth-child(3) { width: 5rem; }
table.variables td:nth-child(4) { width: 7rem; }
table.variables td:nth-child(5) { width: 6rem; }
table.variables td:nth-child(6) { width: 8rem; }
table.variables td:nth-child(7) { min-width: 20rem; }

table.variables input[type="text"] {
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid #d0d7de;
    border-radius: 5px;
    background: #fff;
    font-size: 0.85rem;
    box-sizing: border-box;
}

table.variables td.varattr code {
    display: block;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: #1f2328;
    background: #f6f8fa;
    padding: 0.35rem 0.5rem;
    border-radius: 5px;
    overflow-x: auto;
    white-space: nowrap;
}

.app-shell {
    max-width: 1200px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.result-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #57606a;
}

.result-grid label span {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.result-grid input,
.result-grid select {
    padding: 0.4rem 0.55rem;
    border: 1px solid #d0d7de;
    border-radius: 5px;
    background: #fff;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.panel .reference {
    margin-top: 0.5rem;
    color: #57606a;
    font-size: 0.85rem;
    text-align: right;
    font-style: italic;
}

.panel .hint {
    margin: 0 0 0.75rem;
    color: #57606a;
    font-size: 0.85rem;
}

.value-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.value-cell input[type="number"] {
    flex: 1 1 auto;
}

.unit-hint {
    font-size: 0.78rem;
    color: #57606a;
    min-width: 2.2rem;
    text-align: left;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

pre.source {
    background: #f6f8fa;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    color: #1f2328;
}

pre.source code {
    background: transparent;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

pre.source .meta {
    background: #fff3bf;
    color: #8a6d00;
    padding: 0.02rem 0.18rem;
    border-radius: 3px;
}

.panel .hint code {
    background: #f6f8fa;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-size: 0.85rem;
    color: #1f2328;
}

.copy-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.copy-btn {
    background: #1b6ec2;
    color: #fff;
    border: 0;
    padding: 0.45rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.copy-btn:hover { background: #1657a1; }

.copy-toast {
    color: #166534;
    font-size: 0.85rem;
    background: #dcfce7;
    padding: 0.25rem 0.55rem;
    border-radius: 4px;
}

.mode-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.55rem;
    background: #e7f5ff;
    color: #1971c2;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.02em;
    vertical-align: middle;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}

.example-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.55rem 0.75rem;
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.example-chip:hover {
    border-color: #1971c2;
    background: #f6fbff;
}

.example-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1f2328;
}

.example-math {
    font-size: 0.85rem;
    color: #1f2328;
}

.add-btn {
    background: #f1f3f5;
    color: #1f2328;
    border: 1px dashed #d0d7de;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 0.4rem;
}

.add-btn:hover { background: #e7f5ff; border-color: #1971c2; }

.add-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.remove-btn {
    background: transparent;
    color: #b91c1c;
    border: 1px solid transparent;
    padding: 0 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

.remove-btn:hover { background: #fef2f2; border-color: #fecaca; }

table.variables th.symbol {
    font-size: 0.95rem;
}

table.variables th.symbol .unit-hint {
    margin-left: 0.25rem;
    font-size: 0.7rem;
    color: #57606a;
    font-weight: 400;
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto !important;
    padding: 0 !important;
}

.notes-explanations {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1.25rem;
}

.notes-block h3,
.explanations-block h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #57606a;
    margin: 0 0 0.5rem;
    font-weight: 600;
}

.note-row,
.explanation-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.note-row input,
.explanation-row input {
    flex: 1 1 auto;
    padding: 0.35rem 0.55rem;
    border: 1px solid #d0d7de;
    border-radius: 5px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.explanation-row .exp-symbol { flex: 0 0 9rem; }

@media (max-width: 800px) {
    .notes-explanations { grid-template-columns: 1fr; }
}
