:root {
    --font-family:
        -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --background-color: #f4f4f4;
    --h-color: #444;
    --text-color: #111;
    --selection: rgba(61, 61, 61, 0.2);
    --hr-color: rgba(0, 0, 0, 0.1);
    --label-color: #666;
    --input-color: #212121;
    --input-background-color: #fff;
    --input-border-color: #dfdfe2;
    --input-hover-border-color: rgba(0, 0, 0, 0.1);
    --input-hover-box-shadow: rgba(100, 163, 234, 0.2);
    --input-focus-border-color: rgba(100, 163, 234, 0.5);
    --input-focus-box-shadow: rgba(100, 163, 234, 0.2);
    --checkbox: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16px' height='16px' viewBox='0 0 24 24'%3E%3Cpath fill='%23111' d='m9 20.42l-6.21-6.21l2.83-2.83L9 14.77l9.88-9.89l2.83 2.83z'/%3E%3C/svg%3E");
    --ui-color: rgba(100, 163, 234);
    --ui-color-active: rgba(127, 163, 204, 0.8);
    --ui-color-hover: rgba(100, 163, 234, 0.8);
    --ui-color-disabled: hsla(212, 0%, 65%, 0.8);
}
@media (prefers-color-scheme: dark) {
    :root {
        --background-color:#1c1c1e;
        --text-color: #ddd;
        --h-color: #999;
        --marker-color: #888;
        --higlight-color: #65a7f1;
        --hr-color: rgba(255,255,255,0.1);
        --border-color: rgba(0,0,0,.28);
        --selection: rgba(181,181,181,.2);
        --input-color: #ddd;
        --input-background-color: #3c3c3e;
        --input-border-color: rgba(255,255,255,0.2);
        --input-hover-border-color: rgba(255,255,255,0.2);
        --input-hover-box-shadow: rgba(100,163,234,0.2);
        --input-focus-border-color: rgba(100,163,234,0.65);
        --input-focus-box-shadow: rgba(100,163,234,0.2);
        --checkbox: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16px' height='16px' viewBox='0 0 24 24'%3E%3Cpath fill='%23ddd' d='m9 20.42l-6.21-6.21l2.83-2.83L9 14.77l9.88-9.89l2.83 2.83z'/%3E%3C/svg%3E")
    }
}
*,
:after,
:before {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}
body {
    font-family: var(--font-family);
    font-size: 16px;
    background: var(--background-color);
    color: var(--text-color);
    flex: 1;
    align-items: stretch;
    min-height: 0;
    display: flex;
    min-height: 100vh;
    accent-color: var(--input-focus-border-color);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
button {
    all: unset;
    box-sizing: border-box;
    display: flex;
    color: var(--text-color);
    cursor: pointer;
}
.btn {
    --bg-color: var(--ui-color);
    display: flex;
    padding: 10px 20px;
    border: none;
    background: var(--bg-color);
    color: #fff;
    cursor: pointer;
    border-radius: 8px;
    font-size: 16px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.3s ease;
}
.btn:active,
.btn:focus {
    outline: none;
}
.btn:active {
    --bg-color: var(--ui-color-active);
}
.btn:disabled {
    --bg-color: var(--ui-color-disabled);
    cursor: not-allowed;
}
input,
textarea {
    appearance: none;
    position: relative;
    z-index: 2;
    background-color: var(--input-background-color);
    font: inherit;
    color: var(--input-color) !important;
    width: 100%;
    border: 2px solid var(--input-border-color);
    padding: 0.5em 1em;
    border-radius: 8px;
    outline: none;
    transition:
        border-color 0.2s ease,
        outline 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
@media (hover: hover) {
    .btn:hover:not(:disabled) {
        --bg-color: var(--ui-color-hover);
    }
    .btn:active:not(:disabled) {
        --bg-color: var(--ui-color-active);
    }
    input:hover,
    textarea:hover {
        border-color: var(--input-hover-border-color);
        box-shadow: 0 0 0 4px var(--input-hover-box-shadow);
    }
}
input:focus-visible,
textarea:focus-visible {
    border-color: var(--input-focus-border-color);
    box-shadow: 0 0 0 4px var(--input-focus-box-shadow);
}

input.error {
    border-color: rgba(234, 100, 100, 0.5);
    box-shadow: 0 0 0 4px rgba(234, 100, 100, 0.2);
}
.options-item {
    position: relative;
    display: flex;
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: calc(50% - 12px);
}
label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

label:before {
    content: "";
    flex-shrink: 0;
    display: block;
    color: #fff;
    border: 2px solid var(--input-border-color);
    background-color: var(--input-background-color);
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
    width: 20px;
    height: 20px;
    border-radius: 5px;
}
input:hover ~ label:before {
    box-shadow: 0 0 0 4px var(--input-hover-box-shadow);
}
input:checked ~ label:before {
    border-color: var(--input-focus-border-color);
    background-image: var(--checkbox);
    background-repeat: no-repeat;
    background-position: 50%;
    background-size: 75%;
}
input[type="checkbox"] {
    position: absolute;
    left: 0;
    z-index: -1;
    width: 1rem;
    height: 1.15625rem;
    opacity: 0;
}
input:checked {
    box-shadow: 0 0 0 2px var(--input-focus-box-shadow);
    border-radius: 4px;
}

.wheel-section {
    position: relative;
    display: flex;
    flex-grow: 1;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    min-width: 375px;
    padding: 25px 44px;
    transition: width .3s cubic-bezier(.4, 0, .2, 1), max-width .3s cubic-bezier(.4, 0, .2, 1);
}

.wheel-container {
    position: relative;
    width: 100%;
    min-width: 375px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#wheelCanvas {
    border-radius: 50%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    width: 100%;
    height: 100%;
    min-width: 375px;
    max-width: 700px;
    max-height: 700px;
}

.pointer {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 40px solid #ccc;
    z-index: 10;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    transition: border-top-color 0.15s ease;
}
.pointer::after {
    content: '';
    position: absolute;
    top: -40px;
    right: 0;
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-top: 40px solid rgba(255, 255, 255, 0.2);
}
.sidebar-icon {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    margin: 12px 16px 0 0;
}
.sidebar {
    position: relative;
    z-index: 102;
    top: 0;
    bottom: 0;
    right: 0;
    max-width: 0;
    will-change: transform, max-width;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1), max-width .3s cubic-bezier(.4, 0, .2, 1);
    flex-shrink: 0;
    transform: translate(100%);
    
    transform: none;
}
.sidebar.open {
    position: relative;
    width: 380px;
    max-width: 380px;
    transform: translate(0);
}
.controls {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    padding: 14px;
    border-right: 1px solid var(--hr-color);
    background-color: var(--input-background-color);
    width: 380px;
    min-width: 0;
    height: 100%;
    max-height: 100dvh;
}
.sidebar-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}
h2 {
    font-size: 24px;
}

