/* ============================================================
   Color Palette Generator
   ============================================================ */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: #1a1a1a;
    background: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app { height: 100%; }

/* boot ----------------------------------------------------- */
.boot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    height: 100vh;
    color: #777;
}
.boot-spinner {
    width: 32px; height: 32px;
    border: 3px solid #e5e5e5;
    border-top-color: #4a50fc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-label { font-size: 0.9rem; }

/* layout --------------------------------------------------- */
.page {
    display: grid;
    grid-template-columns: 460px 1fr;
    gap: 40px;
    padding: 32px 40px 24px;
    min-height: 100vh;
    max-width: 1700px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}
.brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: linear-gradient(135deg, #ff3b30, #ff7a59);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.05);
}
.brand-name { font-weight: 600; font-size: 14px; color: #1a1a1a; }

h1.page-title {
    font-size: 36px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 14px;
}
.page-sub {
    color: #555;
    margin: 0 0 22px;
    line-height: 1.45;
    max-width: 430px;
    font-size: 14px;
}

/* tabs ----------------------------------------------------- */
.tabs {
    display: flex;
    gap: 28px;
    border-bottom: 1px solid #eaeaea;
    margin-bottom: 24px;
}
.tab {
    background: transparent;
    border: 0;
    padding: 10px 2px;
    font: inherit;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab svg { width: 18px; height: 18px; }
.tab.active {
    color: #111;
    border-bottom-color: #1a1a1a;
}

/* color wheel --------------------------------------------- */
.wheel-wrap {
    position: relative;
    width: 360px;
    height: 360px;
    margin: 8px 0 20px;
    user-select: none;
    touch-action: none;
}
.wheel-svg {
    position: absolute;     /* sit ON TOP of .wheel-bg, not under it */
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    z-index: 2;
}
.wheel-svg.is-dragging { cursor: grabbing; }
.wheel-svg:active { cursor: grabbing; }

.harmony-line {
    stroke: rgba(255,255,255,0.85);
    stroke-width: 1.5;
    fill: none;
    pointer-events: none;
}

/* ---- secondary dots ---- */
.dot-group { cursor: grab; }
.dot-group.is-active,
.dot-group:active { cursor: grabbing; }

.dot-hit {                /* large transparent hit area */
    fill: transparent;
    stroke: transparent;
}
.dot-ring {               /* white outer ring — visible on any background */
    fill: white;
    stroke: rgba(0,0,0,0.45);
    stroke-width: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    pointer-events: none;
}
.dot-fill {               /* colored center matching the palette stop */
    stroke: rgba(0,0,0,0.25);
    stroke-width: 0.5;
    pointer-events: none;
    transition: r 0.1s ease;
}
.dot-group:hover .dot-fill { r: 9; }
.dot-group.is-active .dot-fill { r: 9.5; }

/* ---- source / "center" dot — drags the whole harmony ---- */
.source-group { cursor: grab; }
.source-group.is-active,
.source-group:active { cursor: grabbing; }

.src-outer {              /* large dashed anchor ring */
    fill: rgba(255,255,255,0.18);
    stroke: white;
    stroke-width: 2;
    stroke-dasharray: 3 3;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
    pointer-events: none;
}
.src-ring {               /* solid white ring just inside the dashed one */
    fill: white;
    stroke: rgba(0,0,0,0.45);
    stroke-width: 1;
    pointer-events: none;
}
.src-fill {               /* colored center matching the source color */
    stroke: rgba(0,0,0,0.3);
    stroke-width: 0.5;
    pointer-events: none;
    transition: r 0.1s ease;
}
.source-group:hover .src-fill { r: 10.5; }
.source-group.is-active .src-fill { r: 11; }
.src-cross {              /* tiny crosshair marker in the source center */
    stroke: white;
    stroke-width: 1.4;
    stroke-linecap: round;
    pointer-events: none;
    mix-blend-mode: screen;
}

/* harmony selector --------------------------------------- */
.harmony-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}
.harmony-label strong { font-size: 14px; color: #1a1a1a; }
.harmony-label span { font-size: 14px; color: #444; }

.harmony-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.harmony-btn {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: #1a1a1a;
    transition: border-color 0.12s, background 0.12s;
}
.harmony-btn:hover { border-color: #bbb; }
.harmony-btn.active { border-color: #1a1a1a; background: #fafafa; }
.harmony-btn svg { width: 26px; height: 26px; }

.harmony-more {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #e5e5e5;
    background: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    margin-left: 4px;
    color: #888;
}
.harmony-more:hover { color: #1a1a1a; border-color: #bbb; }

/* right side / palette ----------------------------------- */
.palette-area {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.palette-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}
.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1a1a1a;
    font-weight: 500;
    font-size: 14px;
}
.toolbar-left .divider {
    width: 1px; height: 18px; background: #e5e5e5; margin: 0 6px;
}
.icon-btn {
    background: transparent;
    border: 0;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    color: #555;
    display: inline-grid;
    place-items: center;
}
.icon-btn:hover { background: #f3f3f3; color: #111; }
.icon-btn svg { width: 18px; height: 18px; }
.toolbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-pill {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 999px;
    padding: 8px 14px;
    font: inherit;
    font-size: 13px;
    color: #1a1a1a;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-pill:hover { border-color: #bbb; }

/* big swatches ------------------------------------------- */
.swatches {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    border-radius: 18px;
    overflow: hidden;
    min-height: 580px;
    flex: 1;
}
.swatch {
    position: relative;
    display: flex;
    align-items: flex-end;
    padding: 18px;
    cursor: pointer;
    transition: filter 0.1s;
}
.swatch:hover { filter: brightness(0.97); }
.swatch.is-source::before {
    content: "";
    position: absolute;
    top: 18px;
    left: 18px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at center, transparent 0 5px, rgba(255,255,255,0.95) 6px 7px, transparent 8px 100%);
    box-shadow: 0 0 0 1.5px rgba(255,255,255,0.9) inset;
}
.swatch.is-source::after {
    content: "";
    position: absolute;
    top: 28px;
    left: 28px;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 0 1px white;
}
.swatch-hex {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.18);
    flex: 1;
}
.swatch.light .swatch-hex { color: #1a1a1a; text-shadow: none; }
.swatch.light.is-source::before { box-shadow: 0 0 0 1.5px rgba(0,0,0,0.5) inset; background: radial-gradient(circle at center, transparent 0 5px, rgba(0,0,0,0.6) 6px 7px, transparent 8px 100%); }
.swatch.light.is-source::after { background: #1a1a1a; box-shadow: 0 0 0 1px #1a1a1a; }

.swatch-copy {
    background: transparent;
    border: 0;
    padding: 4px;
    cursor: pointer;
    color: rgba(255,255,255,0.85);
    opacity: 0;
    transition: opacity 0.12s;
}
.swatch:hover .swatch-copy { opacity: 1; }
.swatch.light .swatch-copy { color: rgba(0,0,0,0.7); }
.swatch-copy svg { width: 18px; height: 18px; }

/* mini bar + name + cta ---------------------------------- */
.under-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 14px;
    align-items: center;
    margin-top: 14px;
}
.mini-bar {
    display: flex;
    gap: 4px;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    max-width: 260px;
}
.mini-bar .mini { flex: 1; }
.under-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #555;
}
.under-actions .icon-btn svg { width: 20px; height: 20px; }

.name-input {
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 6px 12px;
    width: 200px;
    background: #fff;
}
.name-input label { display: block; font-size: 11px; color: #888; }
.name-input input {
    border: 0;
    outline: none;
    font: inherit;
    width: 100%;
    background: transparent;
    color: #1a1a1a;
    font-size: 14px;
}

.cta {
    background: #4a50fc;
    color: white;
    border: 0;
    border-radius: 999px;
    padding: 12px 22px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}
.cta:hover { background: #3b41e8; }

/* edit color popover ------------------------------------- */
.edit-pop {
    position: absolute;
    width: 280px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 18px 48px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.08);
    padding: 16px;
    z-index: 30;
    user-select: none;
}
.edit-pop-head {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}
.edit-pop-title { font-weight: 600; font-size: 13px; color: #1a1a1a; }
.edit-pop-mode {
    margin-left: auto;
    background: transparent;
    border: 0;
    font: inherit;
    color: #555;
    font-size: 12px;
    cursor: pointer;
}
.edit-pop label {
    display: block;
    font-size: 11px;
    color: #888;
    margin: 0 0 4px;
    letter-spacing: 0.04em;
}
.edit-pop .hex-field {
    border: 1.5px solid #4a50fc;
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 12px;
    background: #eef0ff;
    color: #1a1a1a;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    width: 100%;
    outline: none;
}
.sv-pad {
    position: relative;
    height: 140px;
    border-radius: 6px;
    margin-bottom: 10px;
    touch-action: none;
    cursor: crosshair;
    overflow: hidden;
}
.sv-pad::before, .sv-pad::after {
    content: "";
    position: absolute; inset: 0;
    pointer-events: none;
}
.sv-pad::before { background: linear-gradient(to right, #fff, transparent); }
.sv-pad::after { background: linear-gradient(to top, #000, transparent); }
.sv-thumb {
    position: absolute;
    width: 14px; height: 14px;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.25);
    pointer-events: none;
}
.hue-slider, .br-slider {
    position: relative;
    height: 12px;
    border-radius: 8px;
    margin: 6px 0 14px;
    touch-action: none;
    cursor: pointer;
}
.hue-slider {
    background: linear-gradient(to right,
        #ff0000 0%, #ffff00 17%, #00ff00 33%,
        #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
}
.br-slider {
    /* background set inline */
}
.slider-thumb {
    position: absolute;
    top: 50%;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid white;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.25);
    pointer-events: none;
}
.br-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.br-row svg { width: 18px; height: 18px; color: #777; flex-shrink: 0; }
.br-slider { flex: 1; margin: 0; }
.br-value {
    min-width: 30px;
    text-align: right;
    font-size: 12px;
    color: #555;
}

/* toast --------------------------------------------------- */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: white;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.25);
    z-index: 100;
    animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* responsive --------------------------------------------- */
@media (max-width: 1100px) {
    .page { grid-template-columns: 1fr; }
    .wheel-wrap { width: 320px; height: 320px; }
    .swatches { min-height: 420px; }
}
