:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f9fafb;
    --card-bg: #ffffff;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
}

body.dark-mode {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    line-height: 1.6; 
    transition: background 0.3s ease; 
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    letter-spacing: -0.01em;
}
.container { max-width: 800px; margin: 0 auto; padding: 0 1.5rem; }

header { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 0.75rem 0; }
nav { display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; }
.logo svg { flex-shrink: 0; }

.hero { text-align: center; padding: 4rem 0 3rem; }
h1 { font-size: 3rem; font-weight: 800; margin-bottom: 0.75rem; transition: opacity 0.3s; letter-spacing: -0.025em; }
.hero-sub { font-size: 1.25rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.hook-line {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
    animation: fadeIn 0.8s ease-out;
}
.trust-bar { display: inline-flex; align-items: center; gap: 0.75rem; color: var(--text-muted); font-size: 0.875rem; border: 1px solid var(--border); padding: 0.25rem 0.75rem; border-radius: 99px; }
.trust-bar span:not(:last-child)::after { content: "·"; margin-left: 0.75rem; opacity: 0.5; }

.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.input-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.input-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; }

.step-nav {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}
.step-item {
    padding-bottom: 0.75rem;
    font-weight: 600;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}
.step-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.step-item:disabled { opacity: 0.4; cursor: not-allowed; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.tab-btn { background: none; border: none; padding: 0.5rem 1rem; font-size: 0.875rem; color: var(--text-muted); border-radius: 6px; cursor: pointer; transition: 0.2s; }
.tab-btn.active { background: var(--bg); color: var(--primary); font-weight: 600; }
.tab-btn:hover:not(.active) { background: var(--border); color: var(--text); }

.input-wrapper { position: relative; display: flex; }
input, select { width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg); color: var(--text); font-size: 1rem; transition: border-color 0.2s; appearance: none; -webkit-appearance: none; }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1rem; padding-right: 2.5rem; }

#paste-btn { position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: var(--text-muted); cursor: pointer; height: 32px; width: 32px; display: flex; align-items: center; justify-content: center; }

.actions { display: flex; gap: 1rem; }
button { min-height: 44px; padding: 0 1.5rem; border-radius: 8px; font-weight: 600; cursor: pointer; transition: opacity 0.2s, transform 0.1s; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
button:active { transform: scale(0.98); }

button.primary-btn:hover { background: var(--primary-hover); }
button.secondary-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.primary-btn { 
    background: linear-gradient(135deg, #2563eb, #1d4ed8); 
    color: white; 
    border: none; 
    flex: 2; 
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}
.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.secondary-btn { background: transparent; border: 1px solid var(--border); color: var(--text); flex: 1; }

.skeleton { min-height: 250px; background: var(--border); border-radius: var(--radius); margin: 2rem 0; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.8; } }

.result-card { display: flex; flex-direction: column; gap: 1.25rem; text-align: center; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin: 2rem 0; width: 100%; }
.insight-headline {
    font-size: 1.15rem;
    font-weight: 600;
    color: #ef4444;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 8px;
}
#result-text {
    font-variant-numeric: tabular-nums;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.keep-rate-line {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    margin-top: 0.25rem;
}

.insight-line {
    margin-top: 1.5rem;
    font-weight: 500;
    color: var(--primary);
}

.result-breakdown {
    width: 100%;
    text-align: left;
}
.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.result-note {
    margin-top: 1.5rem;
    font-size: 0.85rem;
}

.reverse-cta { margin-top: 1rem; }
.reverse-cta .secondary-btn { width: 100%; }

/* Breakdown table styling */
.breakdown-table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}
.breakdown-table td:last-child {
    text-align: right;
    white-space: nowrap;
}
.breakdown-table .total-row td {
    border-bottom: none;
    padding-top: 0.6rem;
}

.badge { display: inline-block; padding: 0.25rem 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: 99px; font-size: 0.75rem; margin-top: 1rem; }

.export-tools { display: flex; justify-content: center; gap: 0.75rem; margin: 1.5rem 0; }
.icon-btn { width: 44px; height: 44px; background: var(--card-bg); border: 1px solid var(--border); color: var(--text); padding: 0; }
.icon-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }

