:root {
    --ink: #fffaff;
    --muted: #d5c4ee;
    --subtle: #e9dcff;
    --line: rgba(255, 232, 255, .18);
    --line-strong: rgba(255, 220, 255, .34);
    --panel: rgba(63, 22, 111, .88);
    --panel-deep: rgba(35, 11, 67, .95);
    --blue: #e879f9;
    --blue-strong: #a855f7;
    --green: #67e8c1;
    --red: #ff8eaa;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    min-width: 1080px;
    margin: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 14% 4%, rgba(255, 255, 255, .3), transparent 22%),
        radial-gradient(circle at 88% 10%, rgba(244, 114, 182, .42), transparent 34%),
        radial-gradient(circle at 48% 105%, rgba(76, 29, 149, .64), transparent 46%),
        linear-gradient(135deg, #bd72ff 0%, #9d5cff 38%, #7c3aed 68%, #a21caf 100%);
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", "Source Han Sans SC", "Noto Sans SC", sans-serif;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
label {
    -webkit-tap-highlight-color: transparent;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 86px;
    padding: 0 26px;
    border-bottom: 1px solid var(--line);
    border-bottom-color: rgba(255, 231, 255, .18);
    background: rgba(80, 28, 139, .48);
    backdrop-filter: blur(16px);
}

.brand-block,
.top-actions,
.page-tab,
.panel-header,
.editor-actions,
.editor-footer,
.save-actions,
.preview-footer,
.background-actions {
    display: flex;
    align-items: center;
}

.brand-block {
    gap: 14px;
}

.brand-link {
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 39px;
    height: 39px;
    place-items: center;
    border: 1px solid rgba(255, 220, 255, .42);
    border-radius: 11px;
    background: linear-gradient(145deg, rgba(232, 121, 249, .44), rgba(109, 40, 217, .34));
    box-shadow: inset 0 1px rgba(255, 255, 255, .09);
    color: #fff0ff;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .5px;
}

.eyebrow {
    margin-bottom: 5px;
    color: #f0abfc;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 2.3px;
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: 1px;
}

.top-actions {
    gap: 12px;
}

.format-badge {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #e2d3f4;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
}

.template-name-badge {
    max-width: 220px;
    overflow: hidden;
    color: #eadbff;
    font-size: 10px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 17px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease, background .18s ease, opacity .18s ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: .4;
}

.button.primary {
    background: linear-gradient(135deg, #ec8bff, #a855f7 58%, #7e22ce);
    box-shadow: 0 10px 26px rgba(168, 85, 247, .34);
    color: #fff;
}

.publish-action {
    border-color: rgba(255, 220, 255, .42);
    background: linear-gradient(135deg, #f0abfc, #c026d3 55%, #7e22ce);
    box-shadow: 0 10px 26px rgba(192, 38, 211, .28);
    color: #fff;
}

.publish-action:hover:not(:disabled) {
    border-color: rgba(255, 240, 255, .72);
}

.button.compact {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 10px;
}

.button.ghost {
    border-color: var(--line-strong);
    background: rgba(72, 30, 122, .46);
    color: #e5d5f7;
}

.button.ghost:hover:not(:disabled) {
    border-color: rgba(240, 171, 252, .6);
    color: #fff6ff;
}

.button.ghost.active {
    border-color: rgba(232, 121, 249, .64);
    background: rgba(168, 85, 247, .24);
    color: #fff0ff;
}

.button.danger-ghost {
    border-color: rgba(198, 91, 108, .18);
    background: rgba(74, 32, 42, .2);
    color: #b68b93;
}

.button.danger-ghost:hover:not(:disabled) {
    border-color: rgba(236, 111, 130, .42);
    color: #ffabb7;
}

.button-icon {
    font-size: 17px;
    line-height: 1;
}

.studio-layout {
    display: grid;
    height: calc(100vh - 86px);
    grid-template-columns: minmax(560px, 1.55fr) minmax(320px, .65fr);
    gap: 14px;
    padding: 14px 18px 18px;
}

.panel {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(74, 29, 134, .88), rgba(34, 11, 66, .95)),
        var(--panel);
    box-shadow: 0 16px 42px rgba(45, 9, 82, .32);
}

.page-tabs {
    display: flex;
    flex: none;
    flex-direction: row;
    gap: 6px;
    min-height: 0;
    padding: 9px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    background: rgba(53, 18, 97, .48);
}

.page-tab {
    width: auto;
    min-width: 0;
    flex: 1 1 0;
    gap: 7px;
    padding: 7px 9px;
    border: 1px solid rgba(246, 211, 255, .13);
    border-radius: 8px;
    background: rgba(79, 34, 133, .38);
    color: #d9c9ed;
    cursor: pointer;
    text-align: left;
    transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.page-tab:hover {
    border-color: rgba(240, 171, 252, .3);
    background: rgba(137, 65, 194, .28);
    color: #fff4ff;
}

.page-tab.active {
    border-color: rgba(240, 171, 252, .58);
    background: linear-gradient(110deg, rgba(192, 92, 228, .42), rgba(107, 33, 168, .3));
    box-shadow: inset 0 -2px #f0abfc;
    color: #fff8ff;
}

.tab-number {
    display: grid;
    width: 24px;
    height: 24px;
    flex: none;
    place-items: center;
    border: 1px solid rgba(246, 211, 255, .2);
    border-radius: 8px;
    background: rgba(43, 14, 78, .66);
    color: #d8b4fe;
    font-size: 9px;
    font-weight: 800;
}

.page-tab.active .tab-number {
    border-color: rgba(240, 171, 252, .54);
    background: rgba(168, 85, 247, .3);
    color: #fff0ff;
}

.tab-copy {
    min-width: 0;
}

.tab-copy strong,
.tab-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-copy strong {
    margin-bottom: 2px;
    font-size: 9px;
    font-weight: 700;
}

.tab-copy small {
    color: #b99bd6;
    font-size: 7px;
    letter-spacing: .2px;
}

.page-tab.active .tab-copy small {
    color: #dfbaff;
}

.editor-annotation {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 12px;
    border-bottom: 1px solid rgba(122, 155, 214, .1);
    background: rgba(122, 54, 174, .22);
}

.annotation-label {
    flex: none;
    padding: 2px 6px;
    border: 1px solid rgba(240, 171, 252, .3);
    border-radius: 5px;
    background: rgba(168, 85, 247, .18);
    color: #f0abfc;
    font-size: 7px;
    font-weight: 800;
    letter-spacing: .5px;
}

.editor-annotation p {
    margin: 0;
    color: #d1bce5;
    font-size: 8px;
    line-height: 1.55;
}

.editor-panel,
.preview-panel {
    display: flex;
    flex-direction: column;
}

.panel-header {
    min-height: 62px;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2 {
    margin: 0;
    overflow: hidden;
    color: #eaf1fd;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-header p {
    margin: 4px 0 0;
    color: #677892;
    font-size: 9px;
}

.edit-mode-badge {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid rgba(94, 177, 139, .18);
    border-radius: 8px;
    background: rgba(33, 87, 67, .18);
    color: #87c6a8;
    font-size: 9px;
    font-weight: 700;
}

.edit-mode-badge i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
}

.rich-toolbar {
    display: flex;
    min-height: 45px;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    background: rgba(47, 16, 87, .86);
    white-space: nowrap;
}

.format-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    flex: none;
    background: rgba(246, 211, 255, .16);
}

.format-button {
    display: inline-grid;
    min-width: 29px;
    height: 29px;
    place-items: center;
    padding: 0 7px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #cbb3e4;
    cursor: pointer;
    font-size: 11px;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.format-button:hover,
.format-button.active {
    border-color: rgba(240, 171, 252, .36);
    background: rgba(168, 85, 247, .22);
    color: #fff2ff;
}

.format-button.strong {
    font-weight: 900;
}

.format-button.italic {
    font-style: italic;
}

.format-button.underline {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.format-button.strike {
    text-decoration: line-through;
}

.format-button.wide {
    width: auto;
    padding: 0 9px;
    font-size: 9px;
}

.format-button.color-button {
    font-size: 9px;
    font-weight: 700;
}

.format-button.color-button.blue {
    color: #7fa9ff;
}

.format-button.color-button.highlight {
    background: rgba(255, 209, 102, .08);
    color: #e3bd6b;
}

.content-form {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.form-section {
    padding: 11px 14px 13px;
    border-bottom: 1px solid rgba(255, 231, 255, .15);
}

.form-section:last-child {
    border-bottom: 0;
}

.form-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f0e1ff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .3px;
}

.section-title::before {
    width: 3px;
    height: 12px;
    border-radius: 3px;
    background: #e879f9;
    content: "";
}

.section-caption {
    color: #b996d2;
    font-size: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.form-field {
    min-width: 0;
}

.form-field.full {
    grid-column: 1 / -1;
}

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
    color: #d2b9e8;
    font-size: 8px;
    font-weight: 700;
}

.field-hint {
    color: #a785c1;
    font-size: 7px;
    font-weight: 400;
}

.rich-input,
.plain-input,
.select-input {
    width: 100%;
    border: 1px solid rgba(247, 215, 255, .2);
    border-radius: 8px;
    outline: none;
    background: rgba(37, 13, 68, .84);
    color: #f3e9ff;
    font-size: 10px;
    line-height: 1.55;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.rich-input {
    min-height: 32px;
    padding: 6px 9px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.rich-input.multiline {
    min-height: 52px;
}

.rich-input.large {
    min-height: 72px;
}

.rich-input:hover,
.plain-input:hover,
.select-input:hover {
    border-color: rgba(240, 171, 252, .42);
}

.rich-input:focus,
.plain-input:focus,
.select-input:focus {
    border-color: rgba(240, 171, 252, .72);
    background: rgba(49, 17, 89, .98);
    box-shadow: 0 0 0 3px rgba(232, 121, 249, .16);
}

.rich-input:empty::before {
    color: #35455e;
    content: attr(data-placeholder);
    pointer-events: none;
}

.rich-input strong,
.rich-input b {
    color: #edf4ff;
    font-weight: 800;
}

.rich-input mark {
    border-radius: 2px;
    background: #ffd166;
    color: #101a2b;
}

.rich-input ul,
.rich-input ol {
    margin: 4px 0;
    padding-left: 18px;
}

.plain-input {
    height: 32px;
    padding: 0 9px;
}

.select-input {
    height: 32px;
    padding: 0 8px;
    cursor: pointer;
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-card {
    overflow: hidden;
    border: 1px solid rgba(247, 215, 255, .15);
    border-radius: 10px;
    background: rgba(50, 18, 91, .52);
}

.item-card-header {
    display: flex;
    min-height: 28px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 6px 3px 9px;
    border-bottom: 1px solid rgba(247, 215, 255, .12);
    background: rgba(94, 42, 145, .3);
}

.item-title {
    color: #d7bcef;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .5px;
}

.item-actions,
.add-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mini-button {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: #ba9bd3;
    cursor: pointer;
    font-size: 10px;
}

.mini-button:hover {
    border-color: rgba(240, 171, 252, .3);
    background: rgba(168, 85, 247, .18);
    color: #fff1ff;
}

.mini-button.danger:hover {
    border-color: rgba(226, 104, 121, .25);
    background: rgba(105, 38, 49, .2);
    color: #ff9eac;
}

.item-body {
    padding: 8px;
}

.add-button {
    display: flex;
    width: 100%;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
    border: 1px dashed rgba(240, 171, 252, .3);
    border-radius: 8px;
    background: rgba(116, 51, 167, .2);
    color: #d8b4fe;
    cursor: pointer;
    font-size: 8px;
    font-weight: 700;
}

.add-button:hover {
    border-color: rgba(240, 171, 252, .6);
    background: rgba(168, 85, 247, .2);
    color: #fff1ff;
}

.empty-list {
    padding: 12px;
    border: 1px dashed rgba(240, 171, 252, .2);
    border-radius: 8px;
    color: #b897d0;
    font-size: 8px;
    text-align: center;
}

.content-form::-webkit-scrollbar,
.page-tabs::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.content-form::-webkit-scrollbar-thumb,
.page-tabs::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 8px;
    background: #263854;
    background-clip: padding-box;
}

.editor-footer {
    min-height: 54px;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 13px 9px 17px;
    border-top: 1px solid var(--line);
    background: rgba(42, 14, 76, .88);
}

.editor-status {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    color: #c5acda;
    font-size: 9px;
}

.editor-status i {
    width: 6px;
    height: 6px;
    flex: none;
    border-radius: 50%;
    background: #52627a;
}

.editor-status.synced {
    color: #8ce8c4;
}

.editor-status.synced i {
    background: var(--green);
}

.editor-status.dirty {
    color: #ffd38a;
}

.editor-status.dirty i {
    background: #efbd67;
}

.editor-status.error {
    color: #ed8c99;
}

.editor-status.error i {
    background: var(--red);
}

.save-actions {
    flex: none;
    gap: 12px;
}

.shortcut-hint {
    color: #a98bc1;
    font-size: 8px;
}

.cursor-position {
    min-width: 64px;
    color: #bc9ed3;
    font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
    font-size: 8px;
    text-align: right;
}

.save-button {
    min-height: 34px;
    padding: 0 15px;
    border-radius: 8px;
    font-size: 10px;
}

.preview-panel {
    background:
        radial-gradient(circle at 50% 28%, rgba(232, 121, 249, .18), transparent 44%),
        linear-gradient(180deg, rgba(67, 24, 119, .9), rgba(33, 10, 63, .96));
}

.preview-heading {
    min-height: 70px;
}

.preview-stage {
    display: grid;
    flex: 1;
    min-height: 0;
    place-items: center;
    padding: 14px;
    overflow: hidden;
}

.phone-frame {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(246, 211, 255, .2);
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(109, 42, 160, .44), rgba(28, 8, 54, .78)),
        #24103e;
}

.phone-frame::before {
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(246, 211, 255, .09);
    border-radius: 10px;
    content: "";
    pointer-events: none;
}

.phone-frame iframe {
    width: auto;
    max-width: calc(100% - 30px);
    height: calc(100% - 26px);
    aspect-ratio: 9 / 16;
    border: 0;
    border-radius: 11px;
    background: #020a18;
    box-shadow: 0 16px 36px rgba(0, 0, 0, .34);
}

.preview-footer {
    min-height: 58px;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 14px 9px 17px;
    border-top: 1px solid var(--line);
}

.background-copy strong,
.background-copy span {
    display: block;
}

.background-copy strong {
    color: #ead8fb;
    font-size: 9px;
}

.background-copy span {
    margin-top: 3px;
    color: #b493cb;
    font-size: 8px;
}

.background-actions {
    flex: none;
    gap: 6px;
}

.upload-label {
    position: relative;
    cursor: pointer;
}

.upload-label input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.icon-button {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: rgba(95, 41, 146, .46);
    color: #dbc3ef;
    cursor: pointer;
    font-size: 15px;
    transition: border-color .18s ease, color .18s ease;
}

.icon-button:hover {
    border-color: rgba(240, 171, 252, .62);
    color: #fff3ff;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 22px;
    z-index: 20;
    max-width: 420px;
    padding: 12px 15px;
    border: 1px solid rgba(240, 171, 252, .45);
    border-radius: 10px;
    background: #4a1a7d;
    box-shadow: 0 12px 38px rgba(0, 0, 0, .4);
    color: #fff2ff;
    font-size: 11px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity .2s ease, transform .2s ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: rgba(235, 101, 122, .45);
    color: #ffbec8;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(3, 8, 18, .84);
    backdrop-filter: blur(10px);
}

.loading-overlay[hidden] {
    display: none;
}

.loading-overlay strong {
    margin-top: 16px;
    font-size: 14px;
}

.loading-overlay span {
    margin-top: 7px;
    color: var(--muted);
    font-size: 10px;
}

.publish-dialog {
    width: min(760px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    padding: 18px;
    overflow-y: auto;
    border: 1px solid rgba(240, 171, 252, .38);
    border-radius: 16px;
    background:
        radial-gradient(circle at 88% 0, rgba(217, 70, 239, .2), transparent 38%),
        #2f1054;
    box-shadow: 0 30px 80px rgba(34, 5, 61, .62);
    color: var(--ink);
}

.publish-dialog::backdrop {
    background: rgba(31, 6, 53, .76);
    backdrop-filter: blur(7px);
}

.publish-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.publish-dialog-head h2 {
    margin: 0;
    font-size: 19px;
}

.publish-dialog-note {
    margin: 10px 0 16px;
    color: #c8addd;
    font-size: 10px;
}

.publish-page-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.publish-page-card {
    min-width: 0;
    padding: 9px;
    border: 1px solid rgba(246, 211, 255, .18);
    border-radius: 12px;
    background: #1f0a36;
}

.publish-page-image {
    display: grid;
    height: min(320px, 38vh);
    place-items: center;
    overflow: hidden;
    border-radius: 8px;
    background: #12061f;
}

.publish-page-image img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.publish-page-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-top: 9px;
    color: #e7d7f5;
    font-size: 10px;
}

.publish-page-summary strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.publish-page-summary span {
    flex: none;
    color: #b998d0;
    font-size: 9px;
}

.publish-page-links {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
}

.loader {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(114, 151, 229, .2);
    border-top-color: #6b9aff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 700px) {
    .publish-page-list {
        grid-template-columns: 1fr;
    }

    .publish-page-image {
        height: min(420px, 52vh);
    }
}

@media (max-width: 1240px) {
    .studio-layout {
        grid-template-columns: minmax(520px, 1.35fr) minmax(300px, .65fr);
        gap: 10px;
        padding: 10px;
    }

    .shortcut-hint,
    .background-copy span,
    .cursor-position {
        display: none;
    }

    .topbar {
        padding: 0 18px;
    }
}

@media (max-height: 720px) {
    .topbar {
        height: 72px;
    }

    .studio-layout {
        height: calc(100vh - 72px);
    }

    .panel-header {
        min-height: 62px;
    }

    .panel-header p {
        display: none;
    }
}
