:root,
html[data-theme="light"] {
    color-scheme: light;
    --ink: #16324a;
    --ink-soft: #5a7388;
    --paper: #eef5fb;
    --paper-strong: #ffffff;
    --muted: #e3eef8;
    --line: #d5e4f0;
    --accent: #3d8fd1;
    --accent-soft: #d9ebf8;
    --on-accent: #ffffff;
    --danger: #c23b3b;
    --ok: #2f7d57;
    --warn: #3d6ea8;
    --rail: #d7e8f6;
    --rail-hover: rgba(29, 74, 110, 0.08);
    --sidebar: #ffffff;
    --shadow: 0 14px 36px rgba(45, 90, 130, 0.08);
    --editor-border: #d5e4f0;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e6e8eb;
    --ink-soft: #9aa3ad;
    --paper: #0b0c0e;
    --paper-strong: #16181c;
    --muted: #121417;
    --line: #2c3036;
    --accent: #c5ccd4;
    --accent-soft: #24282e;
    --on-accent: #0b0c0e;
    --danger: #e06a6a;
    --ok: #7dcea0;
    --warn: #8cb4e0;
    --rail: #050506;
    --rail-hover: rgba(230, 232, 235, 0.08);
    --sidebar: #111316;
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
    --editor-border: #2c3036;
}

.users-view { flex: 1; min-width: 0; overflow: auto; background: var(--paper-strong); }
.users-table-wrap { padding: 24px; overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; text-align: left; }
.users-table th, .users-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.users-table th { color: var(--ink-soft); }
.users-table td button + button { margin-left: 8px; }
.users-table .danger, #user-form-error { color: var(--danger); }
#user-form { display: grid; gap: 18px; }
#user-form label { display: grid; gap: 8px; }
#user-form input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
#user-form small { color: var(--ink-soft); }
.user-form-actions { display: flex; justify-content: flex-end; gap: 10px; }

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: "Outfit", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

h1, h2, h3 {
    margin: 0;
    font-weight: 600;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button, a, .rail-tab, .icon-btn {
    transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

* {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--ink-soft) 45%, transparent) transparent;
}

.app {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
}

.chrome {
    display: flex;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
}

.rail {
    width: 76px;
    background: var(--rail);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 14px 8px;
    gap: 8px;
    flex-shrink: 0;
}

html[data-rail="collapsed"] .rail {
    width: 52px;
    padding: 14px 6px;
}

html[data-rail="collapsed"] .rail span {
    display: none;
}

.rail-brand {
    width: 40px;
    height: 40px;
    display: block;
    overflow: hidden;
    border-radius: 12px;
    text-decoration: none;
    margin: 0 auto 8px;
    flex-shrink: 0;
}

.rail-brand img,
.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rail-tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.rail-tab,
.rail-btn {
    display: grid;
    justify-items: center;
    gap: 4px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    text-decoration: none;
    cursor: pointer;
    padding: 10px 4px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.rail-tab svg,
.rail-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.rail-tab:hover,
.rail-btn:hover {
    background: var(--rail-hover);
    color: var(--ink);
}

.rail-tab.active {
    background: var(--paper-strong);
    color: var(--accent);
    box-shadow: var(--shadow);
}

html[data-theme="dark"] .rail-tab.active {
    color: var(--ink);
    background: var(--accent-soft);
}

.rail-foot {
    display: grid;
    gap: 4px;
}

html[data-rail="collapsed"] .icon-collapse,
html[data-rail="expanded"] .icon-expand,
html[data-theme="light"] .icon-sun,
html[data-theme="dark"] .icon-moon {
    display: none;
}

.subnav {
    width: 228px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 16px 12px 12px;
    color: var(--ink);
}

.subnav-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    gap: 10px;
}

.subnav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.subnav-head h2 {
    font-size: 13px;
    letter-spacing: 0.12em;
    color: var(--ink-soft);
    font-weight: 600;
}