.feedback-row { border-top: 1px solid var(--border); padding-top: 1.5rem; margin-top: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.feedback-btns { display: flex; gap: 0.75rem; }
.fb-btn { height: 40px; padding: 0 1rem; background: transparent; border: 1px solid var(--border); color: var(--text); font-size: 0.875rem; }

.error-text { color: #ef4444; font-size: 0.875rem; margin-top: 0.75rem; text-align: center; }

#result-area {
    min-width: 0;
}
.compare-box { 
    margin-top: 1.5rem; 
    text-align: center; 
    padding: 1rem 0;
}

.bmc-btn { background: #FFDD00; color: #000; padding: 0.75rem 1.5rem; border-radius: 12px; text-decoration: none; font-weight: 700; margin-top: 2rem; display: inline-flex; align-items: center; gap: 0.5rem; }
.tagline { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem; }

.history-section { margin-top: 3rem; }
.section-title { font-size: 1rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.chips-container { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { padding: 0.4rem 0.8rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: 99px; font-size: 0.8rem; cursor: pointer; transition: all 0.2s; }
.chip {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: rgba(37, 99, 235, 0.05); transform: translateY(-1px); }

.content-seo { padding: 4rem 0; }
.seo-text h2 { font-size: 1.75rem; margin-bottom: 1.25rem; font-weight: 700; }
.seo-text h3 { font-size: 1.25rem; margin: 2rem 0 1rem; font-weight: 600; }
.seo-text p { color: var(--text-muted); margin-bottom: 1rem; }

.icon-btn svg, .primary-btn svg, .secondary-btn svg {
    transition: transform 0.2s ease;
}
.icon-btn:hover svg, .primary-btn:hover svg {
    transform: scale(1.1);
}

#sticky-cta {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
    display: none;
}

@media (max-width: 600px) {
    #sticky-cta.show {
        display: flex;
    }
}

.faq-section { margin-top: 3rem; }
.faq-section h3 { margin-bottom: 1.5rem; }
details { border-bottom: 1px solid var(--border); padding: 1rem 0; cursor: pointer; }
summary { font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details p { margin-top: 0.75rem; color: var(--text-muted); }

.link-grid { 
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 4rem; 
    padding: 2rem; 
    background: var(--card-bg); 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
}
.grid-item { border-right: 1px solid var(--border); padding-right: 1rem; }
.grid-item:last-child { border-right: none; padding-right: 0; }
.grid-item h4 { 
    margin-bottom: 1rem; 
    font-size: 0.8rem; 
    color: var(--text); 
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}
.grid-item a { display: block; color: var(--text-muted); text-decoration: none; font-size: 0.875rem; margin-bottom: 0.35rem; }
.grid-item a:hover { color: var(--primary); text-decoration: underline; }

footer { margin-top: 5rem; padding: 3rem 0; border-top: 1px solid var(--border); background: var(--card-bg); }
.footer-content { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2rem; align-items: start; }
.footer-brand { display: flex; flex-direction: column; gap: 1rem; }
.footer-tools-links { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; }
.footer-tools-links a { color: var(--text-muted); text-decoration: none; }
.footer-tools-links a:hover { color: var(--primary); }
.footer-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; margin-left: 1.5rem; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.875rem; }

/* Iframe Embedding Utility */
body.is-iframe header, 
body.is-iframe footer, 
body.is-iframe .hero, 
body.is-iframe .content-seo, 
body.is-iframe .history-section, 
body.is-iframe .faq-section, 
body.is-iframe .link-grid, 
body.is-iframe #sticky-cta {
    display: none !important;
}
body.is-iframe main { padding: 0; }
body.is-iframe .card { border: none; box-shadow: none; padding: 0; }

@media (max-width: 600px) {
    h1 { font-size: 1.8rem; }
    .actions { flex-direction: column; }
    .link-grid { grid-template-columns: 1fr; }
    .grid-item { border-right: none; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 1.5rem; }
    .grid-item:last-child { border-bottom: none; padding-bottom: 0; }
    .footer-grid { flex-direction: column; text-align: center; }
    .footer-links a { margin: 0 0.5rem; }
}

/* KPI Display Cards */
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
}
.primary-metric {
    grid-column: span 1;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid var(--primary, #2563eb);
}
.metric-card {
    padding: 1.25rem;
    border-radius: 8px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.dark-mode .metric-card { background: #1e293b; }
.metric-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-value { font-size: 1.6rem; font-weight: 600; color: var(--text); }
.keep-rate-line { font-weight: 600; font-size: 1.2rem; margin: 1rem 0; text-align: center; color: var(--primary); width: 100%; }

/* Visualization Metric Rows Framework */
.viz-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
}
.dark-mode .viz-container {
    background: #1e293b;
    border-color: #334155;
}
.viz-row {
    display: grid !important;
    grid-template-columns: 45px 1fr 55px !important;
    align-items: center;
    gap: 1rem;
    width: 100%;
}
.viz-label { font-weight: 500; font-size: 0.9rem; color: var(--text); text-align: left; width: auto; }
.viz-bar-bg { width: 100%; height: 14px; background: #e2e8f0; border-radius: 7px; overflow: hidden; position: relative; }
.dark-mode .viz-bar-bg { background: #334155; }
.viz-bar-fill { height: 100%; border-radius: 7px; transition: width 0.4s ease; }
.viz-bar-fill.keep { background: #10b981; }
.viz-bar-fill.tax { background: #f43f5e; }
.viz-percent { text-align: right; font-weight: 600; font-size: 0.9rem; color: var(--text); width: auto; }

/* Footer Adaptive Grid */
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; text-align: center; }
@media (min-width: 600px) {
    .footer-grid { grid-template-columns: auto 1fr; text-align: left; }
    .footer-links { justify-self: end; display: grid; grid-auto-flow: column; gap: 1.5rem; }
    .footer-links a { margin-left: 0; }
}
