/* Mini Tools — shared styles */
:root {
    --bg: #ffffff;
    --fg: #0b0b0c;
    --muted: #6b7280;
    --accent: #2563eb;
    --card: #f7f7f8;
    --border: #e5e7eb;
    --sidebar-w: 270px;
    --radius: 14px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0b0c; --fg: #e5e7eb; --muted: #9aa3af; --accent: #60a5fa; --card: #121315; --border: #1f2937;
    }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; background: var(--bg); color: var(--fg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top nav */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
header.site { position: sticky; top: 0; z-index: 20; backdrop-filter: saturate(180%) blur(8px); background: color-mix(in oklab, var(--bg), transparent 10%); border-bottom: 1px solid var(--border); }
.topbar { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent), #fff 40%)); display: grid; place-items: center; color: white; font-weight: 800; }
.links a { color: var(--fg); opacity: .9; margin-left: 12px; }
.links a:hover { opacity: 1; text-decoration: none; }

/* Layout with sidebar */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 20px; max-width: 1200px; margin: 0 auto; padding: 18px 24px 0; }
aside.sidebar { position: sticky; top: 70px; align-self: start; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; max-height: calc(100vh - 86px); overflow: auto; }
.sidebar h2 { margin: 4px 8px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.menu { list-style: none; margin: 0; padding: 0; }
.menu a {
    display: flex; gap: 10px; align-items: center;
    padding: 7px 10px; border-radius: 10px; color: var(--fg); font-size: 15px;
}
.menu a:hover { background: color-mix(in oklab, var(--card), var(--accent) 5%); text-decoration: none; }
.menu a.active { background: color-mix(in oklab, var(--card), var(--accent) 10%); font-weight: 600; }
.menu .soon { opacity: .6; pointer-events: none; }

/* Content area */
main.content { min-width: 0; } /* fix flex overflow */

/* Mobile / Tablet: burger + drawer */
.burger {
    display: none; border: 1px solid var(--border); background: var(--card);
    border-radius: 10px; padding: 8px 10px; cursor: pointer; color: var(--fg);
}
@media (max-width: 960px) {
    header.site .links { display: none; }
    .burger { display: inline-flex; align-items: center; gap: 8px; }
    .layout { grid-template-columns: 1fr; padding: 12px 0 0; }
    .container { padding: 0 16px; }
    aside.sidebar {
        position: fixed; top: 60px; left: 0; bottom: 0; z-index: 40;
        width: min(88vw, 320px); max-height: calc(100vh - 60px);
        transform: translateX(-100%); transition: transform .18s ease;
        border-right: 1px solid var(--border); border-top-left-radius: 0; border-bottom-left-radius: 0;
    }
    body.menu-open aside.sidebar { transform: translateX(0); }
    .backdrop {
        position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,.35);
        opacity: 0; pointer-events: none; transition: opacity .18s ease; z-index: 30;
    }
    body.menu-open .backdrop { opacity: 1; pointer-events: auto; }
}

