#tag-sidebar {
    width: 100%;
    flex: 1;
    box-sizing: border-box;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    margin: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 16px;
}

#sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.main-tag-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tag-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.subtag-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 4px 20px;
}

.tag-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag-name {
    flex: 1;
    font-size: 1rem;
    color: #e8e8e8;
}

.tag-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.tag-row:hover .tag-actions,
.subtag-row:hover .tag-actions {
    opacity: 1;
}

.tag-actions button {
    background: none;
    border: none;
    color: #666;
    padding: 2px 4px;
    font-size: 0.8125rem;
    cursor: pointer;
}

.tag-actions button:hover {
    color: #aaa;
    background: none;
}

.add-subtag-btn {
    background: #1e1e1e;
    color: #ccc;
    border: 1px solid #333;
    border-radius: 6px;
    font-size: 0.8125rem;
    padding: 4px 10px;
    margin-left: 20px;
    cursor: pointer;
    display: inline-block;
    width: auto;
    transition: background 0.15s;
}

.add-subtag-btn:hover {
    background: #2a2a2a;
    color: #ccc;
}

#tag-form {
    border-top: 1px solid #2a2a2a;
    padding-top: 12px;
}

.tag-form-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tag-form-inner input[type="text"] {
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 8px 10px;
    color: #e8e8e8;
    font-size: 1rem;
    outline: none;
    width: 100%;
}

.tag-form-inner input[type="text"]:focus {
    border-color: #2563eb;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.color-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

.color-circle:hover:not(.disabled) {
    transform: scale(1.2);
}


.color-circle.disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.color-circle.selected {
    border-color: white;
}

.form-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.form-error {
    color: #f87171;
}

.merge-autocomplete {
    position: relative;
}

.merge-autocomplete input[type="text"] {
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 8px 10px;
    color: #e8e8e8;
    font-size: 1rem;
    outline: none;
    width: 100%;
}

.merge-autocomplete input[type="text"]:focus {
    border-color: #2563eb;
}

.merge-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    max-height: 140px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.merge-dropdown.open {
    display: block;
}

.merge-dropdown-item {
    padding: 8px 10px;
    color: #e8e8e8;
    font-size: 1rem;
    cursor: pointer;
}

.merge-dropdown-item:hover {
    background: #2a2a2a;
}

.merge-dropdown-empty {
    padding: 8px 10px;
    color: #666;
    font-size: 1rem;
}

.subtag-list.collapsed {
    display: none;
}

.toggle-subtags {
    cursor: pointer;
}

.toggle-subtags:hover {
    color: #60a5fa;
}