:root {
    --paper: #f4efe6;
    --paper-deep: #ebe3d4;
    --ink: #1c1915;
    --ink-soft: #4a433a;
    --muted: #8b8175;
    --line: #e0d6c6;
    --card: #fffbf5;
    --cinnabar: #b83a22;
    --cinnabar-hover: #9a2f1c;
    --shadow: 0 18px 40px rgba(48, 32, 18, 0.08);
    --radius: 20px;
    --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --serif: "Noto Serif SC", "Songti SC", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--sans);
    color: var(--ink);
    background: var(--paper);
    min-height: 100vh;
    line-height: 1.6;
}

.paper-grain {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.35;
    background-image:
        radial-gradient(ellipse at top left, rgba(184, 58, 34, 0.08), transparent 42%),
        radial-gradient(ellipse at bottom right, rgba(47, 92, 79, 0.08), transparent 40%);
}

.container {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(16px);
    background: rgba(244, 239, 230, 0.82);
    border-bottom: 1px solid rgba(224, 214, 198, 0.8);
}

.header-inner,
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 76px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--serif);
    font-size: 20px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-text strong {
    font-family: var(--serif);
    font-size: 18px;
    letter-spacing: 0.04em;
}

.brand-text small {
    color: var(--muted);
    font-size: 12px;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(380px, 48vw);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
}

.search-wrap svg {
    width: 18px;
    height: 18px;
    color: var(--muted);
    flex-shrink: 0;
}

.search-wrap input {
    border: 0;
    outline: none;
    background: transparent;
    width: 100%;
    font: inherit;
    color: var(--ink);
}

.ghost-link {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 14px;
}

.ghost-link:hover { color: var(--cinnabar); }

.site-main { padding: 36px 0 72px; }

.hero {
    display: grid;
    gap: 10px;
    margin-bottom: 32px;
}

.eyebrow {
    color: var(--cinnabar);
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.hero h1,
.tool-head h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(32px, 5vw, 48px);
    line-height: 1.2;
}

.lede {
    margin: 0;
    max-width: 42em;
    color: var(--ink-soft);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.tool-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    min-height: 210px;
    display: flex;
    flex-direction: column;
}

.tool-card:hover {
    transform: translateY(-5px);
    border-color: #d2c4ae;
    box-shadow: 0 24px 44px rgba(48, 32, 18, 0.12);
}

.tool-card.hidden { display: none; }

.tool-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
}

.tool-icon svg { width: 22px; height: 22px; }

.cat {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 0.08em;
}

.tool-card h2 {
    margin: 6px 0 8px;
    font-size: 20px;
    font-family: var(--serif);
}

.tool-card p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 14px;
}

.empty-state {
    display: none;
    margin-top: 28px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.tool-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.tool-head p {
    margin: 8px 0 0;
    color: var(--ink-soft);
}

.workspace {
    display: grid;
    gap: 16px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    font-weight: 600;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

label.field {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-soft);
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    color: var(--ink);
}

textarea {
    min-height: 280px;
    resize: vertical;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 13.5px;
    line-height: 1.55;
}

textarea.tall { min-height: 360px; }
textarea.short { min-height: 140px; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 9px 16px;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    background: var(--ink);
    color: var(--paper);
}

.btn:hover { background: #000; }

.btn.secondary {
    background: var(--paper-deep);
    color: var(--ink);
}

.btn.ghost {
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--line);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.check-row,
.option-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    align-items: center;
}

.option-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat {
    background: var(--paper);
    border-radius: 16px;
    padding: 16px;
}

.stat b {
    display: block;
    font-size: 24px;
    font-family: var(--serif);
}

.stat span {
    color: var(--muted);
    font-size: 13px;
}

.result-list {
    display: grid;
    gap: 8px;
}

.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--paper);
    border-radius: 12px;
    padding: 10px 12px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
}

.clocks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.clock {
    background: var(--paper);
    border-radius: 16px;
    padding: 16px;
}

.clock small { color: var(--muted); }
.clock strong {
    display: block;
    margin-top: 4px;
    font-size: 20px;
    font-family: ui-monospace, Consolas, monospace;
}

.range-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

input[type="range"] { width: 100%; }

.error {
    color: var(--cinnabar);
    font-size: 13px;
    min-height: 1.2em;
}

.ok { color: #2F5C4F; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(16px);
    background: var(--ink);
    color: var(--paper);
    padding: 10px 16px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s ease;
    z-index: 20;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

.visit-count strong {
    color: var(--ink);
    font-family: var(--serif);
    font-size: 16px;
    font-weight: 700;
}

.fields-2,
.fields-3 {
    display: grid;
    gap: 12px;
}

.fields-2 { grid-template-columns: 1fr 1fr; }
.fields-3 { grid-template-columns: 1fr 1fr 1fr; }

.swatch {
    height: 132px;
    border-radius: 16px;
    border: 1px solid var(--line);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}

input[type="color"] {
    width: 100%;
    height: 44px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}

.diff-view,
.regex-view {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
    max-height: 520px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    min-height: 180px;
}

.diff-line {
    padding: 1px 10px;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-add { background: #e4f0ea; }
.diff-del { background: #f8e6e1; }
.diff-eq { color: var(--ink-soft); }

.regex-view {
    padding: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.regex-view mark {
    background: #f3d2c4;
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
}

.rmb-result {
    font-family: var(--serif);
    font-size: clamp(22px, 3vw, 32px);
    line-height: 1.45;
    padding: 20px;
    background: var(--paper);
    border-radius: 16px;
    min-height: 92px;
    word-break: break-all;
}

@media (max-width: 980px) {
    .tool-grid { grid-template-columns: repeat(2, 1fr); }
    .split, .clocks, .stats, .fields-2, .fields-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .header-inner { flex-wrap: wrap; padding: 12px 0; }
    .search-wrap { width: 100%; }
    .tool-grid { grid-template-columns: 1fr; }
    .tool-head { flex-direction: column; }
}
