:root {
    color-scheme: light;
    --canvas: #f0f3f8;
    --paper: #ffffff;
    --result: #f8faff;
    --ink: #192337;
    --muted: #536176;
    --line: #ccd5e3;
    --hover: #e7edf6;
    --accent: #9b3330;
    --accent-hover: #7f2826;
    --selected: #fbeae8;
    --focus: #97413f;
    --on-accent: #ffffff;
    --radius: 12px;
    --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
}

:root[data-theme=dark] {
    color-scheme: dark;
    --canvas: #171c27;
    --paper: #1e2634;
    --result: #202a3a;
    --ink: #f1f3fa;
    --muted: #b6c1d5;
    --line: #44516a;
    --hover: #2b374d;
    --accent: #f4a49b;
    --accent-hover: #ffbaaF;
    --selected: #4a2d32;
    --focus: #f4a49b;
    --on-accent: #351b20;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
.wrap { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 740; letter-spacing: -.025em; }
.brand span {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    background: var(--ink);
    color: var(--paper);
    border-radius: 7px;
    font-family: var(--mono);
    font-size: .95rem;
    font-weight: 650;
}
.intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-block: 36px 23px; }
h1, h2, p { margin: 0; }
h1 {
    font: 400 clamp(2.15rem, 5vw, 3.55rem)/1.05 Georgia, "Times New Roman", serif;
    letter-spacing: -.052em;
}
.intro p { margin-top: 10px; color: var(--muted); }
.language { min-width: 146px; }
.language label { display: block; margin-bottom: 4px; font-size: .875rem; font-weight: 650; }
.select-wrap { position: relative; }
.select-wrap::after {
    position: absolute;
    pointer-events: none;
    right: 15px;
    top: 17px;
    content: '';
    width: 8px;
    height: 8px;
    border: solid var(--muted);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
select {
    appearance: none;
    min-height: 44px;
    width: 100%;
    padding: 6px 32px 6px 12px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}

.workbench {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "source result" "formats formats";
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
}
.editor { display: flex; flex-direction: column; min-width: 0; min-height: 330px; }
.source { grid-area: source; }
.result { grid-area: result; border-inline-start: 1px solid var(--line); border-radius: 0 var(--radius) 0 0; background: var(--result); }
.editor-head, .editor-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 16px;
    padding: 8px 16px;
}
.editor-head { min-height: 60px; border-bottom: 1px solid var(--line); }
.editor-foot { min-height: 54px; border-top: 1px solid var(--line); }
h2 { font-size: 1rem; font-weight: 710; }
.action-group { display: flex; flex-wrap: wrap; gap: 3px; }
.button, .mode {
    color: inherit;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: .3rem .72rem;
    border: 1px solid transparent;
    border-radius: 7px;
    white-space: nowrap;
    font-size: .875rem;
    font-weight: 625;
}
.quiet { color: var(--muted); background: transparent; }
.quiet:hover:not(:disabled), summary:hover { color: var(--ink); background: var(--hover); }
.primary { margin-inline-start: 3px; background: var(--accent); color: var(--on-accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button:disabled { opacity: .55; cursor: default; }
.example { color: var(--accent); }
.count { font-family: var(--mono); font-size: .76rem; color: var(--muted); overflow-wrap: anywhere; }
textarea {
    width: 100%;
    display: block;
    min-height: 220px;
    flex: 1;
    border: 0;
    padding: 17px 18px;
    margin: 0;
    background: transparent;
    color: var(--ink);
    resize: vertical;
    font: 1rem/1.7 system-ui, -apple-system, "Segoe UI", sans-serif;
    overflow-wrap: break-word;
    caret-color: var(--accent);
}
textarea::placeholder { opacity: 1; color: var(--muted); }
textarea:focus-visible { outline-offset: -2px; }
:is(button,select,summary,a):focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); }
:is(button,select,summary,a):focus-visible { outline-offset: 2px; }

.formats { min-width: 0; grid-area: formats; padding: 17px 16px 10px; border-top: 1px solid var(--line); }
.format-head { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; margin-bottom: 12px; }
.language-example { font-family: var(--mono); color: var(--accent); font-size: .85rem; flex-shrink: 0; }
.mode-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.mode {
    min-height: 71px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    justify-content: center;
    align-items: start;
    text-align: start;
    padding: 8px 11px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 650;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.mode:hover { background: var(--hover); }
.mode[aria-pressed=true] { border-color: var(--accent); color: var(--accent); background: var(--selected); }
.mode-example { font: .77rem/1.28 var(--mono); color: var(--muted); }
.extra-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
details { margin-top: 7px; }
summary {
    width: max-content;
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 7px;
    cursor: pointer;
    font-size: .875rem;
    color: var(--muted);
    font-weight: 650;
}
details[open] .extra-grid { padding-block: 3px 9px; }
.feedback {
    min-height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: start;
    flex-wrap: wrap;
    gap: 6px 16px;
    padding: 12px 0;
    font-size: .875rem;
    color: var(--muted);
}
#feedback:not(:empty) { font-weight: 620; color: var(--ink); }
#feedback[data-kind=notice] { color: var(--accent); }
.footer { border-top: 1px solid var(--line); padding-block: 16px 25px; font-size: .875rem; }
a { color: var(--muted); text-underline-offset: .18em; }
a:hover { color: var(--ink); }

@media (max-width: 900px) {
    .mode-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .editor-head, .editor-foot { gap: 3px 10px; padding-inline: 12px; }
}
@media (max-width: 660px) {
    .wrap { width: calc(100% - 28px); }
    .intro { align-items: start; flex-direction: column; gap: 15px; padding-block: 25px 16px; }
    .language { min-width: 145px; }
    .workbench { grid-template-columns: minmax(0, 1fr); grid-template-areas: "source" "formats" "result"; }
    .editor { min-height: 251px; }
    .result { border-inline-start: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
    textarea { min-height: 156px; padding: 13px 14px; }
    .formats { padding: 14px 12px 9px; }
    .mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .mode { min-height: 63px; padding: 8px; }
    .extra-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .button { padding-inline: .55rem; }
    .count { font-size: .75rem; }
}
@media (max-width: 365px) {
    .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