.sub-tabs {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.notes-view {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

.notebook-list,
.note-list,
.api-history {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: auto;
}

.notebook-row,
.note-row,
.history-row {
    display: flex;
    align-items: stretch;
    gap: 2px;
    border-radius: 10px;
    position: relative;
}

.notebook-item,
.note-item,
.api-history-item {
    flex: 1;
    min-width: 0;
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: 10px;
    color: inherit;
    cursor: pointer;
}

.notebook-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 12px;
}

.notebook-item small,
.api-history-item small {
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.notebook-row:hover,
.note-row:hover,
.history-row:hover {
    background: var(--accent-soft);
}

.notebook-row.active,
.note-row.active {
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
}

.note-item {
    padding: 10px 8px 10px 12px;
    display: grid;
    gap: 4px;
}

.note-item h3 {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-item p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 12.5px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-item time {
    font-size: 11px;
    color: var(--ink-soft);
}

.row-actions {
    display: flex;
    align-items: center;
    padding-right: 4px;
    opacity: 0;
    pointer-events: none;
}

.notebook-row:hover .row-actions,
.notebook-row.active .row-actions,
.note-row:hover .row-actions,
.note-row.active .row-actions,
.history-row:hover .row-actions {
    opacity: 1;
    pointer-events: auto;
}

.icon-btn {
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    padding: 0;
    flex-shrink: 0;
}

.icon-btn svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.icon-btn:hover {
    color: var(--ink);
    background: var(--rail-hover);
}

.icon-btn.danger:hover {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.plus-btn {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--ink);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.plus-btn:hover {
    background: var(--accent);
    color: var(--on-accent);
}

.notes-pane {
    background: var(--muted);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pane-head,
.editor-head {
    padding: 16px 18px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.pane-head h2 {
    font-size: 17px;
    font-weight: 600;
}

.pane-head p,
.brand p,
.notes-meta {
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 12.5px;
}

.pane-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.notebook-item .lock-mark {
    width: 14px;
    height: 14px;
    fill: currentColor;
    opacity: 0.7;
    flex-shrink: 0;
}

.notebook-item span {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-list {
    flex: 1;
    padding: 0 8px 12px;
    display: grid;
    align-content: start;
    gap: 2px;
}

[hidden] {
    display: none !important;
}

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px 18px;
    gap: 8px;
}

.pager button,
.ghost-btn,
.primary-btn,
.danger-btn {
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 7px 12px;
    cursor: pointer;
}

.primary-btn.compact {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
}

.pager button,
.ghost-btn {
    background: transparent;
    border-color: var(--line);
    color: inherit;
}

.primary-btn {
    background: var(--accent);
    color: var(--on-accent);
}

.primary-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.danger-btn {
    background: transparent;
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.danger-btn.solid {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.editor-pane {
    background: var(--paper-strong);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.empty-editor {
    margin: auto;
    color: var(--ink-soft);
    text-align: center;
    padding: 40px 28px;
    max-width: 360px;
}

.empty-editor .primary-btn {
    margin-top: 16px;
}

.empty-title {
    color: var(--ink);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px;
}

.editor-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

#note-title {
    flex: 1;
    border: 0;
    background: transparent;
    font-size: 22px;
    font-weight: 600;
    outline: none;
    color: var(--ink);
}

.save-status {
    font-size: 12px;
    color: var(--ink-soft);
    white-space: nowrap;
}

.save-status.is-dirty {
    color: var(--accent);
}

.toolbar {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.editor {
    flex: 1;
    overflow: auto;
}

.w-e-bar,
.w-e-text-container,
.w-e-toolbar,
.w-e-text-container .w-e-scroll {
    background: var(--paper-strong) !important;
    border-color: var(--line) !important;
    color: var(--ink) !important;
}

.w-e-bar svg {
    fill: var(--ink-soft) !important;
}

.w-e-bar {
    padding: 2px 8px !important;
}

.w-e-text-container {
    min-height: 100%;
}

.w-e-text-container [data-slate-editor] {
    padding: 28px 36px 64px !important;
    font-size: 16px;
    line-height: 1.75;
    color: var(--ink);
}

.w-e-text-container table {
    border-collapse: collapse;
    width: 100%;
}

.w-e-text-container td,
.w-e-text-container th {
    border: 1px solid var(--editor-border);
    padding: 8px 10px;
}

.modal {
    border: 0;
    border-radius: 18px;
    padding: 0;
    background: var(--paper-strong);
    color: var(--ink);
    box-shadow: var(--shadow);
    width: min(420px, calc(100vw - 32px));
}

.modal::backdrop {
    background: rgba(10, 16, 24, 0.45);
}

.modal form {
    display: grid;
    gap: 14px;
    padding: 24px;
}

.modal label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-soft);
}

.modal input {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--paper);
    color: var(--ink);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.confirm-text {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.55;
}

.app-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    background: var(--ink);
    color: var(--paper-strong);
    padding: 10px 14px;
    font-size: 13px;
    z-index: 50;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.empty-list {
    color: var(--ink-soft);
    padding: 24px 16px;
    line-height: 1.6;
}

.sidebar-user {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--on-accent);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user button {
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 2px 6px;
}

.sidebar-user button:hover {
    color: var(--ink);
}

#tool-search {
    width: 100%;
    height: 34px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    padding: 0 10px;
    border-radius: 10px;
}

.tool-nav {
    display: grid;
    gap: 10px;
    padding-bottom: 8px;
}

.tool-group {
    border-radius: 14px;
    padding: 10px 10px 8px;
}

.tool-group[data-tone="format"] {
    background: #d7ebfa;
}

.tool-group[data-tone="codec"] {
    background: #d5efe4;
}

.tool-group[data-tone="generate"] {
    background: #f3e4cc;
}

.tool-group[data-tone="daily"] {
    background: #e4ddf5;
}

html[data-theme="dark"] .tool-group[data-tone="format"] {
    background: #1b3144;
}

html[data-theme="dark"] .tool-group[data-tone="codec"] {
    background: #1a322c;
}

html[data-theme="dark"] .tool-group[data-tone="generate"] {
    background: #322918;
}

html[data-theme="dark"] .tool-group[data-tone="daily"] {
    background: #2a2438;
}

.tool-group-title {
    margin: 0 4px 8px;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--ink-soft);
    font-weight: 600;
}

.tool-group-items {
    display: grid;
    gap: 6px;
}

.tool-chip {
    display: block;
    padding: 7px 10px;
    border-radius: 8px;
    background: var(--paper-strong);
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    box-shadow: 0 1px 0 rgba(22, 50, 74, 0.04);
}

.tool-chip:hover {
    border-color: color-mix(in srgb, var(--ink) 12%, transparent);
}

.tool-chip.active {
    background: var(--accent);
    color: var(--on-accent);
    border-color: transparent;
}

.tool-chip.hidden {
    display: none;
}

.tool-head {
    padding: 18px 28px 4px;
}

.tool-head p {
    margin: 6px 0 0;
    color: var(--ink-soft);
}

.login-body {
    display: grid;
    grid-template-rows: 1fr auto;
    place-items: center;
    height: auto;
    min-height: 100%;
    background: var(--paper);
}

.login-beian {
    padding: 16px 16px 24px;
    text-align: center;
    font-size: 13px;
}

.login-beian a {
    color: var(--ink-soft);
    text-decoration: none;
}

.login-beian a:hover,
.login-beian a:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}

.login-card {
    margin: 24px 0;
    width: min(420px, calc(100vw - 32px));
    background: var(--paper-strong);
    padding: 32px;
    border-radius: 22px;
    box-shadow: var(--shadow);
    position: relative;
}

.login-theme {
    position: absolute;
    top: 16px;
    right: 16px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink-soft);
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
}

.brand h1 {
    font-size: 22px;
}

.login-card form {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.login-card label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-soft);
}

.login-card input {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--paper);
    color: var(--ink);
}

.login-error {
    color: var(--danger);
    margin: 0;
}

.login-hint {
    color: var(--ink-soft);
    margin: 0;
    font-size: 13px;
}

.api-history-item {
    padding: 8px 8px 8px 12px;
    display: grid;
    gap: 3px;
}

.api-history-item strong {
    font-size: 10px;
    letter-spacing: 0.06em;
    font-weight: 650;
}

.api-history-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
}