input[type="text"],
input[type="number"] {
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.input-duration {
    width: 64px;
    text-align: center;
}

textarea {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    min-height: 250px;
    max-height: 350px;
    transition: border-color 0.3s;
    flex-shrink: 0;
}

.bulk-hint {
    font-size: 12px;
    color: #888;
    font-style: italic;
    line-height: 1.5;
}

.btn-spin {
    justify-content: center;
    font-size: 18px;
    padding: 15px 40px;
    width: 100%;
    max-width: 340px;
    text-align: center;
}

.options {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0;
    border: 1px solid #e0e0e0;
    border-width: 1px 0;
}

.options label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
}

.duration-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}

.duration-row span {
    flex: 1;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}
.segments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.segments-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.btn-restore-all {
    color: white;
    line-height: 1;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
    display: none;
    align-items: center;
    gap: 5px;
    user-select: none;
}

.btn-restore-all.visible {
    display: flex;
}
.segments-list {
    flex: 1 1 0%;
    position: relative;
    overflow: hidden auto;
    height: 100%;
    padding-right: 7px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.segments-list::-webkit-scrollbar {
    width: .375rem;
}
.segments-list::-webkit-scrollbar-thumb {
    background: var(--input-border-color);
    border-radius: 999px;
}
.segment-item {
    position: relative;
    --item-color: var(--input-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--input-background-color);
    border-radius: 5px 8px 8px 5px;
    border: 1px solid var(--item-color);
    border-width: 1px 1px 1px 5px;
    transition: all 0.3s;
    gap: 10px;
}

.segment-item.excluded {
    background: rgba(0, 0, 0, .2);
}
.segment-item.excluded::after {
    content: "";
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--input-background-color);
    opacity: .8;
}

.segment-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    color: var(--input-color);
    flex: 1;
    min-width: 0;
}

.segment-name span {
    max-width: 25ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.segment-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.weight-controls {
    position: relative;
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    user-select: none;
}

.btn-weight {
    width: 24px;
    background-color: var(--input-background-color);
    border: 1px solid var(--input-border-color);
    border-radius: 8px;
    color: var(--input-color);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 .75em;
    transition: all 0.2s;
}
.btn-weight:first-child {
    border-right-width: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.btn-weight:last-child {
    border-left-width: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.btn-weight:hover:not(:disabled) {
    background-color: rgba(0, 0, 0, 8%);
}

.btn-weight:disabled {
    color: var(--label-color);
    cursor: not-allowed;
}

.weight-controls .weight-value {
    border-radius: 0;
    border-width: 1px;
    min-width: 22px;
    width: 38px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    padding: 5px 2px;
}
.weight-controls .weight-value:hover,
.weight-controls .weight-value:focus {
    box-shadow: none;
}
.btn-restore {
    position: relative;
    z-index: 3;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}
.btn-delete {
    display: flex;
    align-items: center;
    background: transparent;
    color: #ff6b6b;
    padding: 0;
    font-size: 18px;
    flex-shrink: 0;
}

.btn-delete:hover,
.btn-delete:focus {
    background: transparent !important;
    color: #ff3232;
}

.result {
    opacity: 0;
    position: absolute;
    bottom: 30%;
    background: white;
    color: black;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    font-size: clamp(16px, 3.2vw, 27px);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all .3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: translateY(30px);
}
.result.show {
    opacity: 1;
    transform: translateY(0);
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    pointer-events: none;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 968px) {

    #wheelCanvas {
        
    }
}
