:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e5e7eb;
    --primary: #1468ff;
    --primary-dark: #0b55db;
    --primary-soft: #eff6ff;
    --shadow: 0 14px 40px rgba(15, 23, 42, .07);
    --shell: 1080px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.site-shell {
    width: min(calc(100% - 32px), var(--shell));
    margin-inline: auto;
}

.skip-link {
    position: fixed;
    left: 12px;
    top: -60px;
    z-index: 1000;
    padding: 10px 14px;
    border-radius: 8px;
    background: #111827;
    color: #fff;
}
.skip-link:focus { top: 12px; }

.site-header {
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.97);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.site-branding { display: flex; align-items: center; min-width: 0; }
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    letter-spacing: -.02em;
}
.brand-text { font-size: 20px; }
.brand-icon {
    width: 34px;
    height: 34px;
    padding: 5px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    place-items: center;
    font-size: 9px;
    line-height: 1;
}
.custom-logo-link { display: inline-flex; align-items: center; }
.custom-logo { display: block; width: auto; max-width: 220px; max-height: 46px; }

.main-nav, .main-nav .menu {
    display: flex;
    align-items: center;
    gap: 25px;
    list-style: none;
    padding: 0;
    margin: 0;
}
.main-nav a {
    display: block;
    padding: 21px 0 19px;
    color: #475569;
    font-weight: 600;
    font-size: 14px;
}
.main-nav a:hover,
.main-nav .current-menu-item > a { color: var(--primary); }

.hero {
    padding: 44px 0 28px;
    background: #fff;
}
.hero-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.hero h1 {
    margin: 0;
    text-align: center;
    font-size: clamp(38px, 5vw, 56px);
    line-height: 1.06;
    letter-spacing: -.045em;
}
.hero-subtitle {
    margin: 10px 0 26px;
    text-align: center;
    color: var(--muted);
    font-size: clamp(16px, 2vw, 19px);
}