.api-client {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background: var(--paper);
}

.api-composer {
    padding: 16px 22px 10px;
    display: grid;
    gap: 10px;
}

.api-url-bar {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr) auto auto;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: var(--paper-strong);
}

.api-url-bar select,
.api-url-bar input {
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 10px 12px;
    color: var(--ink);
}

.api-url-bar select {
    border-right: 1px solid var(--line);
    font-weight: 650;
    font-size: 13px;
}

.api-url-bar .primary-btn,
.api-url-bar .ghost-btn {
    border-radius: 0;
    height: 100%;
}

.api-url-bar .ghost-btn {
    border: 0;
    border-left: 1px solid var(--line);
    background: transparent;
}

.api-url-bar select.method-get { color: var(--ok); }
.api-url-bar select.method-post { color: var(--warn); }
.api-url-bar select.method-put,
.api-url-bar select.method-patch { color: var(--accent); }
.api-url-bar select.method-delete { color: var(--danger); }

.method-get { color: var(--ok); }
.method-post { color: var(--warn); }
.method-put,
.method-patch { color: var(--accent); }
.method-delete { color: var(--danger); }

.api-kv-row input,
.api-body-type select,
#api-body {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper-strong);
    padding: 10px 12px;
    color: var(--ink);
}

.api-tabs {
    display: flex;
    gap: 6px;
    align-items: center;
}

