:root {
    --star-primary: #0053a0;
    --star-primary-dark: #003c75;
    --star-ink: #1a1a1a;
    --star-muted: #6b6b6b;
    --star-line: #e3e3e3;
    --star-bg: #fafafa;
    --star-card: #ffffff;
    --star-error: #b00020;
    --radius: 8px;
    --tap: 48px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--star-bg);
    color: var(--star-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

h1, h2, h3 {
    line-height: 1.2;
    margin: 0 0 0.5rem 0;
}

h1:focus {
    outline: none;
}

h1 {
    font-size: 1.75rem;
}

p {
    margin: 0 0 1rem 0;
}

.muted {
    color: var(--star-muted);
}

/* App shell */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--star-primary);
    color: #fff;
    box-shadow: 0 1px 0 var(--star-primary-dark);
}

.app-header-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
}

.brand {
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-weight: 600;
}

.brand-logo {
    height: 2.4rem;
    width: auto;
    display: block;
    flex: 0 0 auto;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-line-1 {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
}

.brand-line-2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.app-main {
    flex: 1;
    padding: 1.25rem 0 2rem 0;
}

.app-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1rem;
}

.app-footer {
    border-top: 1px solid var(--star-line);
    padding: 0.85rem 0;
    background: #fff;
    font-size: 0.85rem;
}

.page-header {
    margin-bottom: 1.25rem;
}

/* Forms */
.field {
    display: block;
    margin-bottom: 1rem;
}

.field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
}

.input {
    display: block;
    width: 100%;
    min-height: var(--tap);
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    border: 1px solid var(--star-line);
    border-radius: var(--radius);
    color: var(--star-ink);
    -webkit-appearance: none;
    appearance: none;
}

.input:focus {
    outline: none;
    border-color: var(--star-primary);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15);
}

.input.invalid,
.input.modified.invalid {
    border-color: var(--star-error);
}

.field-error,
.validation-message {
    color: var(--star-error);
    font-size: 0.85rem;
    margin-top: 0.3rem;
    display: block;
}

.serial-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.serial-row .input {
    flex: 1 1 auto;
}

.serial-row .secondary-button {
    flex: 0 0 auto;
}

/* Buttons */
.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0.6rem 1.1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}

.primary-button {
    background: var(--star-primary);
    color: #fff;
    width: 100%;
}

.primary-button:hover:not(:disabled) {
    background: var(--star-primary-dark);
}

.primary-button:disabled,
.secondary-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.secondary-button {
    background: #fff;
    color: var(--star-ink);
    border-color: var(--star-line);
}

.secondary-button:hover:not(:disabled) {
    border-color: var(--star-muted);
}

.button-row {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
}

.button-row .primary-button,
.button-row .secondary-button {
    width: 100%;
}

@media (min-width: 540px) {
    .button-row {
        flex-direction: row;
    }
    .button-row .primary-button,
    .button-row .secondary-button {
        width: auto;
    }
    .primary-button {
        width: auto;
        min-width: 12rem;
    }
}

/* Cover prompt */
.cover-prompt {
    background: var(--star-card);
    border: 1px solid var(--star-line);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.device-card {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--star-line);
    margin-bottom: 1rem;
}

.device-card img {
    width: 5rem;
    height: 5rem;
    object-fit: contain;
    flex: 0 0 auto;
}

.device-meta {
    min-width: 0;
}

.device-model {
    font-weight: 600;
}

.device-serial {
    font-size: 0.85rem;
    color: var(--star-muted);
    word-break: break-all;
}

.cover-prompt .device-card {
    margin-bottom: 0;
}

.prompt-block {
    text-align: center;
    padding: 1rem 0 0.5rem 0;
}

.prompt-step {
    font-size: 0.85rem;
    color: var(--star-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.4rem;
}

.prompt-instruction {
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 0.4rem;
}

.prompt-runtime {
    font-size: 0.85rem;
}

@media (min-width: 540px) {
    .prompt-instruction {
        font-size: 1.6rem;
    }
}

/* Spinner */
.spinner-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 0;
}

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 3px solid var(--star-line);
    border-top-color: var(--star-primary);
    animation: spin 0.9s linear infinite;
}

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

/* Errors */
.error-block {
    background: #fff5f5;
    border: 1px solid #f0c8cf;
    border-left: 4px solid var(--star-error);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    color: var(--star-ink);
    margin-bottom: 1rem;
}

.error-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.error-detail {
    font-size: 0.95rem;
}

/* Blazor template defaults kept for input validation styling */
.valid.modified:not([type=checkbox]) {
    outline: none;
}

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

.blazor-error-boundary {
    background: var(--star-error);
    color: white;
    padding: 1rem;
    border-radius: var(--radius);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}