/* Reuse old hero/grid/card/footer styles */
.hero { padding: 12px 0 8px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(26px, 3.4vw, 40px); line-height: 1.1; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 70ch; }
.notice { margin-top: 14px; padding: 10px 12px; background: color-mix(in oklab, var(--card), var(--accent) 4%); border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(1, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; transition: transform .12s ease, box-shadow .12s ease; }
a.card:hover { transform: translateY(-1px); box-shadow: 0 4px 18px color-mix(in oklab, var(--bg), #000 6%); text-decoration: none; }
.card h3 { margin: 0; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
:root[data-theme="light"] { --bg:#ffffff; --fg:#0b0b0c; --muted:#6b7280; --accent:#2563eb; --card:#f7f7f8; --border:#e5e7eb; }
:root[data-theme="dark"]  { --bg:#0b0b0c; --fg:#e5e7eb; --muted:#9aa3af; --accent:#60a5fa; --card:#121315; --border:#1f2937; }
/* Base form controls (theme-aware) */
button, input, select, textarea { font: inherit; color: var(--fg); }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=time], input:not([type]), select, textarea {
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; max-width: 100%;
}
textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; resize: vertical; }
button { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
button:hover { border-color: color-mix(in oklab, var(--border), var(--accent) 40%); }
button.primary, button[type=submit] { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
pre { overflow: auto; }
/* Action rows inside tool cards */
main .links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
/* Two columns on wide screens, one on mobile */
.cols-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 760px) { .cols-2 { grid-template-columns: 1fr 1fr; } }

.mobile-actions { display: flex; gap: 8px; }
.mobile-actions .mt-theme { margin-left: 0; }
.mt-theme {
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    color: var(--fg);
    margin-left: 20px;
    line-height: 1;
}

/* Skip link (visible on keyboard focus) */
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

/* Sidebar groups */
.sidebar h2:not(:first-child) { margin-top: 16px; }
.menu-icon { width: 1.4em; text-align: center; flex: none; }

/* Breadcrumbs */
.breadcrumbs { font-size: 13px; color: var(--muted); margin: 4px 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumbs a { color: var(--muted); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 14px; border-radius: 10px; background: var(--fg); color: var(--bg); box-shadow: 0 6px 24px rgba(0,0,0,.18); z-index: 999; }

/* Visible FAQ */
.faq { margin-top: 32px; }
.faq h2 { margin: 0 0 10px; }
.faq details { border: 1px solid var(--border); border-radius: 10px; background: var(--card); margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
.faq details p { margin: 0; padding: 0 14px 12px; color: var(--muted); }

/* Related tools */
.related { margin-top: 36px; }
.related h2 { margin: 0; font-size: 20px; }
.related .grid { margin-top: 12px; }

/* Footer */
footer.site { margin-top: 32px; border-top: 1px solid var(--border); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 16px; align-items: center; padding-top: 16px; padding-bottom: 16px; color: var(--muted); font-size: 14px; }
.footer-links { display: flex; gap: 12px; flex-wrap: wrap; }

/* Home: category headings */
.cat-title { margin: 28px 0 0; font-size: 18px; }
.cat-title + .grid { margin-top: 12px; }

/* Unified page headings */
main h1 { margin: 0 0 8px; font-size: clamp(26px, 3.4vw, 36px); line-height: 1.15; letter-spacing: -0.02em; }
main .seo, main article > section { max-width: 80ch; }
main .seo h2, main article > section h2 { font-size: 21px; margin: 28px 0 8px; }
main .seo table, main article > section table { border-collapse: collapse; width: 100%; font-size: 14px; }
main .seo th, main .seo td, main article > section th, main article > section td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
main .seo td, main article > section td { overflow-wrap: anywhere; }

/* `hidden` must win over component display rules */
[hidden] { display: none !important; }

/* Tool search */
.side-search { position: relative; margin: 2px 2px 10px; }
.side-search input { width: 100%; padding-right: 30px; }
.side-search-hint { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.side-search input:focus + .side-search-hint, .side-search input:not(:placeholder-shown) + .side-search-hint { display: none; }
kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; background: var(--bg); color: var(--muted); }
.side-empty { margin: 8px; color: var(--muted); font-size: 14px; }
.home-search { margin-top: 18px; }
.home-search input { width: 100%; max-width: 560px; padding: 12px 14px; font-size: 16px; border-radius: 12px; }

/* Breadcrumbs row with favorite toggle */
.tool-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0 10px; }
.tool-bar .breadcrumbs { margin: 0; }
.fav-btn { padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.fav-btn[aria-pressed="true"] { color: #d97706; border-color: color-mix(in oklab, var(--border), #d97706 45%); }

/* Drag & drop target */
.drop-over { outline: 2px dashed var(--accent); outline-offset: 2px; background: color-mix(in oklab, var(--bg), var(--accent) 6%) !important; }

/* Inline status line under inputs */
.status { font-size: 14px; color: var(--muted); min-height: 1.4em; }
.status.ok { color: #16a34a; }
.status.err { color: #dc2626; }
.hint { font-size: 13px; color: var(--muted); }

/* Read-only output panels */
pre.output { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 60px; background: var(--bg); font-size: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-head .links { gap: 6px; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented label { padding: 7px 12px; cursor: pointer; border-right: 1px solid var(--border); font-size: 14px; }
.segmented label:last-child { border-right: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent); color: #fff; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
table.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
table.kv th, table.kv td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
main .seo td pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