.api-import-curl {
    margin-left: auto;
}

.curl-modal {
    width: min(640px, calc(100vw - 32px));
}

.curl-modal textarea {
    width: 100%;
    min-height: 180px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
    padding: 10px 12px;
    font-family: "IBM Plex Mono", Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.5;
    resize: vertical;
}

.api-tab {
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.api-tab.active {
    background: var(--paper-strong);
    color: var(--ink);
    box-shadow: var(--shadow);
}

.api-kv {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

.api-kv-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
    gap: 8px;
    align-items: center;
}

.api-body-type {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--ink-soft);
}

#api-body {
    width: 100%;
    min-height: 140px;
    resize: vertical;
    font-family: "IBM Plex Mono", Consolas, monospace;
    font-size: 13px;
}

.api-response {
    margin: 0 22px 18px;
    padding: 14px 16px;
    background: var(--paper-strong);
    border: 1px solid var(--line);
    border-radius: 12px;
    min-height: 0;
    overflow: auto;
}

.api-response-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--ink-soft);
}

.api-status {
    font-weight: 600;
    color: var(--ink-soft);
}

.api-status.is-2xx { color: var(--ok); }
.api-status.is-3xx { color: var(--warn); }
.api-status.is-4xx,
.api-status.is-5xx,
.api-status.is-error { color: var(--danger); }

.api-response-headers,
.api-response-body {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "IBM Plex Mono", Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.55;
}

.api-response-headers {
    color: var(--ink-soft);
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--line);
    min-height: 1.5em;
}

@media (max-width: 720px) {
    .app,
    .notes-view {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        height: auto;
        min-height: 100vh;
        overflow: visible;
        max-height: none;
    }

    .chrome {
        flex-direction: column;
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .rail {
        width: 100%;
        flex-direction: row;
        align-items: center;
        padding: 8px;
    }

    html[data-rail="collapsed"] .rail {
        width: 100%;
    }

    .rail-tabs,
    .rail-foot {
        flex-direction: row;
        flex: 1;
    }

    .rail-brand {
        margin: 0;
        width: 40px;
        flex-shrink: 0;
    }

    .subnav,
    .notes-pane,
    .editor-pane {
        min-height: 240px;
        width: auto;
    }

    .api-url-bar,
    .api-kv-row {
        grid-template-columns: 1fr;
    }
}
