/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #faf9f6;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #555;
    --border: #ddd;
    --accent: #b85c38;
    --accent-hover: #9a4a2c;
    --accent-light: #fdf0e8;
    --focus-ring: #b85c38;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius: 8px;
    --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1817;
        --surface: #252220;
        --text: #e8e4e0;
        --text-secondary: #b0a89f;
        --border: #3d3832;
        --accent: #d4845a;
        --accent-hover: #e69a6f;
        --accent-light: #2f2520;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    }
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === SKIP LINK === */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    z-index: 1000;
    text-decoration: none;
    border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { top: 0; }

/* === HEADER === */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 1.1rem;
}
.logo svg { color: var(--accent); flex-shrink: 0; }
.logo-text { white-space: nowrap; }

.site-nav ul {
    list-style: none;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.site-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s, color 0.2s;
}
.site-nav a:hover, .site-nav a:focus-visible {
    color: var(--text);
    border-bottom-color: var(--accent);
}

/* === MAIN LAYOUT === */
main {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px 48px;
    width: 100%;
}

/* === HERO + CALCULATOR === */
.hero-section { margin-bottom: 40px; }
.hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}
.hero-text h1 {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 12px;
    color: var(--text);
}
.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.hero-note {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.calculator-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
}
.calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.calc-header h2 { font-size: 1.3rem; font-weight: 600; }

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s;
    display: flex;
    align-items: center;
}
.btn-icon:hover { background: var(--accent-light); color: var(--accent); }

/* === FORM ELEMENTS === */
.field-group {
    margin-bottom: 16px;
}
.field-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--text);
}
.field-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.input-field, .input-range {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}
.input-field:focus, .input-range:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 1px;
    border-color: var(--accent);
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}
.input-with-unit .input-field { flex: 1; }
.unit {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 28px;
}

.range-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.input-range { flex: 1; padding: 0; height: 6px; accent-color: var(--accent); }
.range-output {
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 48px;
    text-align: right;
    color: var(--accent);
}

/* === RESULTS PANEL === */
.results-panel {
    background: var(--accent-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 20px 0;
    min-height: 100px;
}
.result-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px dotted var(--border);
}
.result-item:last-of-type { border-bottom: none; }
.result-label { font-weight: 500; color: var(--text-secondary); font-size: 0.9rem; }
.result-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    font-family: var(--mono);
}
.result-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-top: 8px;
    border-bottom: none;
    display: block;
}

/* === ACTION BUTTONS === */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-primary, .btn-secondary {
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--accent);
    transition: background 0.2s, color 0.2s;
    font-family: var(--font);
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
    background: transparent;
    color: var(--accent);
}
.btn-secondary:hover { background: var(--accent-light); }
.copy-confirm {
    font-size: 0.85rem;
    color: var(--accent);
    margin-top: 8px;
    min-height: 20px;
}

/* === INFO SECTIONS === */
.info-section {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.info-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
}
.info-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.info-section p, .info-section li {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* Walkthrough */
.walkthrough-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}
.step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.step-number {
    display: inline-block;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 12px;
}
.tape-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.tape-table th, .tape-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.tape-table th {
    background: var(--accent-light);
    font-weight: 600;
    color: var(--text);
}
.tape-table td { color: var(--text-secondary); }
.table-note { font-size: 0.85rem; color: var(--text-secondary); }

/* Mistakes list */
.mistakes-list {
    list-style: none;
    display: grid;
    gap: 16px;
}
.mistakes-list li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}
.mistakes-list strong { color: var(--text); display: block; margin-bottom: 4px; }

/* FAQ */
.faq-list { display: grid; gap: 8px; }
.faq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.faq-item summary {
    padding: 14px 18px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
}
.faq-item summary::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--accent);
    transition: transform 0.2s;
}
.faq-item[open] summary::after { content: '−'; transform: rotate(180deg); }
.faq-item p {
    padding: 0 18px 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.updated-note { font-size: 0.85rem; color: var(--text-secondary); margin-top: 16px; font-style: italic; }

/* === FOOTER === */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: auto;
}
.footer-inner { max-width: 1100px; margin: 0 auto; }
.footer-links { margin-top: 8px; }
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .hero-grid { grid-template-columns: 1fr; }
    .hero-text h1 { font-size: 1.8rem; }
    .header-inner { flex-direction: column; align-items: flex-start; }
    .site-nav ul { gap: 12px; }
    .walkthrough-steps { grid-template-columns: 1fr; }
    .action-buttons { flex-direction: column; }
    .btn-primary, .btn-secondary { width: 100%; text-align: center; }
}

@media (max-width: 480px) {
    main { padding: 20px 12px; }
    .calculator-card { padding: 16px; }
    .hero-text h1 { font-size: 1.5rem; }
}

/* Print styles */
@media print {
    .site-header, .site-footer, .action-buttons, .btn-icon, .skip-link { display: none; }
    body { background: #fff; color: #000; }
    .calculator-card { box-shadow: none; border: 1px solid #ccc; }
    .results-panel { background: #f9f9f9; }
}



/* 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;
}
