:root {
    color-scheme:light dark;
    --bg:light-dark(#f5f7fb,#141922);
    --panel:light-dark(#fff,#202734);
    --text:light-dark(#1b283c,#e8edf5);
    --muted:light-dark(#647084,#a4b1c5);
    --border:light-dark(#dfe5ed,#364253);
    --blue:light-dark(#165dcc,#72a8fa);
    --blue-fill:light-dark(#eaf2ff,#233e65);
    --accent:#175ec9;
    --danger:light-dark(#a82d35,#ff9ca5);
    --shadow:0 8px 26px #12203b08
}
* {
    box-sizing:border-box
}
body {
    margin:0;
    background:var(--bg);
    color:var(--text);
    font:14px/1.55 "Segoe UI",system-ui,sans-serif
}
button,input,select {
    font:inherit
}
button,a,input,select,[contenteditable] {
    -webkit-tap-highlight-color:transparent
}
button {
    cursor:pointer
}
button:disabled {
    cursor:default;
    opacity:.55
}
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,[contenteditable]:focus-visible {
    outline:3px solid var(--blue);
    outline-offset:3px
}
a {
    color:var(--blue)
}
[hidden] {
    display:none!important
}
h1,h2,h3,p {
    margin:0
}
h1 {
    font-size:22px;
    line-height:1.2;
    letter-spacing:-.5px
}
h2 {
    font-size:20px;
    line-height:1.3
}
h3 {
    font-size:18px;
    line-height:1.4
}
p+p {
    margin-top:12px
}
.app-shell {
    max-width:1180px;
    margin:auto;
    padding:28px
}
.app-header {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    padding-bottom:26px
}
.brand {
    display:flex;
    gap:12px;
    align-items:center
}
.brand-mark {
    display:grid;
    place-items:center;
    width:44px;
    height:44px;
    flex:0 0 44px;
    background:var(--accent);
    color:#fff;
    border-radius:12px;
    font-size:24px;
    font-weight:700
}
.eyebrow {
    display:block;
    color:var(--muted);
    font-size:11px;
    letter-spacing:1px;
    text-transform:uppercase;
    margin-bottom:3px
}
.welcome {
    max-width:640px;
    margin:38px auto;
    padding:38px;
    background:var(--panel);
    border:1px solid var(--border);
    border-radius:18px;
    box-shadow:var(--shadow)
}
.section-label {
    color:var(--blue);
    font-size:11px;
    letter-spacing:1.1px;
    font-weight:600
}
.welcome h2 {
    font-size:32px;
    letter-spacing:-.8px;
    margin:14px 0
}
.welcome p {
    margin:18px 0;
    max-width:490px
}
.button {
    border:1px solid var(--border);
    background:var(--panel);
    color:var(--text);
    border-radius:7px;
    padding:9px 14px;
    font-weight:600;
    min-height:38px
}
.button:hover:not(:disabled) {
    border-color:var(--blue);
    background:var(--blue-fill)
}
.button.primary {
    background:var(--accent);
    color:#fff;
    border-color:var(--accent)
}
.button.primary:hover:not(:disabled) {
    background:#104ba4
}
.button.subtle {
    background:transparent;
    border-color:transparent;
    font-weight:400
}
.button.danger {
    color:var(--danger)
}
.small {
    font-size:12px
}
.muted {
    color:var(--muted)
}
.user-bar {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    font-size:12px;
    margin-bottom:10px
}
.tabs {
    display:flex;
    gap:6px;
    flex-wrap:wrap;
    border-bottom:1px solid var(--border);
    padding-bottom:12px;
    margin-bottom:24px
}
.tab {
    border:0;
    background:transparent;
    color:var(--muted);
    padding:8px 14px;
    border-radius:7px;
    font-weight:600
}
.tab.active {
    background:var(--accent);
    color:#fff
}
.section-heading {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:16px;
    margin-bottom:20px
}
.section-heading p {
    margin-top:5px
}
.toolbar {
    display:flex;
    align-items:center;
    gap:10px;
    margin-bottom:16px
}
.search-label {
    flex:1
}
.toolbar select {
    max-width:220px
}
input:not([type=checkbox]),select {
    display:block;
    width:100%;
    min-height:40px;
    border:1px solid var(--border);
    border-radius:7px;
    background:var(--panel);
    color:var(--text);
    padding:9px 11px;
    min-width:0
}
label {
    display:block;
    font-weight:600;
    margin-bottom:6px
}
.toolbar label {
    margin:0
}
.toolbar .button {
    white-space:nowrap
}
.library-layout {
    display:grid;
    grid-template-columns:minmax(230px, .85fr) minmax(0,1.55fr);
    gap:22px;
    align-items:start
}
.template-list {
    display:flex;
    flex-direction:column;
    gap:8px
}
.template-entry {
    width:100%;
    text-align:left;
    border:1px solid var(--border);
    border-radius:10px;
    padding:14px 16px;
    background:var(--panel);
    color:var(--text);
    display:block;
    overflow-wrap:anywhere
}
.template-entry:hover,.template-entry.selected {
    border-color:var(--blue)
}
.template-entry.selected {
    background:var(--blue-fill);
    box-shadow:inset 3px 0 var(--blue)
}
.template-entry strong {
    display:block;
    font-size:14px;
    font-weight:600
}
.template-entry span {
    display:block;
    font-size:12px;
    color:var(--muted);
    margin-top:4px
}
.template-entry .excerpt {
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    overflow:hidden
}
.detail-panel {
    background:var(--panel);
    border:1px solid var(--border);
    border-radius:12px;
    padding:24px;
    min-width:0;
    box-shadow:var(--shadow)
}
.detail-heading {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    flex-wrap:wrap;
    margin-bottom:14px
}
.badge {
    display:inline-block;
    background:var(--blue-fill);
    color:var(--blue);
    border-radius:5px;
    padding:3px 8px;
    font-size:11px;
    font-weight:600
}
.mail-content {
    overflow-wrap:anywhere;
    padding:22px 0;
    margin:12px 0;
    border-block:1px solid var(--border);
    min-height:140px
}
.mail-content p {
    margin:0 0 12px
}
.mail-content a {
    color:var(--blue)
}
.mail-content ul,.mail-content ol {
    padding-left:24px
}
.action-row {
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-top:16px
}
.empty-state {
    text-align:center;
    padding:40px 18px;
    color:var(--muted)
}
.empty-state h3 {
    color:var(--text);
    margin-bottom:9px
}
.empty-symbol {
    font-size:34px;
    color:var(--blue);
    display:block;
    margin-bottom:12px
}
#result-count {
    margin-bottom:8px
}
.notice {
    padding:12px 16px;
    border:1px solid var(--border);
    border-left:4px solid var(--blue);
    border-radius:8px;
    background:var(--panel);
    margin-bottom:18px;
    overflow-wrap:anywhere
}
.notice.error {
    border-left-color:var(--danger);
    color:var(--danger)
}
#editor-form>label {
    margin-top:15px
}
.required {
    color:var(--blue)
}
.editor-box {
    border:1px solid var(--border);
    border-radius:8px;
    overflow:hidden
}
.format-toolbar {
    display:flex;
    flex-wrap:wrap;
    gap:4px;
    padding:6px;
    background:var(--bg);
    border-bottom:1px solid var(--border)
}
.format-button {
    background:transparent;
    color:var(--text);
    border:0;
    border-radius:4px;
    padding:6px 12px;
    min-width:34px
}
.format-button:hover {
    background:var(--blue-fill)
}
.rich-editor {
    min-height:210px;
    padding:14px;
    overflow-wrap:anywhere
}
.rich-editor p {
    margin:0 0 12px
}
.field-error {
    color:var(--danger);
    font-size:12px;
    display:block;
    margin-top:4px
}
.checkbox-label {
    display:flex;
    gap:10px;
    align-items:center;
    font-weight:400;
    margin:14px 0
}
.checkbox-label input {
    accent-color:var(--accent);
    width:17px;
    height:17px;
    flex:0 0 17px
}
.app-footer {
    padding-top:30px;
    color:var(--muted);
    font-size:11px;
    text-align:center
}
.sr-only {
    position:absolute;
    width:1px;
    height:1px;
    padding:0;
    margin:-1px;
    overflow:hidden;
    clip:rect(0,0,0,0);
    white-space:nowrap;
    border:0
}
dialog {
    border:1px solid var(--border);
    border-radius:14px;
    padding:26px;
    background:var(--panel);
    color:var(--text);
    max-width:560px;
    width:calc(100% - 32px);
    box-shadow:0 16px 70px #0004
}
dialog::backdrop {
    background:#11182780
}
dialog h2 {
    margin-bottom:14px
}
dialog p {
    overflow-wrap:anywhere
}
#admin-panel {
    max-width:650px
}
@media(max-width:760px) {
    .app-shell {
        padding:20px
    }
    .library-layout {
        grid-template-columns:1fr
    }
    .section-heading {
        align-items:flex-start;
        flex-direction:column
    }
    .toolbar {
        flex-wrap:wrap
    }
    .search-label {
        flex-basis:100%
    }
    .toolbar>label:not(.search-label) {
        flex:1
    }
    .toolbar select {
        max-width:none
    }
    .detail-panel {
        padding:18px
    }
    .welcome {
        margin:16px 0;
        padding:24px
    }
    .welcome h2 {
        font-size:28px
    }
    .app-header {
        flex-wrap:wrap
    }
    .app-header h1 {
        font-size:21px
    }
    .tabs {
        gap:2px
    }
    .tab {
        padding:8px 10px
    }
}
@media(max-width:380px) {
    .app-shell {
        padding:14px
    }
    .toolbar .button {
        padding-inline:9px
    }
    .detail-panel {
        padding:14px
    }
    .welcome {
        padding:20px
    }
    .welcome h2 {
        font-size:25px
    }
    .action-row .button {
        flex:1 1 auto
    }
}
@media(prefers-reduced-motion:no-preference) {
    button {
        transition:background-color .12s,border-color .12s
    }
}
.detail-back {
    display:none;
    margin:0 0 14px -8px
}
@media(max-width:760px) {
    .show-detail .list-column,.show-detail>.toolbar {
        display:none
    }
    .show-detail .detail-back {
        display:inline-block
    }
}

.account-form { max-width:460px; margin-top:24px; text-align:left }
.account-form .button,.management-card>.button { margin-top:18px }
.account-form .small { margin-top:12px }
.management-card { background:var(--panel); border:1px solid var(--border); border-radius:16px; padding:22px; margin:18px 0; min-width:0; overflow-wrap:anywhere }
.management-card h3 { margin-bottom:10px }
.management-card .action-row { margin-top:16px }
.user-bar { flex-wrap:wrap; gap:10px }
@media(max-width:480px) { .management-card { padding:16px } }
.account-form input+label { margin-top:16px }