.calculator {
    width: min(100%, 580px);
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow);
}
.calculator-screen {
    position: relative;
    min-height: 116px;
    margin-bottom: 14px;
    padding: 20px 22px;
    border: 1px solid #dfe5ec;
    border-radius: 12px;
    background: #f9fbfd;
    text-align: right;
    overflow: hidden;
}
.calculator-expression {
    min-height: 26px;
    color: var(--muted);
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.calculator-result {
    display: block;
    margin-top: 5px;
    color: #080f1e;
    font-size: clamp(38px, 7vw, 50px);
    line-height: 1.1;
    font-weight: 720;
    letter-spacing: -.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.calc-key {
    min-height: 64px;
    border: 1px solid #e2e7ed;
    border-radius: 11px;
    background: #fff;
    color: #0b1220;
    box-shadow: 0 2px 5px rgba(15,23,42,.03);
    font-size: 23px;
    cursor: pointer;
    transition: transform .08s ease, background .12s ease, border-color .12s ease;
    touch-action: manipulation;
    user-select: none;
}
.calc-key:hover { background: #f8fafc; border-color: #cfd7e2; }
.calc-key:active,
.calc-key.is-pressed { transform: translateY(1px); background: #f1f5f9; }
.calc-key:focus-visible { outline: 3px solid rgba(20,104,255,.25); outline-offset: 2px; }
.calc-key--utility { font-weight: 600; }
.calc-key--operator { color: var(--primary); background: #fbfdff; font-size: 29px; }
.calc-key--equals {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
    font-size: 30px;
    font-weight: 500;
}
.calc-key--equals:hover { background: var(--primary-dark); border-color: var(--primary-dark); }


.calculator-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: -2px 0 12px;
}
.calc-tool {
    min-height: 34px;
    padding: 4px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.calc-tool:hover { background: #f1f5f9; color: #1e293b; }
.calc-tool:focus-visible { outline: 3px solid rgba(20,104,255,.2); outline-offset: 1px; }
.history-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-grid;
    place-items: center;
    font-size: 11px;
}
.calc-key--operator.is-active {
    border-color: #b8d2ff;
    background: var(--primary-soft);
}
.calculator-history {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 14px;
}
.history-clear {
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
}
.history-clear:hover { color: #dc2626; }
.history-empty {
    padding: 12px 0 4px;
    color: #94a3b8;
    text-align: center;
    font-size: 13px;
}
.history-list {
    display: grid;
    gap: 2px;
    max-height: 230px;
    overflow: auto;
    overscroll-behavior: contain;
}
.history-item {
    width: 100%;
    padding: 8px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    text-align: left;
    cursor: pointer;
}
.history-item:hover { background: #f8fafc; }
.history-expression {
    min-width: 0;
    overflow: hidden;
    color: #64748b;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-result {
    color: #0f172a;
    font-size: 15px;
}
.calculator-status {
    min-height: 18px;
    margin: 6px 2px -5px;
    color: #64748b;
    text-align: center;
    font-size: 12px;
}

.content-section { padding: 6px 0 54px; }
.content-narrow { max-width: 760px; }
.plain-section {
    padding: 28px 0;
    border-top: 1px solid var(--line);
}
.plain-section:first-child { border-top: 0; }
.plain-section h2 {
    margin: 0 0 12px;
    font-size: 23px;
    line-height: 1.25;
    letter-spacing: -.025em;
}
.plain-section p { margin: 0 0 12px; color: #475569; }
.plain-section p:last-child { margin-bottom: 0; }
.keyboard-note {
    margin-top: 16px !important;
    padding: 11px 14px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: #2459a8 !important;
    font-size: 14px;
}
.seo-copy strong { color: #1e293b; }

.faq-section details { border-top: 1px solid var(--line); }
.faq-section details:last-child { border-bottom: 1px solid var(--line); }
.faq-section summary {
    position: relative;
    padding: 15px 36px 15px 0;
    cursor: pointer;
    list-style: none;
    font-weight: 650;
    color: #1e293b;
}
.faq-section summary::-webkit-details-marker { display: none; }
.faq-section summary::after {
    content: "+";
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 22px;
    font-weight: 400;
}
.faq-section details[open] summary::after { content: "−"; }
.faq-section details p { padding: 0 32px 15px 0; font-size: 15px; }

.site-footer {
    border-top: 1px solid var(--line);
    background: #fff;
}
.footer-inner {
    padding: 32px 0 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 200px;
    gap: 70px;
}
.brand--footer .brand-text { font-size: 18px; }
.brand--footer .brand-icon { width: 31px; height: 31px; }
.footer-brand .custom-logo { max-height: 40px; max-width: 190px; }
.footer-brand p {
    max-width: 390px;
    margin: 12px 0 0;
    color: #64748b;
    font-size: 14px;
}
.footer-links { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; font-size: 14px; }
.footer-links strong { margin-bottom: 3px; }
.footer-links a { color: #475569; }
.footer-links a:hover { color: var(--primary); }
.footer-menu { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.footer-bottom { padding: 16px 0 21px; border-top: 1px solid #f1f5f9; color: #64748b; font-size: 13px; }

.generic-page { padding-block: 46px 70px; max-width: 800px; }
.entry h1, .generic-page h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.1; letter-spacing: -.035em; }
.entry-content { color: #334155; }
.primary-link { display: inline-block; margin-top: 15px; color: var(--primary); font-weight: 700; }

@media (max-width: 760px) {
    .site-shell { width: min(calc(100% - 24px), var(--shell)); }
    .header-inner { min-height: 60px; }
    .brand-text { font-size: 18px; }
    .brand-icon { width: 32px; height: 32px; }
    .custom-logo { max-height: 40px; max-width: 180px; }
    .main-nav { gap: 16px; }
    .main-nav a { padding: 18px 0 16px; font-size: 13px; }

    .hero { padding-top: 31px; }
    .hero h1 { font-size: 39px; }
    .hero-subtitle { margin-bottom: 22px; font-size: 16px; }
    .calculator { padding: 11px; border-radius: 15px; }
    .calculator-screen { min-height: 103px; padding: 16px; }
    .calculator-tools { margin-bottom: 10px; }
    .calculator-expression { font-size: 15px; }
    .calc-key { min-height: 59px; font-size: 22px; border-radius: 9px; }
    .calc-key--operator { font-size: 27px; }
    .plain-section { padding: 24px 0; }
    .footer-inner { grid-template-columns: 1fr; gap: 25px; }
}

@media (max-width: 520px) {
    .main-nav { display: none; }
    .hero { padding-top: 26px; }
    .hero h1 { font-size: 33px; }
    .hero-subtitle { max-width: 330px; margin-top: 8px; }
    .calculator { width: 100%; box-shadow: 0 9px 25px rgba(15,23,42,.06); }
    .calculator-grid { gap: 7px; }
    .calc-key { min-height: 56px; }
    .calc-tool { min-height: 32px; padding-inline: 7px; }
    .calculator-result { font-size: 40px; }
    .content-section { padding-bottom: 40px; }
}

@media (max-width: 360px) {
    .site-shell { width: min(calc(100% - 16px), var(--shell)); }
    .hero h1 { font-size: 30px; }
    .hero-subtitle { font-size: 15px; }
    .calculator { padding: 8px; }
    .calculator-grid { gap: 6px; }
    .calc-key { min-height: 52px; font-size: 20px; }
    .calc-key--operator { font-size: 25px; }
    .calculator-screen { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
}
