/* ============================================================
   GLOBAL RESET & BASE
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #1e1e2e;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    color: #ddd;
    user-select: none;
}

/* ============================================================
   MAIN CONTAINER
   ============================================================ */
.app-container {
    width: 100%;
    max-width: 780px;
    background: #2d2d3f;
    border-radius: 16px;
    padding: 28px 32px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: box-shadow 0.3s;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.app-header .logo {
    font-size: 28px;
}
.app-header h1 {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #f6d5f7, #fbe9d2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================================
   FIELD GROUP
   ============================================================ */
.field-group {
    margin-bottom: 18px;
}
.field-group .field-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    color: #b0b8cc;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.field-group .field-label .hint {
    color: rgba(255, 255, 255, 0.25);
    font-weight: 400;
    font-size: 12px;
}
.field-group .field-label .label-with-tip {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.field-group .field-label .label-with-tip .tip {
    font-weight: 400;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.2px;
}

/* ============================================================
   TEXT INPUT
   ============================================================ */
.text-input {
    width: 100%;
    padding: 12px 16px;
    background: #1a1a2e;
    border: 1px solid #3a3a5a;
    border-radius: 10px;
    color: #e8edf5;
    font-size: 15px;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    font-family: inherit;
}
.text-input:focus {
    border-color: #6c8cff;
    box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.12);
}
.text-input::placeholder {
    color: rgba(255, 255, 255, 0.18);
}

.input-hint {
    font-size: 12.5px;
    color: #f0a070;
    margin-top: 8px;
    padding: 6px 14px;
    background: rgba(240, 160, 112, 0.07);
    border-radius: 8px;
    border: 1px solid rgba(240, 160, 112, 0.12);
    display: none;
    align-items: center;
    gap: 8px;
}
.input-hint.show {
    display: flex;
}
.input-hint .hint-icon {
    font-size: 14px;
}

/* ============================================================
   MODE TOGGLE
   ============================================================ */
.mode-toggle {
    display: flex;
    gap: 6px;
    background: #1a1a2e;
    border-radius: 10px;
    padding: 4px;
    border: 1px solid #3a3a5a;
    width: fit-content;
}
.mode-toggle .mode-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #8a9bb5;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    font-family: inherit;
}
.mode-toggle .mode-btn.active {
    background: #3a4a7a;
    color: #fff;
    box-shadow: 0 4px 12px rgba(58, 74, 122, 0.35);
}
.mode-toggle .mode-btn:hover:not(.active) {
    color: #c8d0e0;
}

/* ============================================================
   COLOR BAR (顶部触发器 + 渐变条 + 色标)
   ============================================================ */
.color-bar-wrap {
    position: relative;
    margin: 10px 0 6px;
    padding: 0 0 22px;
}

/* ---- 顶部起点/终点触发器 ---- */
.top-colors {
    position: relative;
    height: 32px;
    margin-bottom: 6px;
}
.color-picker-trigger {
    position: absolute;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    z-index: 5;
}
.color-picker-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.color-picker-trigger:active {
    transform: scale(0.85);
    transition-duration: 0.08s;
}
.color-picker-trigger.start {
    left: 0;
    background: #a6c0fe;
}
.color-picker-trigger.end {
    right: 0;
    background: #e284c2;
}

/* ---- 渐变条 ---- */
.color-bar-track {
    position: relative;
    height: 34px;
    border-radius: 18px;
    overflow: visible;
    background: #1a1a2e;
    border: 2px solid #3a3a5a;
    cursor: pointer;
}
.color-bar-track .gradient-bg {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    transition: background 0.2s;
}

/* ---- 色标 (下方) ---- */
.stops-container {
    position: relative;
    height: 30px;
    margin-top: 2px;
    width: 100%;
}

