/* =============================================================
 * app.css — 全站设计令牌与通用组件
 * 三个页面（home / create / editor）共用这一层。
 * 只放令牌、重置、基础组件；页面专属样式在各自文件里。
 * ============================================================= */

:root {
    /* 品牌 */
    --brand: #6C4CF1;
    --brand-hover: #5B3BE0;
    --brand-soft: #F2EEFE;
    --brand-soft-2: #E6DFFD;
    --brand-ring: rgba(108, 76, 241, .18);

    /* 中性色阶 */
    --ink: #14161A;
    --ink-2: #565C66;
    --ink-3: #8A909B;
    --ink-4: #B4B9C2;

    --line: #E7E9EE;
    --line-2: #D8DCE3;
    --line-3: #C3C9D2;

    --surface: #FFFFFF;
    --surface-2: #F7F8FA;
    --surface-3: #EFF1F4;
    --bg: #FBFAFD;

    /* 语义色 */
    --ok: #0F9D58;
    --ok-soft: #E7F6EE;
    --warn: #E0A008;
    --warn-soft: #FDF4DC;
    --danger: #E0453F;
    --danger-soft: #FCEBEA;

    /* 圆角 */
    --r-xs: 6px;
    --r-sm: 9px;
    --r-md: 13px;
    --r-lg: 18px;
    --r-xl: 24px;
    --r-full: 999px;

    /* 阴影 */
    --sh-1: 0 1px 2px rgba(20, 22, 26, .05);
    --sh-2: 0 3px 10px rgba(20, 22, 26, .06), 0 1px 3px rgba(20, 22, 26, .04);
    --sh-3: 0 10px 30px rgba(20, 22, 26, .09), 0 2px 8px rgba(20, 22, 26, .05);
    --sh-4: 0 24px 70px rgba(20, 22, 26, .16);

    /* 动效 */
    --ease: cubic-bezier(.32, .72, .35, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);

    /* 尺寸 */
    --topbar-h: 58px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* hidden 必须压住任何 display 声明，否则 .flow{display:flex} 会把它顶回来 */
[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure {
    margin: 0;
}

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

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

::selection {
    background: var(--brand-soft-2);
    color: var(--brand-hover);
}

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

/* 滚动条 —— 细、灰、不抢视线 */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--line-2) transparent;
}

*::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--line-2);
    border-radius: var(--r-full);
    border: 2px solid transparent;
    background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--ink-4);
    background-clip: content-box;
}

/* =============================================================
 * 顶栏
 * ============================================================= */

.topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
    position: relative;
    z-index: 40;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 750;
    letter-spacing: -.02em;
    font-size: 15px;
    white-space: nowrap;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand) 0%, #9077FF 100%);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 2px 8px var(--brand-ring);
    flex: none;
}

.topbar-spacer {
    flex: 1;
}

/* =============================================================
 * 按钮
 * ============================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 15px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 560;
    cursor: pointer;
    white-space: nowrap;
    transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease), transform .12s var(--ease);
    user-select: none;
}

.btn:hover {
    background: var(--surface-2);
    border-color: var(--line-3);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 2px 10px var(--brand-ring);
}

.btn-primary:hover {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--ink-2);
}

.btn-ghost:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.btn-sm {
    height: 30px;
    padding: 0 11px;
    font-size: 12.5px;
}

.btn-lg {
    height: 46px;
    padding: 0 26px;
    font-size: 15px;
    border-radius: var(--r-md);
}

.btn-icon {
    width: 34px;
    padding: 0;
    flex: none;
}

/* =============================================================
 * 表单控件
 * ============================================================= */

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.field-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-hint {
    font-size: 11.5px;
    color: var(--ink-3);
    font-weight: 450;
}

.field-value {
    margin-left: auto;
    font-size: 12px;
    font-weight: 650;
    color: var(--brand);
    font-variant-numeric: tabular-nums;
}

.input,
.select {
    height: 36px;
    width: 100%;
    padding: 0 11px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 13.5px;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
    min-width: 0;
}

.select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%238A909B' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 30px;
    cursor: pointer;
}

.input:focus,
.select:focus {
    outline: 0;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
}

.input[type="number"] {
    font-variant-numeric: tabular-nums;
}

/* 滑块 */
.range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    background: transparent;
    cursor: pointer;
    margin: 0;
}

.range::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: var(--r-full);
    background: var(--surface-3);
}

.range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    margin-top: -5.5px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid var(--brand);
    box-shadow: 0 1px 4px rgba(20, 22, 26, .18);
    transition: transform .12s var(--ease);
}

.range::-webkit-slider-thumb:hover {
    transform: scale(1.14);
}

.range::-moz-range-track {
    height: 4px;
    border-radius: var(--r-full);
    background: var(--surface-3);
}

.range::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid var(--brand);
    box-shadow: 0 1px 4px rgba(20, 22, 26, .18);
}

/* 取色器 */
.color-well {
    -webkit-appearance: none;
    appearance: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    flex: none;
    overflow: hidden;
}

.color-well::-webkit-color-swatch-wrapper {
    padding: 3px;
}

.color-well::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
}

.color-well::-moz-color-swatch {
    border: none;
    border-radius: 5px;
}

/* 复选 / 开关 */
.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink-2);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.check input {
    appearance: none;
    width: 17px;
    height: 17px;
    border: 1.5px solid var(--line-3);
    border-radius: 5px;
    background: var(--surface);
    cursor: pointer;
    position: relative;
    transition: background .14s var(--ease), border-color .14s var(--ease);
    flex: none;
    margin: 0;
}

.check input:checked {
    background: var(--brand);
    border-color: var(--brand);
}

.check input:checked::after {
    content: "";
    position: absolute;
    left: 4.5px;
    top: 1.5px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(42deg);
}

/* 分段控件 */
.segmented {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-3);
    border-radius: var(--r-sm);
    gap: 2px;
}

.segmented button {
    border: 0;
    background: transparent;
    padding: 5px 13px;
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 560;
    color: var(--ink-2);
    cursor: pointer;
    transition: background .16s var(--ease), color .16s var(--ease), box-shadow .16s var(--ease);
    white-space: nowrap;
}

.segmented button.is-active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--sh-1);
}

/* =============================================================
 * 通用容器
 * ============================================================= */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 9px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tag-brand {
    background: var(--brand-soft);
    color: var(--brand-hover);
}

.divider {
    height: 1px;
    background: var(--line);
    border: 0;
    margin: 0;
}

/* 像素图放大不模糊 —— 全站统一 */
.pixelated {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* 棋盘格底（透明区可见） */
.checker {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #EDEFF3 25%, transparent 25%, transparent 75%, #EDEFF3 75%),
        linear-gradient(45deg, #EDEFF3 25%, transparent 25%, transparent 75%, #EDEFF3 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
}

/* 工具提示 */
[data-tip] {
    position: relative;
}

[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    background: #22252B;
    color: #fff;
    font-size: 11.5px;
    padding: 5px 9px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 999;
    box-shadow: var(--sh-2);
}

/* 空状态 */
.empty-state {
    display: grid;
    place-items: center;
    gap: 10px;
    color: var(--ink-3);
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
