/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #1e293b;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.skip-link {
    position: absolute; top: -100px; left: 0; background: #0f172a; color: #fff; padding: 0.5rem 1rem; z-index: 1000;
}
.skip-link:focus { top: 0; }

/* Header */
.site-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky; top: 0; z-index: 100;
}
.header-inner {
    max-width: 1100px; margin: 0 auto; padding: 0.75rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: #0f172a; }
.logo-text { font-weight: 700; font-size: 1.1rem; }
.site-nav ul { list-style: none; display: flex; gap: 1.5rem; }
.site-nav a { text-decoration: none; color: #475569; font-weight: 500; font-size: 0.9rem; }
.site-nav a:hover { color: #d97706; }

/* Main layout */
main { flex: 1; max-width: 1100px; margin: 0 auto; width: 100%; padding: 0 1.25rem; }

/* Worksheet section */
.worksheet-section { padding: 2rem 0 1.5rem; }
.worksheet-container { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04); padding: 2rem; }
.worksheet-intro h1 { font-size: 1.8rem; font-weight: 700; color: #0f172a; margin-bottom: 0.5rem; }
.subtitle { color: #475569; font-size: 1.05rem; margin-bottom: 1.75rem; max-width: 650px; }

/* Form */
.risk-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-weight: 600; font-size: 0.9rem; color: #334155; }
.label-hint { font-weight: 400; color: #64748b; font-size: 0.8rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
textarea, input[type="text"], select {
    width: 100%; padding: 0.75rem; border: 1px solid #cbd5e1; border-radius: 8px;
    font-size: 0.95rem; font-family: inherit; background: #fff; color: #1e293b;
    transition: border-color 0.15s;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: #d97706; box-shadow: 0 0 0 3px rgba(217,119,6,0.15); }
textarea { resize: vertical; min-height: 100px; }
.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn-primary {
    background: #d97706; color: #fff; border: none; padding: 0.7rem 1.5rem; border-radius: 8px;
    font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: background 0.15s;
}
.btn-primary:hover { background: #b45309; }
.btn-primary:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }
.btn-secondary {
    background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; padding: 0.7rem 1.5rem;
    border-radius: 8px; font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: background 0.15s;
}
.btn-secondary:hover { background: #e2e8f0; }

/* Result panel */
.result-panel { margin-top: 2rem; border-top: 1px solid #e2e8f0; padding-top: 1.5rem; }
.result-panel.hidden { display: none; }
.result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem; }
.result-header h2 { font-size: 1.3rem; font-weight: 700; color: #0f172a; }
.result-actions { display: flex; gap: 0.5rem; }
.btn-icon {
    background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 8px; padding: 0.5rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center; color: #334155;
    transition: background 0.15s;
}
.btn-icon:hover { background: #e2e8f0; }
.brief-content { font-size: 0.95rem; color: #334155; line-height: 1.7; }
.brief-content .risk-badge {
    display: inline-block; padding: 0.25rem 0.75rem; border-radius: 20px; font-weight: 700; font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.risk-badge.low { background: #dcfce7; color: #166534; }
.risk-badge.medium { background: #fef3c7; color: #92400e; }
.risk-badge.high { background: #fee2e2; color: #991b1b; }
.risk-badge.critical { background: #fecaca; color: #7f1d1d; }
.brief-section { margin-bottom: 1.25rem; }
.brief-section h4 { font-weight: 700; color: #0f172a; margin-bottom: 0.4rem; font-size: 1rem; }
.brief-section ul { padding-left: 1.25rem; }
.brief-section li { margin-bottom: 0.3rem; }
.emergency-card { background: #fef3c7; border: 2px dashed #d97706; border-radius: 8px; padding: 1rem; margin-top: 1rem; }
.emergency-card h4 { color: #92400e; }

/* Saved section */
.saved-section { padding: 1.5rem 0 2rem; }
.saved-container h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; color: #0f172a; }
.saved-list { display: flex; flex-direction: column; gap: 0.75rem; }
.empty-state { color: #64748b; font-style: italic; }
.saved-item {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 1rem;
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem;
}
.saved-item p { font-weight: 600; color: #1e293b; }
.saved-item .btn-text { color: #b91c1c; background: none; border: none; cursor: pointer; font-weight: 500; font-size: 0.85rem; }
.btn-text.hidden { display: none; }
#clear-saved { margin-top: 0.75rem; color: #b91c1c; cursor: pointer; background: none; border: none; font-weight: 500; }

/* Support section */
.support-section { padding: 2rem 0 3rem; }
.support-container h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.25rem; color: #0f172a; }
.level-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.level-card { border-radius: 10px; padding: 1.25rem; }
.level-card.level-1 { background: #f0fdf4; border: 1px solid #bbf7d0; }
.level-card.level-2 { background: #fffbeb; border: 1px solid #fde68a; }
.level-card.level-3 { background: #fff7ed; border: 1px solid #fed7aa; }
.level-card.level-4 { background: #fef2f2; border: 1px solid #fecaca; }
.level-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; color: #0f172a; }
.level-card p { font-size: 0.9rem; color: #475569; }
.scenario-block, .mistakes-block { margin-bottom: 1.5rem; }
.scenario-block h3, .mistakes-block h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; color: #0f172a; }
.mistakes-block ul { padding-left: 1.25rem; }
.mistakes-block li { margin-bottom: 0.5rem; }

/* Footer */
.site-footer { background: #fff; border-top: 1px solid #e2e8f0; padding: 1.5rem 1.25rem; margin-top: auto; }
.footer-inner { max-width: 1100px; margin: 0 auto; font-size: 0.85rem; color: #64748b; text-align: center; }
.footer-inner a { color: #d97706; text-decoration: none; }
.footer-links { margin-top: 0.5rem; }

/* Print styles */
@media print {
    .site-header, .site-footer, .saved-section, .support-section, .form-actions, .result-actions, #risk-form, .skip-link { display: none !important; }
    .worksheet-container { box-shadow: none; padding: 0; }
    .result-panel { border-top: none; padding-top: 0; margin-top: 0; }
    body { background: #fff; color: #000; }
    .emergency-card { border: 1px solid #000; background: #fff; }
}

/* Responsive */
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
    .worksheet-container { padding: 1.25rem; }
    .worksheet-intro h1 { font-size: 1.5rem; }
    .header-inner { flex-direction: column; gap: 0.5rem; }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