.stop-pin {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    cursor: grab;
    z-index: 20;
    transition: filter 0.2s;
    touch-action: none;
}
.stop-pin:hover {
    filter: brightness(1.15);
}
.stop-pin:active {
    cursor: grabbing;
}
.stop-pin .pin-body {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2.5px solid #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stop-pin.dragging .pin-body {
    transform: scale(1.22);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

/* ---- 单色模式色条 ---- */
.color-bar-track.single .gradient-bg {
    background: #6c8cff;
}

/* ============================================================
   BOTTOM COLOR LIST (色标列表)
   ============================================================ */
.color-list {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-top: 6px;
    padding: 8px 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}
.color-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    padding: 4px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: border-color 0.2s;
    min-width: 0;
}
.color-item:hover {
    border-color: rgba(255, 255, 255, 0.06);
}
.color-item .item-swatch {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s;
}
.color-item .item-swatch:hover {
    transform: scale(1.05);
}
.color-item .item-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.color-item .item-text {
    font-size: 10px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.color-item .pos-input {
    width: 100%;
    background: #1a1a2e;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    color: #c8d0e0;
    text-align: center;
    font-size: 11px;
    padding: 1px 2px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    -moz-appearance: textfield;
}
.color-item .pos-input::-webkit-outer-spin-button,
.color-item .pos-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.color-item .pos-input:focus {
    border-color: #6c8cff;
    background: #222244;
}

/* ============================================================
   PRESET AREA
   ============================================================ */
#presetGroup {
    transition: opacity 0.25s ease, max-height 0.3s ease, margin 0.3s ease;
    overflow: hidden;
    max-height: 100px;
    opacity: 1;
    margin-bottom: 18px;
}
#presetGroup.hidden {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    pointer-events: none;
}
.preset-area {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: 4px 0 2px;
}
.preset-btn {
    padding: 7px 22px;
    border-radius: 30px;
    border: none;
    background: #1e2f4a;
    color: #c8d0e0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    font-family: inherit;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}
.preset-btn:hover {
    background: #2d4a7a;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(45, 74, 122, 0.3);
}
.preset-btn .gradient-text {
    background: linear-gradient(90deg, #a6c0fe, #b5b1ef, #c4a2e0, #e284c2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.preset-btn:hover .gradient-text {
    filter: brightness(1.15);
}

/* ============================================================
   PREVIEW
   ============================================================ */
.preview-box {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 16px 20px;
    min-height: 54px;
    border: 1px solid #3a3a5a;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    font-size: 20px;
    line-height: 1.6;
    color: #e8edf5;
    word-break: break-all;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* ============================================================
   OUTPUT
   ============================================================ */
.output-wrapper {
    display: flex;
    gap: 12px;
    align-items: stretch;
}
.output-box {
    flex: 1;
    background: #121224;
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid #3a3a5a;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    color: #b8c8e8;
    word-break: break-all;
    min-height: 46px;
    max-height: 110px;
    overflow-y: auto;
    user-select: text;
    line-height: 1.6;
}
.output-box::-webkit-scrollbar {
    width: 4px;
}
.output-box::-webkit-scrollbar-track {
    background: transparent;
}
.output-box::-webkit-scrollbar-thumb {
    background: #3a3a5a;
    border-radius: 4px;
}

.copy-btn {
    flex-shrink: 0;
    background: #1e2f4a;
    border: 1px solid #3a3a5a;
    border-radius: 12px;
    padding: 0 20px;
    color: #b8c8e8;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    height: 100%;
    min-height: 46px;
}
.copy-btn:hover {
    background: #2d4a7a;
    color: #fff;
    border-color: #4a5a8a;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(45, 74, 122, 0.25);
}
.copy-btn:active {
    transform: scale(0.94);
}
.copy-btn .icon {
    font-size: 17px;
    line-height: 1;
}
.copy-btn.copied {
    background: #1e4a3a;
    border-color: #3a7a5a;
    color: #8cd4b0;
}

.limit-warning {
    color: #f0a070;
    font-size: 12.5px;
    margin-top: 8px;
    padding: 6px 14px;
    background: rgba(240, 160, 112, 0.07);
    border-radius: 8px;
    border: 1px solid rgba(240, 160, 112, 0.12);
    display: none;
    align-items: center;
    gap: 8px;
}
.limit-warning.show {
    display: flex;
}
.limit-warning .warn-icon {
    font-size: 15px;
}

/* ============================================================
   PICKER MODAL (拾色器弹窗)
   ============================================================ */
#pickerModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease;
}
#pickerModal.open {
    display: flex;
    opacity: 1;
}
#pickerModal.open .picker-window {
    transform: scale(1);
    opacity: 1;
}

.picker-window {
    background: #2d2d3f;
    padding: 22px 28px 24px;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    border: 1px solid #4a4a6a;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transform: scale(0.92);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    max-width: 560px;
    width: 100%;
}

.picker-body {
    display: flex;
    flex-direction: row;
    gap: 18px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ---- 色板 ---- */
.picker-container {
    position: relative;
    width: 200px;
    height: 200px;
    cursor: crosshair;
    flex-shrink: 0;
    touch-action: none;
}
#picker-canvas {
    border-radius: 6px;
    width: 100%;
    height: 100%;
    display: block;
    border: 1px solid #3a3a5a;
    pointer-events: none;
}
.picker-indicator {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2.5px solid #fff;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
    background: #ff0000;
    will-change: left, top;
}

/* ---- Hue 竖条 ---- */
.hue-container {
    position: relative;
    width: 22px;
    height: 200px;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: none;
}
#hue-canvas {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    display: block;
    border: 1px solid #3a3a5a;
    pointer-events: none;
}
.hue-slider {
    position: absolute;
    left: -10px;
    width: calc(100% + 20px);
    height: 0px;
    background: transparent;
    pointer-events: none;
    transform: translateY(-50%);
    z-index: 2;
    will-change: top;
}
.hue-slider::before,
.hue-slider::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
}
.hue-slider::before {
    left: 0;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #fff;
}
.hue-slider::after {
    right: -2px;
    border-width: 6px 10px 6px 0;
    border-color: transparent #fff transparent transparent;
}

/* ---- 右侧控制 ---- */
.picker-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 140px;
}
.picker-preview {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #1a1a2e;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #3a3a5a;
}
.picker-preview .preview-swatch {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid #3a3a5a;
    background: #ffffff;
    flex-shrink: 0;
}
.picker-preview .hex-code {
    color: #ddd;
    font-size: 13px;
    font-weight: 500;
    background: #121224;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
    outline: none;
    width: 80px;
    letter-spacing: 0.5px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    transition: border-color 0.2s, background 0.2s;
}
.picker-preview .hex-code:focus {
    border-color: #6c8cff;
    background: #000;
}

.rgb-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rgb-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.rgb-item .rgb-label {
    width: 18px;
    font-size: 12px;
    font-weight: 700;
    color: #aaa;
    text-align: right;
    flex-shrink: 0;
}
.rgb-item .rgb-label.r {
    color: #ff6b6b;
}
.rgb-item .rgb-label.g {
    color: #51cf66;
}
.rgb-item .rgb-label.b {
    color: #339af0;
}
.rgb-item input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 5px;
    border-radius: 3px;
    outline: none;
    background: #3a3a5a;
    transition: background 0.1s;
    --thumb-color: #fff;
}
.rgb-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--thumb-color);
    border: 2px solid #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
    cursor: pointer;
}
.rgb-item input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--thumb-color);
    border: 2px solid #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
    cursor: pointer;
}
.rgb-item .rgb-input {
    width: 32px;
    text-align: center;
    color: #ddd;
    font-size: 12px;
    background: #121224;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 0;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}
.rgb-item .rgb-input::-webkit-outer-spin-button,
.rgb-item .rgb-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.rgb-item .rgb-input:focus {
    border-color: #6c8cff;
}

/* ---- 弹窗按钮 ---- */
.picker-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid #3a3a5a;
}
.picker-buttons .btn {
    padding: 7px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: inherit;
}
.picker-buttons .btn-cancel {
    background: #3a3a5a;
    color: #b0b8cc;
}
.picker-buttons .btn-cancel:hover {
    background: #4a4a6a;
}
.picker-buttons .btn-confirm {
    background: #4a7acc;
    color: #fff;
}
.picker-buttons .btn-confirm:hover {
    background: #5a8add;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(74, 122, 204, 0.3);
}
.picker-buttons .btn-confirm:active {
    transform: scale(0.94);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
    .app-container {
        padding: 18px 14px 22px;
    }
    .app-header h1 {
        font-size: 18px;
    }
    .mode-toggle .mode-btn {
        padding: 6px 14px;
        font-size: 12px;
    }
    .preview-box {
        font-size: 17px;
        padding: 12px 14px;
    }
    .output-wrapper {
        flex-direction: column;
    }
    .copy-btn {
        justify-content: center;
        padding: 10px 16px;
        min-height: 40px;
        height: auto;
    }
    .output-box {
        font-size: 12px;
        padding: 10px 12px;
        max-height: 70px;
    }
    .color-list {
        flex-wrap: wrap;
        gap: 4px;
    }
    .color-item {
        flex: 1 1 45%;
        min-width: 80px;
    }
    .picker-window {
        padding: 16px 14px 18px;
        max-width: 95%;
        margin: 10px;
    }
    .picker-body {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    .picker-container {
        width: 170px;
        height: 170px;
    }
    .hue-container {
        height: 170px;
        width: 20px;
    }
    .picker-controls {
        width: 100%;
        min-width: 0;
    }
    .color-picker-trigger {
        width: 24px;
        height: 24px;
    }
    .color-bar-track {
        height: 30px;
    }
    .color-bar-wrap {
        padding: 0 0 18px;
    }
    .top-colors {
        height: 28px;
    }
    .field-group .field-label .label-with-tip .tip {
        font-size: 10px;
    }
}
@media (max-width: 400px) {
    .app-container {
        padding: 12px 8px 16px;
    }
    .preview-box {
        font-size: 14px;
        padding: 10px 10px;
    }
    .picker-container {
        width: 140px;
        height: 140px;
    }
    .hue-container {
        height: 140px;
        width: 16px;
    }
    .field-group .field-label .label-with-tip .tip {
        font-size: 9px;
    }
}